From 39620db24d38265b7a135922fe22672775e37d67 Mon Sep 17 00:00:00 2001 From: dd32 Date: Fri, 19 Feb 2010 10:21:29 +0000 Subject: [PATCH] First pass at giving taxonomies a show_ui param. See #10773 git-svn-id: http://svn.automattic.com/wordpress/trunk@13216 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/menu.php | 4 ++-- wp-includes/taxonomy.php | 27 +++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/wp-admin/menu.php b/wp-admin/menu.php index 1ca45dcca0..e9b5fa5b85 100644 --- a/wp-admin/menu.php +++ b/wp-admin/menu.php @@ -57,7 +57,7 @@ $menu[5] = array( __('Posts'), 'edit_posts', 'edit.php', '', 'open-if-no-js menu $i = 15; foreach ( $wp_taxonomies as $tax ) { - if ( ! in_array('post', (array) $tax->object_type, true) ) + if ( ! $tax->show_ui || ! in_array('post', (array) $tax->object_type, true) ) continue; $submenu['edit.php'][$i++] = array( esc_attr($tax->label), 'manage_categories', 'edit-tags.php?taxonomy=' . $tax->name ); @@ -94,7 +94,7 @@ foreach ( (array) get_post_types( array('show_ui' => true) ) as $ptype ) { $i = 15; foreach ( $wp_taxonomies as $tax ) { - if ( ! in_array($ptype, (array) $tax->object_type, true) ) + if ( ! $tax->show_ui || ! in_array($ptype, (array) $tax->object_type, true) ) continue; $submenu["edit.php?post_type=$ptype"][$i++] = array( esc_attr($tax->label), 'manage_categories', "edit-tags.php?taxonomy=$tax->name&post_type=$ptype" ); diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index f6dc05922f..65117eb5fa 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -20,7 +20,10 @@ function create_initial_taxonomies() { 'label' => __('Categories'), 'singular_label' => __('Category'), 'query_var' => false, - 'rewrite' => false + 'rewrite' => false, + 'public' => true, + 'show_ui' => true, + '_builtin' => true ) ) ; register_taxonomy( 'post_tag', 'post', array( @@ -29,13 +32,19 @@ function create_initial_taxonomies() { 'label' => __('Post Tags'), 'singular_label' => __('Post Tag'), 'query_var' => false, - 'rewrite' => false + 'rewrite' => false, + 'public' => true, + 'show_ui' => true, + '_builtin' => true ) ) ; register_taxonomy( 'link_category', 'link', array( 'hierarchical' => false, 'label' => __('Categories'), 'query_var' => false, - 'rewrite' => false + 'rewrite' => false, + 'public' => false, + 'show_ui' => false, + '_builtin' => true, ) ) ; } add_action( 'init', 'create_initial_taxonomies', 0 ); // highest priority @@ -189,7 +198,14 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) { if ( ! is_array($wp_taxonomies) ) $wp_taxonomies = array(); - $defaults = array('hierarchical' => false, 'update_count_callback' => '', 'rewrite' => true, 'query_var' => true); + $defaults = array( 'hierarchical' => false, + 'update_count_callback' => '', + 'rewrite' => true, + 'query_var' => $taxonomy, + 'public' => true, + 'show_ui' => null, + '_builtin' => false + ); $args = wp_parse_args($args, $defaults); if ( false !== $args['query_var'] && !empty($wp) ) { @@ -210,6 +226,9 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) { $wp_rewrite->add_permastruct($taxonomy, "/{$args['rewrite']['slug']}/%$taxonomy%", $args['rewrite']['with_front']); } + if ( is_null($args['show_ui']) ) + $args['show_ui'] = $args['public']; + foreach ( array('manage_cap', 'edit_cap', 'delete_cap') as $cap ) { if ( empty($args[$cap]) ) $args[$cap] = 'manage_categories';