全国服务热线:4008-888-888

公司新闻

WordPress最近评价实用工具详细说明

WordPress近期评论小工具图1 WordPress最近评价实用工具

WordPress最近评价实用工具应用详细介绍

在网站【后台管理-外型-实用工具】中寻找最近评价实用工具,将它拖至要想展现的侧面栏中。
近期评论小工具设置图2 最近评价实用工具设定
大家能够设定最近评价实用工具的显示信息题目和显示信息的评价总数。
近期评论小工具前端预览图3 最近评价实用工具前端开发浏览
那样大家就非常简单的在网站内添加了最近评价的作用了。

WordPress最近评价实用工具源代码详细介绍

源代码部位:wp-includes\widgets\class-wp-ments.php
源码:(since 4.4.0)

 'ments',
 'description' => __( 'Your site s ments.' ),
 'customize_selective_refresh' => true,
 parent::__construct( 'ments', __( 'Recent Comments' ), $widget_ops );
 $this->alt_option_name = 'ments';
 if ( is_active_widget( false, false, $this->id_base ) || is_customize_preview() ) {
 add_action( 'wp_head', array( $this, 'ments_style' ) );
 * Outputs the default styles for the Recent Comments widget.
 * @since 2.8.0
 * @access public
 public ments_style() {
 * Filters the Recent Comments default widget styles.
 * @since 3.1.0
 * @param bool $active Whether the widget is active. Default true.
 * @param string $id_base The widget ID.
 if ( ! current_theme_supports( 'widgets' ) // Temp hack #14876
 || ! apply_filters( 'ments_widget_style', true, $this->id_base ) )
 return;
 $output = '';
 $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Comments' );
 /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
 $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5;
 if ( ! $number )
 $number = 5;
 * Filters the arguments for the Recent Comments widget.
 * @since 3.4.0
 * @see WP_Comment_Query::query() rmation on accepted arguments.
 * @param array $comment_args An array of arguments used to retrieve ments.
 $comments = ments( apply_filters( 'ments_args', array(
 'number' => $number,
 'status' => 'approve',
 'post_status' => 'publish'
 ) ) );
 $output .= $args['before_widget'];
 if ( $title ) {
 $output .= $args['before_title'] . $title . $args['after_title'];
 $output .= '';
 if ( is_array( $comments ) && $comments ) {
 // Prime cache for associated posts. (Prime post term cache if we need it for permalinks.)
 $post_ids = array_unique( wp_list_pluck( $comments, 'comment_post_ID' ) );
 _prime_post_caches( $post_ids, strpos( get_option( 'permalink_structure' ), '%category%' ), false );
 foreach ( (array) $comments as $comment ) {
 $output .= '';
 /* translators: comments widget: 1: comment author, 2: post link */
 $output .= sprintf( _x( '%1$s on %2$s', 'widgets' ),
 '' . ment_author_link( $comment ) . '',
 '' . get_the_title( $comment->comment_post_ID ) . ''
 $output .= '';
 $output .= '';
 $output .= $args['after_widget'];
 echo $output;
 * Handles updating settings for the current Recent Comments widget instance.
 * @since 2.8.0
 * @access public
 * @param array $new_instance New settings for this instance as input by the user via
 * WP_Widget::form().
 * @param array $old_instance Old settings for this instance.
 * @return array Updated settings to save.
 public function update( $new_instance, $old_instance ) {
 $instance = $old_instance;
 $instance['title'] = sanitize_text_field( $new_instance['title'] );
 $instance['number'] = absint( $new_instance['number'] );
 return $instance;
 * Outputs the settings form for the Recent Comments widget.
 * @since 2.8.0
 * @access public
 * @param array $instance Current settings.
 public function form( $instance ) {
 $title = isset( $instance['title'] ) ? $instance['title'] : '';
 $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
 

get_field_id( 'title' ); ?>"> get_field_id( 'title' ); ?>" name="get_field_name( 'title' ); ?>" type="text" value="" />

get_field_id( 'number' ); ?>"> get_field_id( 'number' ); ?>" name="get_field_name( 'number' ); ?>" type="number" step="1" min="1" value="" size="3" />

WordPress最近评价实用工具的详细介绍就到这儿,后边大家会解读怎样自定最近评价实用工具。



在线客服

关闭

客户服务热线
4008-888-888


点击这里给我发消息 在线客服

点击这里给我发消息 在线客服