'显示最新评论' ) ); } function form($instance) { $num = isset($instance['number']) ? absint($instance['number']) : 5; $title = isset($instance['title']) ? $instance['title'] : '最新评论'; ?>
id_base)) { echo $args['before_title'] . $title . $args['after_title']; } } public function widget_end($args) { echo $args['after_widget']; } function update($new_instance, $old_instance) { $instance = $old_instance; $instance['num'] = absint($new_instance['num']); $instance['title'] = sanitize_text_field($new_instance['title']); return $instance; } function widget($args, $instance) { $this->widget_start($args, $instance); $number = (!empty($instance['number'])) ? absint($instance['number']) : 5; $comments = get_comments( /** * Filters the arguments for the Recent Comments widget. * * @param array $comment_args An array of arguments used to retrieve the recent comments. * @param array $instance Array of settings for the current widget. * @see WP_Comment_Query::query() for information on accepted arguments. * * @since 3.4.0 * @since 4.9.0 Added the `$instance` parameter. * */ apply_filters( 'widget_comments_args', array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish', ), $instance ) ); foreach ($comments as $comment) { if ($comment->user_id) { $author_url = get_author_posts_url($comment->user_id); $userdata = get_userdata($comment->user_id); $display_name = $userdata->display_name; } else { $author_url = 'javascript:;'; $display_name = $comment->comment_author; } $post_title = get_the_title($comment->comment_post_ID); $post_link = get_permalink($comment->comment_post_ID); ?>
comment_content, 55))); ?>
评论于 comment_post_ID);?>