Speed up Recent Comments dash module query
git-svn-id: https://develop.svn.wordpress.org/trunk@10079 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
154cc86cb5
commit
d31387d674
@ -396,17 +396,25 @@ function wp_dashboard_recent_drafts( $drafts = false ) {
|
||||
* @since unknown
|
||||
*/
|
||||
function wp_dashboard_recent_comments() {
|
||||
$status = ( current_user_can('edit_posts') ) ? '' : 'approved';
|
||||
global $wpdb;
|
||||
|
||||
list($comments, $total) = _wp_get_comment_list( $status, false, 0, 5 );
|
||||
if ( current_user_can('edit_posts') )
|
||||
$allowed_states = array('0', '1');
|
||||
else
|
||||
$allowed_states = array('1');
|
||||
|
||||
// Select all comment types and filter out spam later for better query performance.
|
||||
$comments = $wpdb->get_results( "SELECT * FROM $wpdb->comments ORDER BY comment_date_gmt DESC LIMIT 0, 50" );
|
||||
|
||||
if ( $comments ) :
|
||||
?>
|
||||
|
||||
<div id="the-comment-list" class="list:comment">
|
||||
<?php
|
||||
foreach ( $comments as $comment )
|
||||
_wp_dashboard_recent_comments_row( $comment );
|
||||
foreach ( $comments as $comment ) {
|
||||
if ( in_array($comment->comment_approved, $allowed_states) )
|
||||
_wp_dashboard_recent_comments_row( $comment );
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user