List Tables: don't render "extra tablenav" if there are no posts. This includes Bulk Actions, Dates Dropdown, Category Dropdowns, Pagination.

Also ensure that the Months dropdown, when it is shown, shows months from the proper set of posts.

Props egower, CoenJacobs, MikeHansenMe, mehulkaklotar.
Fixes #33824, #21015, #21856.

Built from https://develop.svn.wordpress.org/trunk@34076


git-svn-id: http://core.svn.wordpress.org/trunk@34044 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2015-09-12 08:13:24 +00:00
parent 41c5bfb493
commit eb230b5424
2 changed files with 16 additions and 2 deletions

View File

@ -528,10 +528,22 @@ class WP_List_Table {
return;
}
$extra_checks = "AND post_status != 'auto-draft'";
if ( ! isset( $_GET['post_status'] ) || 'trash' !== $_GET['post_status'] ) {
$extra_checks .= " AND post_status != 'trash'";
} elseif ( isset( $_GET['post_status'] ) ) {
$stati = explode( ',', $_GET['post_status'] );
$extra_checks = '';
foreach ( $stati as $status ) {
$extra_checks .= $wpdb->prepare( ' AND post_status = %s', $status );
}
}
$months = $wpdb->get_results( $wpdb->prepare( "
SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
FROM $wpdb->posts
WHERE post_type = %s
$extra_checks
ORDER BY post_date DESC
", $post_type ) );
@ -1118,7 +1130,8 @@ class WP_List_Table {
protected function display_tablenav( $which ) {
if ( 'top' == $which )
wp_nonce_field( 'bulk-' . $this->_args['plural'] );
?>
if ( $this->has_items() ) : ?>
<div class="tablenav <?php echo esc_attr( $which ); ?>">
<div class="alignleft actions bulkactions">
@ -1132,6 +1145,7 @@ class WP_List_Table {
<br class="clear" />
</div>
<?php
endif;
}
/**

View File

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