From 5a1c8da1699a6a199eb3c707e1ec9eaa86c21f35 Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 29 Apr 2009 16:40:36 +0000 Subject: [PATCH] Allow taxonomy registration before init. Props arena. fixes #9647 git-svn-id: http://svn.automattic.com/wordpress/trunk@11122 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/taxonomy.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 2e2396b97..7e86b3003 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -12,20 +12,14 @@ // /** - * Default Taxonomy Objects - * @since 2.3.0 - * @global array $wp_taxonomies + * Creates the initial taxonomies when 'init' action is fired. */ -$wp_taxonomies = array(); - function create_initial_taxonomies() { - global $wp_taxonomies; - $wp_taxonomies['category'] = (object) array('name' => 'category', 'object_type' => 'post', 'hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'label' => __('Categories')); - $wp_taxonomies['post_tag'] = (object) array('name' => 'post_tag', 'object_type' => 'post', 'hierarchical' => false, 'update_count_callback' => '_update_post_term_count', 'label' => __('Post Tags')); - $wp_taxonomies['link_category'] = (object) array('name' => 'link_category', 'object_type' => 'link', 'hierarchical' => false); - + register_taxonomy( 'category', 'post', array('hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'label' => __('Categories')) ) ; + register_taxonomy( 'post_tag', 'post', array('hierarchical' => false, 'update_count_callback' => '_update_post_term_count', 'label' => __('Post Tags')) ) ; + register_taxonomy( 'link_category', 'link', array('hierarchical' => false) ) ; } -add_action( 'init', 'create_initial_taxonomies' ); +add_action( 'init', 'create_initial_taxonomies', 0 ); // highest priority /** * Return all of the taxonomy names that are of $object_type. @@ -173,6 +167,12 @@ function is_taxonomy_hierarchical($taxonomy) { function register_taxonomy( $taxonomy, $object_type, $args = array() ) { global $wp_taxonomies, $wp_rewrite, $wp; + if (!is_array($wp_taxonomies)) + $wp_taxonomies = array(); + + if (isset($wp_taxonomies[$taxonomy])) + return; + $defaults = array('hierarchical' => false, 'update_count_callback' => '', 'rewrite' => true, 'query_var' => true); $args = wp_parse_args($args, $defaults);