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.
Built from https://develop.svn.wordpress.org/trunk@41022


git-svn-id: http://core.svn.wordpress.org/trunk@40872 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2017-07-10 23:05:40 +00:00
parent 5cfbf0519b
commit f75e623eae
2 changed files with 7 additions and 2 deletions

View File

@ -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();
}
?>
<div class="alignleft actions">
<?php
@ -354,7 +359,7 @@ class WP_Comments_List_Table extends WP_List_Table {
submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => '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 );

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.9-alpha-41021';
$wp_version = '4.9-alpha-41022';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.