WordPress.org

Make WordPress Core

Changeset 34076


Ignore:
Timestamp:
09/12/2015 08:12:43 AM (3 years ago)
Author:
wonderboymusic
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-list-table.php

    r33734 r34076  
    529529        }
    530530
     531        $extra_checks = "AND post_status != 'auto-draft'";
     532        if ( ! isset( $_GET['post_status'] ) || 'trash' !== $_GET['post_status'] ) {
     533            $extra_checks .= " AND post_status != 'trash'";
     534        } elseif ( isset( $_GET['post_status'] ) ) {
     535            $stati = explode( ',', $_GET['post_status'] );
     536            $extra_checks = '';
     537            foreach ( $stati as $status ) {
     538                $extra_checks .= $wpdb->prepare( ' AND post_status = %s', $status );
     539            }
     540        }
     541
    531542        $months = $wpdb->get_results( $wpdb->prepare( "
    532543            SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
    533544            FROM $wpdb->posts
    534545            WHERE post_type = %s
     546            $extra_checks
    535547            ORDER BY post_date DESC
    536548        ", $post_type ) );
     
    11191131        if ( 'top' == $which )
    11201132            wp_nonce_field( 'bulk-' . $this->_args['plural'] );
    1121 ?>
     1133
     1134        if ( $this->has_items() ) : ?>
    11221135    <div class="tablenav <?php echo esc_attr( $which ); ?>">
    11231136
     
    11331146    </div>
    11341147<?php
     1148        endif;
    11351149    }
    11361150
Note: See TracChangeset for help on using the changeset viewer.