diff --git a/src/js/_enqueues/admin/common.js b/src/js/_enqueues/admin/common.js index 2a7daba0d2dc4..8e2b399b925ee 100644 --- a/src/js/_enqueues/admin/common.js +++ b/src/js/_enqueues/admin/common.js @@ -506,6 +506,97 @@ window.columns = { $( function() { columns.init(); } ); +/** + * Manages taxonomy filter dropdown visibility preferences in Screen Options. + * + * @since 7.0.0 + * + * Binds change events to the taxonomy filter checkboxes to show or hide + * the corresponding filter dropdowns instantly, and persists the preference + * via AJAX. Hidden dropdowns have their name, $visible, true ), true, false ) . ' />'; + echo esc_html( $taxonomy->labels->name ) . "\n"; + } + ?> + + months_dropdown( $this->screen->post_type ); @@ -595,19 +842,55 @@ protected function extra_tablenav( $which ) { $output = ob_get_clean(); if ( ! empty( $output ) ) { + ?> +
+ 'post-query-submit' ) ); + ?> +
+ taxonomies_dropdown( $this->screen->post_type ); + $taxonomy_output = ob_get_clean(); + + if ( ! empty( $taxonomy_output ) ) { + $visible_taxonomies = get_visible_taxonomy_filters( $this->screen ); + $row_class = empty( $visible_taxonomies ) + ? 'alignleft actions taxonomy-filters-row hidden' + : 'alignleft actions taxonomy-filters-row'; + ?> +
+ 'post-query-submit-taxonomy' ) ); + ?> +
+ is_trash && $this->has_items() && current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) ) { + ?> +
+ +
+ - - id . 'taxonomyfilters' ); + + if ( ! is_array( $visible ) ) { + $visible = array(); + } + + /** + * Filters the list of taxonomy slugs with visible filter dropdowns on the post list table. + * + * @since 7.0.0 + * + * @param string[] $visible Array of taxonomy slugs whose filter dropdowns are shown. + * @param WP_Screen $screen WP_Screen object of the current screen. + */ + return apply_filters( 'visible_taxonomy_filters', $visible, $screen ); +} + /** * Prints the meta box preferences for screen meta. *