Make WordPress Core

Changeset 47186


Ignore:
Timestamp:
02/05/2020 06:24:16 AM (4 years ago)
Author:
SergeyBiryukov
Message:

Taxonomy: In register_taxonomy(), return the registered taxonomy object on success, for consistency with register_post_type().

Props krynes, SergeyBiryukov.
Fixes #48558.

Location:
trunk
Files:
3 edited

Legend:

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

    r47122 r47186  
    409409 *                                                Default false.
    410410 * }
    411  * @return void|WP_Error Void on success, WP_Error object on failure.
     411 * @return WP_Taxonomy|WP_Error The registered taxonomy object on success, WP_Error object on failure.
    412412 */
    413413function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
     
    442442     */
    443443    do_action( 'registered_taxonomy', $taxonomy, $object_type, (array) $taxonomy_object );
     444
     445    return $taxonomy_object;
    444446}
    445447
  • trunk/tests/phpunit/tests/post/types.php

    r47122 r47186  
    3838
    3939        _unregister_post_type( 'foo' );
     40    }
     41
     42    /**
     43     * @ticket 48558
     44     */
     45    function test_register_post_type_return_value() {
     46        $this->assertInstanceOf( 'WP_Post_Type', register_post_type( 'foo' ) );
    4047    }
    4148
  • trunk/tests/phpunit/tests/taxonomy.php

    r47122 r47186  
    171171
    172172    /**
     173     * @ticket 48558
     174     */
     175    function test_register_taxonomy_return_value() {
     176        $this->assertInstanceOf( 'WP_Taxonomy', register_taxonomy( 'foo', 'post' ) );
     177    }
     178
     179    /**
    173180     * @ticket 21593
    174181     *
Note: See TracChangeset for help on using the changeset viewer.