Make WordPress Core

Ticket #12516: get_taxonomies.2.diff

File get_taxonomies.2.diff, 1.3 KB (added by scribu, 15 years ago)

return associative array

  • wp-includes/taxonomy.php

     
    5656add_action( 'init', 'create_initial_taxonomies', 0 ); // highest priority
    5757
    5858/**
     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}
     85
     86/**
    5987 * Return all of the taxonomy names that are of $object_type.
    6088 *
    6189 * It appears that this function can be used to find all of the names inside of