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

git-svn-id: http://svn.automattic.com/wordpress/trunk@13608 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2010-03-06 18:20:11 +00:00
parent 28b2f32688
commit e35acd21f7
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.
*