Improve the recent comments dashboard widget, props matt, fixes #8510

git-svn-id: https://develop.svn.wordpress.org/trunk@10090 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2008-12-06 21:23:36 +00:00
parent 9155619b9e
commit cee6f56637
1 changed files with 16 additions and 9 deletions

View File

@ -404,21 +404,28 @@ function wp_dashboard_recent_comments() {
$allowed_states = array('1'); $allowed_states = array('1');
// Select all comment types and filter out spam later for better query performance. // 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" ); $comments = array();
$start = 0;
while ( count( $comments ) < 5 && $possible = $wpdb->get_results( "SELECT * FROM $wpdb->comments ORDER BY comment_date_gmt DESC LIMIT $start, 50" ) ) {
foreach ( $possible as $comment ) {
if ( count( $comments ) >= 5 )
break;
if ( in_array( $comment->comment_approved, $allowed_states ) )
$comments[] = $comment;
}
$start = $start + 50;
}
if ( $comments ) : if ( $comments ) :
?> ?>
<div id="the-comment-list" class="list:comment"> <div id="the-comment-list" class="list:comment">
<?php <?php
$count = 0; foreach ( $comments as $comment )
foreach ( $comments as $comment ) {
if ( $count >= 5 )
break;
if ( in_array($comment->comment_approved, $allowed_states) )
_wp_dashboard_recent_comments_row( $comment ); _wp_dashboard_recent_comments_row( $comment );
$count++;
}
?> ?>
</div> </div>