Posts list table: Add a filter to disable the months dropdown.

It was previously possible to prevent it from displaying by filtering everything out from the results, but if one really doesn't want it, they should be able to short-circuit before the query even runs.

props norcross, SergeyBiryukov.
fixes #30254.


git-svn-id: https://develop.svn.wordpress.org/trunk@31438 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Helen Hou-Sandi 2015-02-12 18:37:06 +00:00
parent afef491a75
commit 8e1df9dab2
1 changed files with 12 additions and 0 deletions

View File

@ -509,6 +509,18 @@ class WP_List_Table {
protected function months_dropdown( $post_type ) {
global $wpdb, $wp_locale;
/**
* Filter whether to remove the 'Months' drop-down from the post list table.
*
* @since 4.2.0
*
* @param bool $disable Whether to disable the drop-down. Default false.
* @param string $post_type The post type.
*/
if ( apply_filters( 'disable_months_dropdown', false, $post_type ) ) {
return;
}
$months = $wpdb->get_results( $wpdb->prepare( "
SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
FROM $wpdb->posts