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
This commit is contained in:
Boone Gorges 2015-01-30 19:18:23 +00:00
parent 9b0ee1c6f5
commit abce542e5f
3 changed files with 27 additions and 2 deletions

View File

@ -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;

View File

@ -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',

View File

@ -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.