Changeset 20609
- Timestamp:
- 04/26/2012 09:09:51 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/dashboard.php
r20579 r20609 596 596 global $wpdb; 597 597 598 if ( current_user_can('edit_posts') )599 $allowed_states = array('0', '1');600 else601 $allowed_states = array('1');602 603 598 // Select all comment types and filter out spam later for better query performance. 604 599 $comments = array(); … … 609 604 ? absint( $widgets['dashboard_recent_comments']['items'] ) : 5; 610 605 611 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" ) ) { 612 606 $comments_query = array( 'number' => $total_items * 5, 'offset' => 0 ); 607 if ( ! current_user_can( 'edit_posts' ) ) 608 $comments_query['status'] = 'approve'; 609 610 while ( count( $comments ) < $total_items && $possible = get_comments( $comments_query ) ) { 613 611 foreach ( $possible as $comment ) { 614 if ( count( $comments ) >= $total_items ) 615 break; 616 if ( in_array( $comment->comment_approved, $allowed_states ) && current_user_can( 'read_post', $comment->comment_post_ID ) ) 617 $comments[] = $comment; 618 } 619 620 $start = $start + 50; 621 } 622 623 if ( $comments ) : 624 ?> 625 626 <div id="the-comment-list" class="list:comment"> 627 <?php 612 if ( ! current_user_can( 'read_post', $comment->comment_post_ID ) ) 613 continue; 614 $comments[] = $comment; 615 if ( count( $comments ) == $total_items ) 616 break 2; 617 } 618 $comments_query['offset'] += $comments_query['number']; 619 $comments_query['number'] = $total_items * 10; 620 } 621 622 if ( $comments ) { 623 echo '<div id="the-comment-list" class="list:comment">'; 628 624 foreach ( $comments as $comment ) 629 625 _wp_dashboard_recent_comments_row( $comment ); 630 ?> 631 632 </div> 633 634 <?php 635 if ( current_user_can('edit_posts') ) { ?> 636 <?php _get_list_table('WP_Comments_List_Table')->views(); ?> 637 <?php } 626 echo '</div>'; 627 628 if ( current_user_can('edit_posts') ) 629 _get_list_table('WP_Comments_List_Table')->views(); 638 630 639 631 wp_comment_reply( -1, false, 'dashboard', false ); 640 632 wp_comment_trashnotice(); 641 642 else : 643 ?> 644 645 <p><?php _e( 'No comments yet.' ); ?></p> 646 647 <?php 648 endif; // $comments; 633 } else { 634 echo '<p>' . __( 'No comments yet.' ) . '</p>'; 635 } 649 636 } 650 637
Note: See TracChangeset
for help on using the changeset viewer.