From abce542e5ff2eaa50fe2372759bfa946c36cd028 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Fri, 30 Jan 2015 19:18:23 +0000 Subject: [PATCH] Introduce 'show_in_quick_edit' parameter for `register_taxonomy()`. Setting 'show_in_quick_edit' to false when registering a custom taxonomy will hide the taxonomy when editing posts using Quick Edit. The new 'quick_edit_show_taxonomy' filter allows this behavior to be filtered on a finer scale, as when you want a given taxonomy to be hidden for one post type but not for others. Props hlashbrooke. Fixes #26948. Built from https://develop.svn.wordpress.org/trunk@31307 git-svn-id: http://core.svn.wordpress.org/trunk@31288 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../includes/class-wp-posts-list-table.php | 18 +++++++++++++++++- wp-includes/taxonomy.php | 9 +++++++++ wp-includes/version.php | 2 +- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/wp-admin/includes/class-wp-posts-list-table.php b/wp-admin/includes/class-wp-posts-list-table.php index 194448660a..65c751bf06 100644 --- a/wp-admin/includes/class-wp-posts-list-table.php +++ b/wp-admin/includes/class-wp-posts-list-table.php @@ -944,10 +944,26 @@ class WP_Posts_List_Table extends WP_List_Table { $hierarchical_taxonomies = array(); $flat_taxonomies = array(); foreach ( $taxonomy_names as $taxonomy_name ) { + + /** + * Filters whether the current taxonomy should be shown in the Quick Edit panel. + * + * @since 4.2.0 + * + * @param bool $show Whether to show the current taxonomy in Quick Edit. + * Default: true. + * @param string $taxonomy_name Taxonomy name. + * @param string $post_type Post type of current Quick Edit post. + */ + if ( ! apply_filters( 'quick_edit_show_taxonomy', true, $taxonomy_name, $screen->post_type ) ) { + continue; + } + $taxonomy = get_taxonomy( $taxonomy_name ); - if ( !$taxonomy->show_ui ) + if ( ! $taxonomy->show_in_quick_edit ) { continue; + } if ( $taxonomy->hierarchical ) $hierarchical_taxonomies[] = $taxonomy; diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index ccaae9041b..ec398b44aa 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -282,6 +282,8 @@ function is_taxonomy_hierarchical($taxonomy) { * * If not set, the default is inherited from public. * - show_tagcloud - Whether to list the taxonomy in the Tag Cloud Widget. * * If not set, the default is inherited from show_ui. + * - show_in_quick_edit - Whether to show the taxonomy in the quick/bulk edit panel. + * * It not set, the default is inherited from show_ui. * - show_admin_column - Whether to display a column for the taxonomy on its post type listing screens. * * Defaults to false. * - meta_box_cb - Provide a callback function for the meta box display. @@ -308,6 +310,7 @@ function is_taxonomy_hierarchical($taxonomy) { * - _builtin - true if this taxonomy is a native or "built-in" taxonomy. THIS IS FOR INTERNAL USE ONLY! * * @since 2.3.0 + * @since 4.2.0 Introduced 'show_in_quick_edit' parameter. * @uses $wp_taxonomies Inserts new taxonomy object into the list * @uses $wp Adds query vars * @@ -331,6 +334,7 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) { 'show_in_menu' => null, 'show_in_nav_menus' => null, 'show_tagcloud' => null, + 'show_in_quick_edit' => null, 'show_admin_column' => false, 'meta_box_cb' => null, 'capabilities' => array(), @@ -389,6 +393,11 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) { if ( null === $args['show_tagcloud'] ) $args['show_tagcloud'] = $args['show_ui']; + // If not set, default to the setting for show_ui. + if ( null === $args['show_in_quick_edit'] ) { + $args['show_in_quick_edit'] = $args['show_ui']; + } + $default_caps = array( 'manage_terms' => 'manage_categories', 'edit_terms' => 'manage_categories', diff --git a/wp-includes/version.php b/wp-includes/version.php index 270dfe5f23..0892b531af 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.2-alpha-31306'; +$wp_version = '4.2-alpha-31307'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.