id_base); if( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) ) $number = 5; $vault = new WP_Query( apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) ); if( $vault->have_posts() ) : $before_title = '

'; $after_title = '

'; echo $before_widget; if( $title ) echo $before_title . $title . $after_title; ?>
have_posts() ) : $vault->the_post(); ?>
id; if ( isset( $cache[ $args['widget_id'] ] ) ) { echo $cache[ $args['widget_id'] ]; return; } extract($args, EXTR_SKIP); $output = ''; $title = ( ! empty( $instance['title'] ) && isset($instance['title']) ) ? $instance['title'] : __( 'Recent Comments', 'bellini' ); /** This filter is documented in wp-includes/default-widgets.php */ $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); $number = ( ! empty( $instance['number'] ) && isset($instance['number']) ) ? absint( $instance['number'] ) : 5; if ( ! $number ) $number = 5; $comments = get_comments( apply_filters( 'widget_comments_args', array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish' ) ) ); $output .= $before_widget; if ( $title ) $output .= $before_title . $title . $after_title; if ( $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 .= '
'; if(get_avatar($comment)) { $output .= '
'; $output .= ''; $output .= get_avatar( $comment, 80 ); $output .= ''; $output .= '
'; $output .= '
'; } else { $output .= '
'; } $output .= sprintf(__('%1$s on %2$s', 'bellini'), get_comment_author_link(), ''; $output .= get_the_title($comment->comment_post_ID) . ''; $output .= '
'; $output .= '
'; } } $output .= $after_widget; echo $output; $cache[$args['widget_id']] = $output; wp_cache_set('widget_recent_comments', $cache, 'widget'); } }