Ticket #15400: 15400-updated.patch
| File 15400-updated.patch, 2.0 KB (added by , 15 years ago) |
|---|
-
wp-includes/default-widgets.php
649 649 else if ( $number < 1 ) 650 650 $number = 1; 651 651 652 add_action('comments_clauses', array( 'WP_Widget_Recent_Comments', 'comments_query_filter')); 652 653 $comments = get_comments( array( 'number' => $number, 'status' => 'approve' ) ); 654 remove_action('comments_clauses', array( 'WP_Widget_Recent_Comments', 'comments_query_filter')); 653 655 $output .= $before_widget; 654 656 if ( $title ) 655 657 $output .= $before_title . $title . $after_title; … … 657 659 $output .= '<ul id="recentcomments">'; 658 660 if ( $comments ) { 659 661 foreach ( (array) $comments as $comment) { 660 $output .= '<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>'; 662 $ispostcached = wp_cache_get($comment->ID, 'posts') == false ? false : true; 663 if(!$ispostcached) { 664 wp_cache_add($comment->ID, $comment, 'posts'); 665 } 666 $output .= '<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) ) . '">' . get_the_title($comment) . '</a>') . '</li>'; 667 if(!$ispostcached) { 668 wp_cache_delete($comment->ID, 'posts'); 669 } 661 670 } 662 671 } 663 672 $output .= '</ul>'; … … 692 701 <input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p> 693 702 <?php 694 703 } 704 705 function comments_query_filter($pieces) { 706 global $wpdb; 707 708 $pieces['join'] .= " LEFT JOIN $wpdb->posts ON ( $wpdb->comments.comment_post_ID = $wpdb->posts.ID )"; 709 710 return $pieces; 711 } 695 712 } 696 713 697 714 /**