From e35acd21f71de14650990d3d1303f07af3f995f2 Mon Sep 17 00:00:00 2001 From: ryan Date: Sat, 6 Mar 2010 18:20:11 +0000 Subject: [PATCH] get_taxonomies(). Props ptahdunbar, scribu. fixes #12516 git-svn-id: http://svn.automattic.com/wordpress/trunk@13608 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/taxonomy.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 7fbe61967..14f408022 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -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. *