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

git-svn-id: http://svn.automattic.com/wordpress/trunk@10090 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2008-12-06 21:23:36 +00:00
parent c25fbefaea
commit c647bdc9bb
1 changed files with 16 additions and 9 deletions

View File

@ -404,21 +404,28 @@ function wp_dashboard_recent_comments() {
$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" );
$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 ) :
?>
<div id="the-comment-list" class="list:comment">
<?php
$count = 0;
foreach ( $comments as $comment ) {
if ( $count >= 5 )
break;
if ( in_array($comment->comment_approved, $allowed_states) )
_wp_dashboard_recent_comments_row( $comment );
$count++;
}
foreach ( $comments as $comment )
_wp_dashboard_recent_comments_row( $comment );
?>
</div>