diff -r 34716fd837a4 -r be944660c56a wp/wp-admin/includes/class-wp-list-table.php --- a/wp/wp-admin/includes/class-wp-list-table.php Tue Dec 15 15:52:01 2020 +0100 +++ b/wp/wp-admin/includes/class-wp-list-table.php Wed Sep 21 18:19:35 2022 +0200 @@ -43,7 +43,7 @@ * The current screen. * * @since 3.1.0 - * @var object + * @var WP_Screen */ protected $screen; @@ -396,7 +396,7 @@ * Filters the list of available list table views. * * The dynamic portion of the hook name, `$this->screen->id`, refers - * to the ID of the current screen, usually a string. + * to the ID of the current screen. * * @since 3.1.0 * @@ -419,12 +419,29 @@ } /** - * Gets the list of bulk actions available on this table. + * Retrieves the list of bulk actions available for this table. + * + * The format is an associative array where each element represents either a top level option value and label, or + * an array representing an optgroup and its options. + * + * For a standard option, the array element key is the field value and the array element value is the field label. + * + * For an optgroup, the array element key is the label and the array element value is an associative array of + * options as above. * - * The format is an associative array: - * - `'option_name' => 'option_title'` + * Example: + * + * [ + * 'edit' => 'Edit', + * 'delete' => 'Delete', + * 'Change State' => [ + * 'feature' => 'Featured', + * 'sale' => 'On Sale', + * ] + * ] * * @since 3.1.0 + * @since 5.6.0 A bulk action can now contain an array of options in order to create an optgroup. * * @return array */ @@ -445,14 +462,15 @@ $this->_actions = $this->get_bulk_actions(); /** - * Filters the list table bulk actions drop-down. + * Filters the items in the bulk actions menu of the list table. * * The dynamic portion of the hook name, `$this->screen->id`, refers - * to the ID of the current screen, usually a string. + * to the ID of the current screen. * * @since 3.1.0 + * @since 5.6.0 A bulk action can now contain an array of options in order to create an optgroup. * - * @param string[] $actions An array of the available bulk actions. + * @param array $actions An array of the available bulk actions. */ $this->_actions = apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores @@ -469,10 +487,21 @@ echo '\n"; @@ -497,10 +526,6 @@ return $_REQUEST['action']; } - if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) { - return $_REQUEST['action2']; - } - return false; } @@ -570,25 +595,37 @@ 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'] ); - } + /** + * Filters to short-circuit performing the months dropdown query. + * + * @since 5.7.0 + * + * @param object[]|false $months 'Months' drop-down results. Default false. + * @param string $post_type The post type. + */ + $months = apply_filters( 'pre_months_dropdown_query', false, $post_type ); - $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 - ) - ); + 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. @@ -608,7 +645,7 @@ $m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0; ?> - +