Make WordPress Core

Ticket #34413: 34413.3.diff

File 34413.3.diff, 1.6 KB (added by SergeyBiryukov, 8 years ago)
  • src/wp-includes/taxonomy-functions.php

     
    442442        unset( $args['capabilities'] );
    443443
    444444        $args['name'] = $taxonomy;
    445         $args['object_type'] = array_unique( (array) $object_type );
    446445
     446        if ( isset( $wp_taxonomies[ $taxonomy ] ) ) {
     447                $args['object_type'] = array_merge( $wp_taxonomies[ $taxonomy ]->object_type, (array) $object_type );
     448        } else {
     449                $args['object_type'] = (array) $object_type;
     450        }
     451
     452        $args['object_type'] = array_unique( $args['object_type'] );
     453
    447454        $args['labels'] = get_taxonomy_labels( (object) $args );
    448455        $args['label'] = $args['labels']->name;
    449456
  • tests/phpunit/tests/taxonomy.php

     
    251251                $this->assertEqualSets( $expected, $tax->object_type );
    252252        }
    253253
     254        /**
     255         * @ticket 34413
     256         */
     257        public function test_register_taxonomy_subsequent_calls_should_not_overwrite_previously_registered_object_types() {
     258                register_taxonomy( 'wptests_tax', 'post' );
     259                register_taxonomy( 'wptests_tax', 'page' );
     260
     261                $tax = get_taxonomy( 'wptests_tax' );
     262
     263                $expected = array( 'post', 'page' );
     264                $this->assertEqualSets( $expected, $tax->object_type );
     265        }
     266
    254267        public function test_get_objects_in_term_should_return_invalid_taxonomy_error() {
    255268                $terms = get_objects_in_term( 1, 'invalid_taxonomy' );
    256269                $this->assertInstanceOf( 'WP_Error', $terms );