From 4c5bb9758ad52d7aa8be3bd8664cec2179909304 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 10 Jul 2017 23:04:26 +0000 Subject: [PATCH] Comments: In `WP_Comments_List_Table::extra_tablenav()`, save the state of `::has_items()` to a static variable, so that the value is consistent between top and bottom navigation. This prevents "Empty Spam" and "Empty Trash" buttons from disappearing if there's only one page of comments in Spam/Trash. Fixes #40975. git-svn-id: https://develop.svn.wordpress.org/trunk@41022 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/class-wp-comments-list-table.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/includes/class-wp-comments-list-table.php b/src/wp-admin/includes/class-wp-comments-list-table.php index fa41a7203c..3ff2814e0a 100644 --- a/src/wp-admin/includes/class-wp-comments-list-table.php +++ b/src/wp-admin/includes/class-wp-comments-list-table.php @@ -319,6 +319,11 @@ class WP_Comments_List_Table extends WP_List_Table { */ protected function extra_tablenav( $which ) { global $comment_status, $comment_type; + static $has_items; + + if ( ! isset( $has_items ) ) { + $has_items = $this->has_items(); + } ?>
'post-query-submit' ) ); } - if ( ( 'spam' === $comment_status || 'trash' === $comment_status ) && current_user_can( 'moderate_comments' ) && $this->has_items() ) { + if ( ( 'spam' === $comment_status || 'trash' === $comment_status ) && current_user_can( 'moderate_comments' ) && $has_items ) { wp_nonce_field( 'bulk-destroy', '_destroy_nonce' ); $title = ( 'spam' === $comment_status ) ? esc_attr__( 'Empty Spam' ) : esc_attr__( 'Empty Trash' ); submit_button( $title, 'apply', 'delete_all', false );