WordPress.org

Make WordPress Core

Ticket #19148: taxonomy.php.patch

File taxonomy.php.patch, 1.4 KB (added by MZAWeb, 2 years ago)
  • wp-includes/taxonomy.php

     
    354354        unset( $args['capabilities'] ); 
    355355 
    356356        $args['name'] = $taxonomy; 
    357         $args['object_type'] =  array_unique( (array)$object_type ); 
     357        $args['object_type'] =  array(); 
    358358 
    359359        $args['labels'] = get_taxonomy_labels( (object) $args ); 
    360360        $args['label'] = $args['labels']->name; 
    361361 
    362362        $wp_taxonomies[$taxonomy] = (object) $args; 
    363363 
     364        foreach (array_unique( (array)$object_type ) as $type){ 
     365        register_taxonomy_for_object_type($taxonomy, $type); 
     366    } 
     367 
    364368        // register callback handling for metabox 
    365369        add_filter('wp_ajax_add-' . $taxonomy, '_wp_ajax_add_hierarchical_term'); 
    366370 
     
    432436 * @return bool True if successful, false if not 
    433437 */ 
    434438function register_taxonomy_for_object_type( $taxonomy, $object_type) { 
    435         global $wp_taxonomies; 
     439        global $wp_taxonomies, $wp_post_types; 
    436440 
    437441        if ( !isset($wp_taxonomies[$taxonomy]) ) 
    438442                return false; 
     
    440444        if ( ! get_post_type_object($object_type) ) 
    441445                return false; 
    442446 
    443         if ( ! in_array( $object_type, $wp_taxonomies[$taxonomy]->object_type ) ) 
     447        if ( ! in_array( $object_type, $wp_taxonomies[$taxonomy]->object_type ) ){ 
    444448                $wp_taxonomies[$taxonomy]->object_type[] = $object_type; 
     449        $wp_post_types[$object_type]->taxonomies[] = $taxonomy; 
     450    } 
    445451 
    446452        return true; 
    447453}