diff --git a/src/wp-includes/taxonomy.php b/src/wp-includes/taxonomy.php index f161a71818..91ac0cdb24 100644 --- a/src/wp-includes/taxonomy.php +++ b/src/wp-includes/taxonomy.php @@ -408,7 +408,7 @@ function is_taxonomy_hierarchical( $taxonomy ) { * @type bool $_builtin This taxonomy is a "built-in" taxonomy. INTERNAL USE ONLY! * Default false. * } - * @return void|WP_Error Void on success, WP_Error object on failure. + * @return WP_Taxonomy|WP_Error The registered taxonomy object on success, WP_Error object on failure. */ function register_taxonomy( $taxonomy, $object_type, $args = array() ) { global $wp_taxonomies; @@ -441,6 +441,8 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) { * @param array $args Array of taxonomy registration arguments. */ do_action( 'registered_taxonomy', $taxonomy, $object_type, (array) $taxonomy_object ); + + return $taxonomy_object; } /** diff --git a/tests/phpunit/tests/post/types.php b/tests/phpunit/tests/post/types.php index 2e5313c368..9632b8d472 100644 --- a/tests/phpunit/tests/post/types.php +++ b/tests/phpunit/tests/post/types.php @@ -39,6 +39,13 @@ class Tests_Post_Types extends WP_UnitTestCase { _unregister_post_type( 'foo' ); } + /** + * @ticket 48558 + */ + function test_register_post_type_return_value() { + $this->assertInstanceOf( 'WP_Post_Type', register_post_type( 'foo' ) ); + } + /** * @ticket 31134 * diff --git a/tests/phpunit/tests/taxonomy.php b/tests/phpunit/tests/taxonomy.php index 62f098fe0a..adf61e76fc 100644 --- a/tests/phpunit/tests/taxonomy.php +++ b/tests/phpunit/tests/taxonomy.php @@ -169,6 +169,13 @@ class Tests_Taxonomy extends WP_UnitTestCase { unset( $GLOBALS['wp_taxonomies'][ $tax ] ); } + /** + * @ticket 48558 + */ + function test_register_taxonomy_return_value() { + $this->assertInstanceOf( 'WP_Taxonomy', register_taxonomy( 'foo', 'post' ) ); + } + /** * @ticket 21593 *