Ticket #17020: dashboard-recent-comments-3.2.diff
File dashboard-recent-comments-3.2.diff, 1.9 KB (added by , 14 years ago) |
---|
-
wp-admin/includes/dashboard.php
594 594 * @since 2.5.0 595 595 */ 596 596 function wp_dashboard_recent_comments() { 597 global $wpdb;598 599 if ( current_user_can('edit_posts') )600 $allowed_states = array('0', '1');601 else602 $allowed_states = array('1');603 604 597 // Select all comment types and filter out spam later for better query performance. 605 598 $comments = array(); 606 $start = 0;607 599 608 600 $widgets = get_option( 'dashboard_widget_options' ); 609 601 $total_items = isset( $widgets['dashboard_recent_comments'] ) && isset( $widgets['dashboard_recent_comments']['items'] ) 610 602 ? absint( $widgets['dashboard_recent_comments']['items'] ) : 5; 603 604 $comment_args = array( 605 'status' => (current_user_can('edit_posts') ? null : 'hold'), 606 'number' => $total_items, 607 'offset' => 0, 608 'orderby' => 'comment_date_gmt', 609 'order' => 'DESC' 610 ); 611 612 $comments = get_comments( $comment_args ); 611 613 612 while ( count( $comments ) < $total_items && $possible = $wpdb->get_results( "SELECT * FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' ORDER BY c.comment_date_gmt DESC LIMIT $start, 50" ) ) {613 614 foreach ( $possible as $comment ) {615 if ( count( $comments ) >= $total_items )616 break;617 if ( in_array( $comment->comment_approved, $allowed_states ) && current_user_can( 'read_post', $comment->comment_post_ID ) )618 $comments[] = $comment;619 }620 621 $start = $start + 50;622 }623 624 614 if ( $comments ) : 625 615 ?> 626 616 627 617 <div id="the-comment-list" class="list:comment"> 628 618 <?php 629 619 foreach ( $comments as $comment ) 630 _wp_dashboard_recent_comments_row( $comment ); 620 if( current_user_can( 'read_post', $comment->comment_post_ID) ) 621 _wp_dashboard_recent_comments_row( $comment ); 631 622 ?> 632 623 633 624 </div>