WordPress.org

Make WordPress Core

Changeset 14479


Ignore:
Timestamp:
05/06/2010 06:07:50 PM (10 years ago)
Author:
nacin
Message:

Allow get_object_taxonomies to return taxonomy objects. props scribu, fixes #13109.

File:
1 edited

Legend:

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

    r14432 r14479  
    102102 *
    103103 * @param array|string|object $object Name of the type of taxonomy object, or an object (row from posts)
     104 * @param string $output The type of output to return, either taxonomy 'names' or 'objects'. 'names' is the default.
    104105 * @return array The names of all taxonomy of $object_type.
    105106 */
    106 function get_object_taxonomies($object) {
     107function get_object_taxonomies($object, $output = 'names') {
    107108    global $wp_taxonomies;
    108109
     
    116117
    117118    $taxonomies = array();
    118     foreach ( (array) $wp_taxonomies as $taxonomy ) {
    119         if ( array_intersect($object, (array) $taxonomy->object_type) )
    120             $taxonomies[] = $taxonomy->name;
     119    foreach ( (array) $wp_taxonomies as $tax_name => $tax_obj ) {
     120        if ( array_intersect($object, (array) $tax_obj->object_type) )
     121            $taxonomies[$tax_name] = ('names' == $output) ? $tax_name : $tax_obj;
    121122    }
    122123
Note: See TracChangeset for help on using the changeset viewer.