diff --git a/wp-admin/includes/class-wp-list-table.php b/wp-admin/includes/class-wp-list-table.php index e2b306e38f..cdd07f076d 100644 --- a/wp-admin/includes/class-wp-list-table.php +++ b/wp-admin/includes/class-wp-list-table.php @@ -595,35 +595,47 @@ 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'] ) ) { - $extra_checks = $wpdb->prepare( ' AND post_status = %s', $_GET['post_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 - ) - ); - /** - * Filters the 'Months' drop-down results. + * Filters to short-circuit performing the months dropdown query. * - * @since 3.7.0 + * @since 5.7.0 * - * @param object[] $months Array of the months drop-down query results. - * @param string $post_type The post type. + * @param object[]|false $months 'Months' drop-down results. Default false. + * @param string $post_type The post type. */ - $months = apply_filters( 'months_dropdown_results', $months, $post_type ); + $months = apply_filters( 'pre_months_dropdown_query', false, $post_type ); + + if ( ! is_array( $months ) ) { + $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'] ) ) { + $extra_checks = $wpdb->prepare( ' AND post_status = %s', $_GET['post_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 + ) + ); + + /** + * Filters the 'Months' drop-down results. + * + * @since 3.7.0 + * + * @param object[] $months Array of the months drop-down query results. + * @param string $post_type The post type. + */ + $months = apply_filters( 'months_dropdown_results', $months, $post_type ); + } $month_count = count( $months ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 32e7159762..1f3938e90d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.7-alpha-50162'; +$wp_version = '5.7-alpha-50163'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.