WordPress.org

Make WordPress Core

Changeset 13608


Ignore:
Timestamp:
03/06/2010 06:20:11 PM (10 years ago)
Author:
ryan
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/taxonomy.php

    r13597 r13608  
    5555}
    5656add_action( 'init', 'create_initial_taxonomies', 0 ); // highest priority
     57
     58/**
     59 * Get a list of registered taxonomy objects.
     60 *
     61 * @package WordPress
     62 * @subpackage Taxonomy
     63 * @since 3.0.0
     64 * @uses $wp_taxonomies
     65 * @see register_taxonomy
     66 *
     67 * @param array $args An array of key => value arguments to match against the taxonomies.
     68 *  Only taxonomies having attributes that match all arguments are returned.
     69 * @param string $output The type of output to return, either taxonomy 'names' or 'objects'. 'names' is the default.
     70 * @return array A list of taxonomy names or objects
     71 */
     72function get_taxonomies( $args = array(), $output = 'names' ) {
     73    global $wp_taxonomies;
     74
     75    $taxonomies = array();
     76    foreach ( (array) $wp_taxonomies as $taxname => $taxobj )
     77        if ( empty($args) || array_intersect_assoc((array) $taxobj, $args) )
     78            $taxonomies[$taxname] = $taxobj;
     79
     80    if ( 'names' == $output )
     81        return array_keys($taxonomies);
     82
     83    return $taxonomies;
     84}
    5785
    5886/**
Note: See TracChangeset for help on using the changeset viewer.