mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-09 18:08:09 +01:00
Administration: New filter ahead of the months drop-down.
As this can cause large, long running queries on sites with many posts, this filter allows the query to be modified, bypassing entirely if needed. Fixes #51660. Props geoffguillain, SergeyBiryukov, hareesh-pillai, hellofromTonya, TimothyBlynJacobs, whyisjake. Built from https://develop.svn.wordpress.org/trunk@50163 git-svn-id: http://core.svn.wordpress.org/trunk@49842 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
56c9aa3cab
commit
8e8fe6d2c0
@ -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 );
|
||||
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user