In WP_Media_List_Table
, fetch all pending comment counts at once, instead of for each row in the loop.
See #11381. git-svn-id: https://develop.svn.wordpress.org/trunk@34127 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
0c38f660e1
commit
ea610e66d4
@ -8,6 +8,14 @@
|
||||
* @access private
|
||||
*/
|
||||
class WP_Media_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Store the pending comment count for each post
|
||||
*
|
||||
* @access public
|
||||
* @since 4.4.0
|
||||
* @var array
|
||||
*/
|
||||
public $pending_count = array();
|
||||
|
||||
private $detached;
|
||||
|
||||
@ -481,7 +489,12 @@ class WP_Media_List_Table extends WP_List_Table {
|
||||
public function column_comments( $post ) {
|
||||
echo '<div class="post-com-count-wrapper">';
|
||||
|
||||
$pending_comments = get_pending_comments_num( $post->ID );
|
||||
if ( isset( $this->pending_count[ $post->ID ] ) ) {
|
||||
$pending_comments = $this->pending_count[ $post->ID ];
|
||||
} else {
|
||||
$pending_comments = get_pending_comments_num( $post->ID );
|
||||
}
|
||||
|
||||
$this->comments_bubble( $post->ID, $pending_comments );
|
||||
|
||||
echo '</div>';
|
||||
@ -548,7 +561,12 @@ class WP_Media_List_Table extends WP_List_Table {
|
||||
* @global WP_Post $post
|
||||
*/
|
||||
public function display_rows() {
|
||||
global $post;
|
||||
global $post, $wp_query;
|
||||
|
||||
$post_ids = wp_list_pluck( $wp_query->posts, 'ID' );
|
||||
reset( $wp_query->posts );
|
||||
|
||||
$this->pending_count = get_pending_comments_num( $post_ids );
|
||||
|
||||
add_filter( 'the_title','esc_html' );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user