Make WordPress Core


Ignore:
Timestamp:
08/03/2019 03:34:54 AM (6 years ago)
Author:
SergeyBiryukov
Message:

Taxonomy: Fix deprecated calls to get_terms().

The taxonomy should be passed as part of $args, rather than as its own argument.

Props sgastard, mukesh27, SergeyBiryukov.
Fixes #47819.

File:
1 edited

Legend:

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

    r45711 r45723  
    11321132 *                                 parameter will be interpreted as `$args`, and the first function parameter will
    11331133 *                                 be parsed as a taxonomy or array of taxonomies.
    1134  * @return array|int|WP_Error List of WP_Term instances and their children. Will return WP_Error, if any of $taxonomies
     1134 * @return array|int|WP_Error List of WP_Term instances and their children. Will return WP_Error, if any of taxonomies
    11351135 *                            do not exist.
    11361136 */
     
    16861686 */
    16871687function wp_count_terms( $taxonomy, $args = array() ) {
    1688     $defaults = array( 'hide_empty' => false );
     1688    $defaults = array(
     1689        'taxonomy'   => $taxonomy,
     1690        'hide_empty' => false,
     1691    );
    16891692    $args     = wp_parse_args( $args, $defaults );
    16901693
     
    16971700    $args['fields'] = 'count';
    16981701
    1699     return get_terms( $taxonomy, $args );
     1702    return get_terms( $args );
    17001703}
    17011704
     
    21922195     */
    21932196    $name_matches = get_terms(
    2194         $taxonomy,
    21952197        array(
     2198            'taxonomy'               => $taxonomy,
    21962199            'name'                   => $name,
    21972200            'hide_empty'             => false,
     
    22202223            if ( is_taxonomy_hierarchical( $taxonomy ) ) {
    22212224                $siblings = get_terms(
    2222                     $taxonomy,
    22232225                    array(
     2226                        'taxonomy'               => $taxonomy,
    22242227                        'get'                    => 'all',
    22252228                        'parent'                 => $parent,
     
    34713474    $children = array();
    34723475    $terms    = get_terms(
    3473         $taxonomy,
    34743476        array(
     3477            'taxonomy'               => $taxonomy,
    34753478            'get'                    => 'all',
    34763479            'orderby'                => 'id',
Note: See TracChangeset for help on using the changeset viewer.