Make WordPress Core

Ticket #36227: 36227.patch

File 36227.patch, 1.7 KB (added by sebastian.pisula, 10 years ago)
  • wp-includes/category.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    2121 *
    2222 *     @type string $taxonomy Taxonomy to retrieve terms for. In this case, default 'category'.
    2323 * }
    24  * @return array List of categories.
     24 * @return array|WP_Error List of categories.
    2525 */
    2626function get_categories( $args = '' ) {
    2727        $defaults = array( 'taxonomy' => 'category' );
    2828        $args = wp_parse_args( $args, $defaults );
    2929
    30         $taxonomy = $args['taxonomy'];
    31 
    3230        /**
    3331         * Filter the taxonomy used to retrieve terms when calling {@see get_categories()}.
    3432         *
     
    3735         * @param string $taxonomy Taxonomy to retrieve terms from.
    3836         * @param array  $args     An array of arguments. See {@see get_terms()}.
    3937         */
    40         $taxonomy = apply_filters( 'get_categories_taxonomy', $taxonomy, $args );
     38        $args['taxonomy'] = apply_filters( 'get_categories_taxonomy', $args['taxonomy'], $args );
    4139
    4240        // Back compat
    4341        if ( isset($args['type']) && 'link' == $args['type'] ) {
     
    4846                                '<code>taxonomy => link_category</code>'
    4947                        )
    5048                );
    51                 $taxonomy = $args['taxonomy'] = 'link_category';
     49
     50                $args['taxonomy'] = 'link_category';
    5251        }
    5352
    54         $categories = (array) get_terms( $taxonomy, $args );
     53        $categories = get_terms( $args );
    5554
    56         foreach ( array_keys( $categories ) as $k )
    57                 _make_cat_compat( $categories[$k] );
     55        if ( ! is_wp_error( $args['taxonomy'] ) ) {
     56                foreach ( array_keys( $categories ) as $k ) {
     57                        _make_cat_compat( $categories[ $k ] );
     58                }
     59        }
    5860
    5961        return $categories;
    6062}