get_taxonomies(). Props ptahdunbar, scribu. fixes #12516

git-svn-id: https://develop.svn.wordpress.org/trunk@13608 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2010-03-06 18:20:11 +00:00
parent 97d62bb8ce
commit 2cd7529b55
1 changed files with 28 additions and 0 deletions

View File

@ -55,6 +55,34 @@ function create_initial_taxonomies() {
}
add_action( 'init', 'create_initial_taxonomies', 0 ); // highest priority
/**
* Get a list of registered taxonomy objects.
*
* @package WordPress
* @subpackage Taxonomy
* @since 3.0.0
* @uses $wp_taxonomies
* @see register_taxonomy
*
* @param array $args An array of key => value arguments to match against the taxonomies.
* Only taxonomies having attributes that match all arguments are returned.
* @param string $output The type of output to return, either taxonomy 'names' or 'objects'. 'names' is the default.
* @return array A list of taxonomy names or objects
*/
function get_taxonomies( $args = array(), $output = 'names' ) {
global $wp_taxonomies;
$taxonomies = array();
foreach ( (array) $wp_taxonomies as $taxname => $taxobj )
if ( empty($args) || array_intersect_assoc((array) $taxobj, $args) )
$taxonomies[$taxname] = $taxobj;
if ( 'names' == $output )
return array_keys($taxonomies);
return $taxonomies;
}
/**
* Return all of the taxonomy names that are of $object_type.
*