Make WordPress Core

Changeset 11122


Ignore:
Timestamp:
04/29/2009 04:40:36 PM (16 years ago)
Author:
ryan
Message:

Allow taxonomy registration before init. Props arena. fixes #9647

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/taxonomy.php

    r11115 r11122  
    1313
    1414/**
    15  * Default Taxonomy Objects
    16  * @since 2.3.0
    17  * @global array $wp_taxonomies
    18  */
    19 $wp_taxonomies = array();
    20 
     15 * Creates the initial taxonomies when 'init' action is fired.
     16 */
    2117function create_initial_taxonomies() {
    22     global $wp_taxonomies;
    23     $wp_taxonomies['category'] = (object) array('name' => 'category', 'object_type' => 'post', 'hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'label' => __('Categories'));
    24     $wp_taxonomies['post_tag'] = (object) array('name' => 'post_tag', 'object_type' => 'post', 'hierarchical' => false, 'update_count_callback' => '_update_post_term_count', 'label' => __('Post Tags'));
    25     $wp_taxonomies['link_category'] = (object) array('name' => 'link_category', 'object_type' => 'link', 'hierarchical' => false);
    26 
    27 }
    28 add_action( 'init', 'create_initial_taxonomies' );
     18    register_taxonomy( 'category', 'post', array('hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'label' => __('Categories')) ) ;
     19    register_taxonomy( 'post_tag', 'post', array('hierarchical' => false, 'update_count_callback' => '_update_post_term_count', 'label' => __('Post Tags')) ) ;
     20    register_taxonomy( 'link_category', 'link', array('hierarchical' => false) ) ;
     21}
     22add_action( 'init', 'create_initial_taxonomies', 0 ); // highest priority
    2923
    3024/**
     
    173167function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
    174168    global $wp_taxonomies, $wp_rewrite, $wp;
     169
     170    if (!is_array($wp_taxonomies))
     171        $wp_taxonomies = array();
     172
     173    if (isset($wp_taxonomies[$taxonomy]))
     174        return;
    175175
    176176    $defaults = array('hierarchical' => false, 'update_count_callback' => '', 'rewrite' => true, 'query_var' => true);
Note: See TracChangeset for help on using the changeset viewer.