List Tables: Hide 'Empty Trash' and 'Empty Spam' buttons when view is already empty.

Props ivantedja, Presskopp, printsachen1, Jaydeep Rami, mathieuhays, cazm.
Fixes #38341.
Built from https://develop.svn.wordpress.org/trunk@40297


git-svn-id: http://core.svn.wordpress.org/trunk@40204 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Pascal Birchler
2017-03-17 16:54:42 +00:00
parent 62061bab56
commit 3e189479a7
6 changed files with 12 additions and 5 deletions

View File

@@ -354,7 +354,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' ) ) {
if ( ( 'spam' === $comment_status || 'trash' === $comment_status ) && current_user_can( 'moderate_comments' ) && $this->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 );