Coding Standards: Move count() usage in wp_dashboard_recent_comments().
While the rule to discourage using functions like `count()` in a loop condition is a recommendation/best practice rule from the `WordPress-Extra` ruleset and does not directly apply to WordPress core, this is intended as a minor readability and code clarity improvement. Follow-up to [10090], [17556], [20609], [26144]. Props krunal265, johnbillion, audrasjb, dhruvang21, SergeyBiryukov. Fixes #56499. Built from https://develop.svn.wordpress.org/trunk@60643 git-svn-id: http://core.svn.wordpress.org/trunk@59979 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -1074,8 +1074,10 @@ function wp_dashboard_recent_comments( $total_items = 5 ) {
|
||||
$comments_query['status'] = 'approve';
|
||||
}
|
||||
|
||||
while ( count( $comments ) < $total_items && $possible = get_comments( $comments_query ) ) {
|
||||
if ( ! is_array( $possible ) ) {
|
||||
do {
|
||||
$possible = get_comments( $comments_query );
|
||||
|
||||
if ( empty( $possible ) || ! is_array( $possible ) ) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1088,16 +1090,17 @@ function wp_dashboard_recent_comments( $total_items = 5 ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$comments[] = $comment;
|
||||
$comments[] = $comment;
|
||||
$comments_count = count( $comments );
|
||||
|
||||
if ( count( $comments ) === $total_items ) {
|
||||
if ( $comments_count === $total_items ) {
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
|
||||
$comments_query['offset'] += $comments_query['number'];
|
||||
$comments_query['number'] = $total_items * 10;
|
||||
}
|
||||
} while ( $comments_count < $total_items );
|
||||
|
||||
if ( $comments ) {
|
||||
echo '<div id="latest-comments" class="activity-block table-view-list">';
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.9-alpha-60642';
|
||||
$wp_version = '6.9-alpha-60643';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
||||
Reference in New Issue
Block a user