mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-04 18:01:42 +01:00
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:
parent
c25fbefaea
commit
c647bdc9bb
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user