WordPress.org

Make WordPress Core

Ticket #9647: 9647_2.diff

File 9647_2.diff, 2.0 KB (added by arena, 9 years ago)

last changes

  • wp-includes/taxonomy.php

     
    1212//
    1313
    1414/**
    15  * Default Taxonomy Objects
    16  * @since 2.3.0
    17  * @global array $wp_taxonomies
     15 * Creates the initial taxonomies when 'init' action is fired.
    1816 */
    19 $wp_taxonomies = array();
    20 
    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 
     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) ) ;
    2721}
    28 add_action( 'init', 'create_initial_taxonomies' );
     22add_action( 'init', 'create_initial_taxonomies', 0 ); // highest priority
    2923
    3024/**
    3125 * Return all of the taxonomy names that are of $object_type.
     
    173167function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
    174168        global $wp_taxonomies, $wp_rewrite, $wp;
    175169
     170        if (!is_array($wp_taxonomies))
     171                $wp_taxonomies = array();
     172
     173        if (isset($wp_taxonomies[$taxonomy]))
     174                return;
     175
    176176        $defaults = array('hierarchical' => false, 'update_count_callback' => '', 'rewrite' => true, 'query_var' => true);
    177177        $args = wp_parse_args($args, $defaults);
    178178