| 636 | | if ( !$comments = wp_cache_get( 'recent_comments', 'widget' ) ) { |
| 637 | | $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 15"); |
| 638 | | wp_cache_add( 'recent_comments', $comments, 'widget' ); |
| | 645 | $comments = get_comments(array('number' => $number)); |
| | 646 | |
| | 647 | echo $before_widget; |
| | 648 | if ( $title ) |
| | 649 | echo $before_title . $title . $after_title; |
| | 650 | |
| | 651 | echo '<ul id="recentcomments">'; |
| | 652 | if ( $comments ) { |
| | 653 | foreach ( (array) $comments as $comment) { |
| | 654 | echo '<li class="recentcomments">' . /* translators: comments widget: 1: comment author, 2: post link */ sprintf(_x('%1$s on %2$s', 'widgets'), get_comment_author_link(), '<a href="' . esc_url( get_comment_link($comment->comment_ID) ) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>'; |
| | 655 | } |
| 641 | | $comments = array_slice( (array) $comments, 0, $number ); |
| 642 | | ?> |
| 643 | | <?php echo $before_widget; ?> |
| 644 | | <?php if ( $title ) echo $before_title . $title . $after_title; ?> |
| 645 | | <ul id="recentcomments"><?php |
| 646 | | if ( $comments ) : foreach ( (array) $comments as $comment) : |
| 647 | | echo '<li class="recentcomments">' . /* translators: comments widget: 1: comment author, 2: post link */ sprintf(_x('%1$s on %2$s', 'widgets'), get_comment_author_link(), '<a href="' . esc_url( get_comment_link($comment->comment_ID) ) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>'; |
| 648 | | endforeach; endif;?></ul> |
| 649 | | <?php echo $after_widget; ?> |
| 650 | | <?php |
| | 660 | $cache[$args['widget_id']] = ob_get_flush(); |
| | 661 | wp_cache_add('widget_recent_comments', 'widget'); |