if ( !
is_array( $wp_taxonomies ) ) { $wp_taxonomies = array
();
} $args =
wp_parse_args( $args );
if ( empty( $taxonomy ) ||
strlen( $taxonomy ) > 32
) { _doing_it_wrong( __FUNCTION__,
__( 'Taxonomy names must be between 1 and 32 characters in length.'
), '4.2.0'
);
return new WP_Error( 'taxonomy_length_invalid',
__( 'Taxonomy names must be between 1 and 32 characters in length.'
) );
} $taxonomy_object =
new WP_Taxonomy( $taxonomy,
$object_type,
$args );
$taxonomy_object->
add_rewrite_rules();
$wp_taxonomies[ $taxonomy ] =
$taxonomy_object;
$taxonomy_object->
add_hooks();
// Add default term.
if ( !
empty( $taxonomy_object->default_term
) ) { $term =
term_exists( $taxonomy_object->default_term
['name'
],
$taxonomy );
if ( $term ) { update_option( 'default_term_' .
$taxonomy_object->name,
$term['term_id'
] );
}