WordPress.org

Make WordPress Core

Ticket #13109: 13109.diff

File 13109.diff, 1.1 KB (added by scribu, 8 years ago)
  • wp-includes/taxonomy.php

     
    9898 * @uses $wp_taxonomies
    9999 *
    100100 * @param array|string|object $object Name of the type of taxonomy object, or an object (row from posts)
     101 * @param string $output The type of output to return, either taxonomy 'names' or 'objects'. 'names' is the default.
    101102 * @return array The names of all taxonomy of $object_type.
    102103 */
    103 function get_object_taxonomies($object) {
     104function get_object_taxonomies($object, $output = 'names') {
    104105        global $wp_taxonomies;
    105106
    106107        if ( is_object($object) ) {
     
    112113        $object = (array) $object;
    113114
    114115        $taxonomies = array();
    115         foreach ( (array) $wp_taxonomies as $taxonomy ) {
    116                 if ( array_intersect($object, (array) $taxonomy->object_type) )
    117                         $taxonomies[] = $taxonomy->name;
     116        foreach ( (array) $wp_taxonomies as $tax_name => $tax_obj ) {
     117                if ( array_intersect($object, (array) $tax_obj->object_type) )
     118                        $taxonomies[$tax_name] = ('names' == $output) ? $tax_name : $tax_obj;
    118119        }
    119120
    120121        return $taxonomies;