Introduce show_in_menu for register_taxonomy.

Accepts boolean: true to show, false to hide. If not set, the default is inherited from show_ui.

fixes #20930.
Built from https://develop.svn.wordpress.org/trunk@25133


git-svn-id: http://core.svn.wordpress.org/trunk@25113 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2013-08-26 22:35:10 +00:00
parent a87a1bceff
commit 8688857816
3 changed files with 17 additions and 4 deletions

View File

@ -53,7 +53,7 @@ $menu[5] = array( __('Posts'), 'edit_posts', 'edit.php', '', 'open-if-no-js menu
$i = 15;
foreach ( get_taxonomies( array(), 'objects' ) as $tax ) {
if ( ! $tax->show_ui || ! in_array('post', (array) $tax->object_type, true) )
if ( ! $tax->show_ui || ! $tax->show_in_menu || ! in_array('post', (array) $tax->object_type, true) )
continue;
$submenu['edit.php'][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name );
@ -65,7 +65,7 @@ $menu[10] = array( __('Media'), 'upload_files', 'upload.php', '', 'menu-top menu
/* translators: add new file */
$submenu['upload.php'][10] = array( _x('Add New', 'file'), 'upload_files', 'media-new.php');
foreach ( get_taxonomies_for_attachments( 'objects' ) as $tax ) {
if ( ! $tax->show_ui )
if ( ! $tax->show_ui || ! $tax->show_in_menu )
continue;
$submenu['upload.php'][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name . '&post_type=attachment' );
@ -84,7 +84,7 @@ $menu[20] = array( __('Pages'), 'edit_pages', 'edit.php?post_type=page', '', 'me
$submenu['edit.php?post_type=page'][10] = array( _x('Add New', 'page'), get_post_type_object( 'page' )->cap->create_posts, 'post-new.php?post_type=page' );
$i = 15;
foreach ( get_taxonomies( array(), 'objects' ) as $tax ) {
if ( ! $tax->show_ui || ! in_array('page', (array) $tax->object_type, true) )
if ( ! $tax->show_ui || ! $tax->show_in_menu || ! in_array('page', (array) $tax->object_type, true) )
continue;
$submenu['edit.php?post_type=page'][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name . '&post_type=page' );
@ -126,7 +126,7 @@ foreach ( (array) get_post_types( array('show_ui' => true, '_builtin' => false,
$i = 15;
foreach ( get_taxonomies( array(), 'objects' ) as $tax ) {
if ( ! $tax->show_ui || ! in_array($ptype, (array) $tax->object_type, true) )
if ( ! $tax->show_ui || ! $tax->show_in_menu || ! in_array($ptype, (array) $tax->object_type, true) )
continue;
$submenu["edit.php?post_type=$ptype"][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, "edit-tags.php?taxonomy=$tax->name&post_type=$ptype" );

View File

@ -547,6 +547,9 @@ class wp_xmlrpc_server extends IXR_Server {
if ( in_array( 'cap', $fields ) )
$_taxonomy['cap'] = (array) $taxonomy->cap;
if ( in_array( 'menu', $fields ) )
$_taxonomy['show_in_menu'] = (bool) $_taxonomy->show_in_menu;
if ( in_array( 'object_type', $fields ) )
$_taxonomy['object_type'] = array_unique( (array) $taxonomy->object_type );

View File

@ -280,6 +280,11 @@ function is_taxonomy_hierarchical($taxonomy) {
* - hierarchical - Whether the taxonomy is hierarchical (e.g. category). Defaults to false.
* - show_ui -Whether to generate a default UI for managing this taxonomy in the admin.
* * If not set, the default is inherited from public.
* - show_in_menu - Where to show the taxonomy in the admin menu.
* * If true, the taxonomy is shown as a submenu of the object type menu.
* * If false, no menu is shown.
* * show_ui must be true.
* * If not set, the default is inherited from show_ui.
* - show_in_nav_menus - Makes this taxonomy available for selection in navigation menus.
* * If not set, the default is inherited from public.
* - show_tagcloud - Whether to list the taxonomy in the Tag Cloud Widget.
@ -324,6 +329,7 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
'public' => true,
'hierarchical' => false,
'show_ui' => null,
'show_in_menu' => null,
'show_in_nav_menus' => null,
'show_tagcloud' => null,
'capabilities' => array(),
@ -366,6 +372,10 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
if ( null === $args['show_ui'] )
$args['show_ui'] = $args['public'];
// If not set, default to the setting for show_ui.
if ( null === $args['show_in_menu' ] || ! $args['show_ui'] )
$args['show_in_menu' ] = $args['show_ui'];
// If not set, default to the setting for public.
if ( null === $args['show_in_nav_menus'] )
$args['show_in_nav_menus'] = $args['public'];