diff --git a/src/wp-includes/taxonomy.php b/src/wp-includes/taxonomy.php index be19a14148..5b70968185 100644 --- a/src/wp-includes/taxonomy.php +++ b/src/wp-includes/taxonomy.php @@ -564,6 +564,8 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) { * @return true|WP_Error True on success, WP_Error on failure or if the taxonomy doesn't exist. */ function unregister_taxonomy( $taxonomy ) { + global $wp_taxonomies; + if ( ! taxonomy_exists( $taxonomy ) ) { return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) ); } @@ -575,8 +577,6 @@ function unregister_taxonomy( $taxonomy ) { return new WP_Error( 'invalid_taxonomy', __( 'Unregistering a built-in taxonomy is not allowed.' ) ); } - global $wp_taxonomies; - $taxonomy_object->remove_rewrite_rules(); $taxonomy_object->remove_hooks();