Make WordPress Core

Changeset 45723


Ignore:
Timestamp:
08/03/2019 03:34:54 AM (7 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.

Location:
trunk/src
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/ajax-actions.php

    r45654 r45723  
    152152
    153153        $results = get_terms(
    154                 $taxonomy,
    155154                array(
     155                        'taxonomy'   => $taxonomy,
    156156                        'name__like' => $s,
    157157                        'fields'     => 'names',
     
    10861086
    10871087        $tags = get_terms(
    1088                 $taxonomy,
    10891088                array(
    1090                         'number'  => 45,
    1091                         'orderby' => 'count',
    1092                         'order'   => 'DESC',
     1089                        'taxonomy' => $taxonomy,
     1090                        'number'   => 45,
     1091                        'orderby'  => 'count',
     1092                        'order'    => 'DESC',
    10931093                )
    10941094        );
  • trunk/src/wp-admin/includes/class-wp-terms-list-table.php

    r45583 r45723  
    215215                        $this->callback_args,
    216216                        array(
     217                                'taxonomy'   => $taxonomy,
    217218                                'page'       => 1,
    218219                                'number'     => 20,
     
    238239                        $args['offset'] = $args['number'];
    239240                }
    240                 $terms = get_terms( $taxonomy, $args );
     241
     242                $terms = get_terms( $args );
    241243
    242244                if ( empty( $terms ) || ! is_array( $terms ) ) {
  • trunk/src/wp-admin/includes/export.php

    r45603 r45723  
    160160
    161161                $custom_taxonomies = get_taxonomies( array( '_builtin' => false ) );
    162                 $custom_terms      = (array) get_terms( $custom_taxonomies, array( 'get' => 'all' ) );
     162                $custom_terms      = (array) get_terms(
     163                        array(
     164                                'taxonomy' => $custom_taxonomies,
     165                                'get'      => 'all',
     166                        )
     167                );
    163168
    164169                // Put categories in order with no child going before its parent.
  • trunk/src/wp-admin/includes/nav-menu.php

    r45583 r45723  
    664664
    665665        $args = array(
     666                'taxonomy'     => $taxonomy_name,
    666667                'child_of'     => 0,
    667668                'exclude'      => '',
     
    676677        );
    677678
    678         $terms = get_terms( $taxonomy_name, $args );
     679        $terms = get_terms( $args );
    679680
    680681        if ( ! $terms || is_wp_error( $terms ) ) {
     
    775776                                <?php
    776777                                $popular_terms  = get_terms(
    777                                         $taxonomy_name,
    778778                                        array(
     779                                                'taxonomy'     => $taxonomy_name,
    779780                                                'orderby'      => 'count',
    780781                                                'order'        => 'DESC',
     
    813814                                $searched       = esc_attr( $_REQUEST[ 'quick-search-taxonomy-' . $taxonomy_name ] );
    814815                                $search_results = get_terms(
    815                                         $taxonomy_name,
    816816                                        array(
     817                                                'taxonomy'     => $taxonomy_name,
    817818                                                'name__like'   => $searched,
    818819                                                'fields'       => 'all',
  • trunk/src/wp-admin/includes/post.php

    r45583 r45723  
    20422042
    20432043                $_term = get_terms(
    2044                         $taxonomy,
    20452044                        array(
     2045                                'taxonomy'   => $taxonomy,
    20462046                                'name'       => $term,
    20472047                                'fields'     => 'ids',
  • trunk/src/wp-admin/includes/template.php

    r45667 r45723  
    126126                $args['selected_cats'] = array();
    127127        }
     128
    128129        if ( is_array( $parsed_args['popular_cats'] ) ) {
    129130                $args['popular_cats'] = $parsed_args['popular_cats'];
    130131        } else {
    131132                $args['popular_cats'] = get_terms(
    132                         $taxonomy,
    133133                        array(
     134                                'taxonomy'     => $taxonomy,
    134135                                'fields'       => 'ids',
    135136                                'orderby'      => 'count',
     
    140141                );
    141142        }
     143
    142144        if ( $descendants_and_self ) {
    143145                $categories = (array) get_terms(
    144                         $taxonomy,
    145146                        array(
     147                                'taxonomy'     => $taxonomy,
    146148                                'child_of'     => $descendants_and_self,
    147149                                'hierarchical' => 0,
     
    152154                array_unshift( $categories, $self );
    153155        } else {
    154                 $categories = (array) get_terms( $taxonomy, array( 'get' => 'all' ) );
     156                $categories = (array) get_terms(
     157                        array(
     158                                'taxonomy' => $taxonomy,
     159                                'get'      => 'all',
     160                        )
     161                );
    155162        }
    156163
     
    208215
    209216        $terms = get_terms(
    210                 $taxonomy,
    211217                array(
     218                        'taxonomy'     => $taxonomy,
    212219                        'orderby'      => 'count',
    213220                        'order'        => 'DESC',
     
    267274
    268275        $categories = get_terms(
    269                 'link_category',
    270276                array(
     277                        'taxonomy'   => 'link_category',
    271278                        'orderby'    => 'name',
    272279                        'hide_empty' => 0,
  • trunk/src/wp-includes/bookmark-template.php

    r45667 r45723  
    238238        if ( $parsed_args['categorize'] ) {
    239239                $cats = get_terms(
    240                         'link_category',
    241240                        array(
     241                                'taxonomy'     => 'link_category',
    242242                                'name__like'   => $parsed_args['category_name'],
    243243                                'include'      => $parsed_args['category'],
  • trunk/src/wp-includes/category-template.php

    r45668 r45723  
    385385        $get_terms_args = $parsed_args;
    386386        unset( $get_terms_args['name'] );
    387         $categories = get_terms( $parsed_args['taxonomy'], $get_terms_args );
     387        $categories = get_terms( $get_terms_args );
    388388
    389389        $name     = esc_attr( $parsed_args['name'] );
     
    702702
    703703        $tags = get_terms(
    704                 $args['taxonomy'],
    705704                array_merge(
    706705                        $args,
  • trunk/src/wp-includes/category.php

    r45590 r45723  
    2727        $defaults = array( 'taxonomy' => 'category' );
    2828        $args     = wp_parse_args( $args, $defaults );
    29 
    30         $taxonomy = $args['taxonomy'];
    3129
    3230        /**
     
    3836         * @param array  $args     An array of arguments. 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
     
    5250                        )
    5351                );
    54                 $taxonomy         = 'link_category';
    55                 $args['taxonomy'] = $taxonomy;
    56         }
    57 
    58         $categories = get_terms( $taxonomy, $args );
     52                $args['taxonomy'] = 'link_category';
     53        }
     54
     55        $categories = get_terms( $args );
    5956
    6057        if ( is_wp_error( $categories ) ) {
     
    137134        }
    138135        $categories = get_terms(
    139                 'category',
    140136                array(
    141                         'get'  => 'all',
    142                         'slug' => $leaf_path,
     137                        'taxonomy' => 'category',
     138                        'get'      => 'all',
     139                        'slug'     => $leaf_path,
    143140                )
    144141        );
     
    280277 */
    281278function get_tags( $args = '' ) {
    282         $tags = get_terms( 'post_tag', $args );
     279        $defaults = array( 'taxonomy' => 'post_tag' );
     280        $args     = wp_parse_args( $args, $defaults );
     281
     282        $tags = get_terms( $args );
    283283
    284284        if ( empty( $tags ) ) {
  • trunk/src/wp-includes/class-walker-category.php

    r44957 r45723  
    201201                                // 'current_category' can be an array, so we use `get_terms()`.
    202202                                $_current_terms = get_terms(
    203                                         $category->taxonomy,
    204203                                        array(
     204                                                'taxonomy'   => $category->taxonomy,
    205205                                                'include'    => $args['current_category'],
    206206                                                'hide_empty' => false,
  • trunk/src/wp-includes/class-wp-customize-nav-menus.php

    r45442 r45723  
    211211                } elseif ( 'taxonomy' === $type ) {
    212212                        $terms = get_terms(
    213                                 $object,
    214213                                array(
     214                                        'taxonomy'     => $object,
    215215                                        'child_of'     => 0,
    216216                                        'exclude'      => '',
     
    366366                $taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'names' );
    367367                $terms      = get_terms(
    368                         $taxonomies,
    369368                        array(
     369                                'taxonomies' => $taxonomies,
    370370                                'name__like' => $args['s'],
    371371                                'number'     => 20,
  • trunk/src/wp-includes/class-wp-term-query.php

    r45590 r45723  
    429429                                        $excluded_children,
    430430                                        (array) get_terms(
    431                                                 reset( $taxonomies ),
    432431                                                array(
     432                                                        'taxonomy'   => reset( $taxonomies ),
    433433                                                        'child_of'   => intval( $extrunk ),
    434434                                                        'fields'     => 'ids',
  • trunk/src/wp-includes/class-wp-xmlrpc-server.php

    r45599 r45723  
    15581558                                        if ( is_taxonomy_hierarchical( $taxonomy ) ) {
    15591559                                                $tax_term_names = get_terms(
    1560                                                         $taxonomy,
    15611560                                                        array(
     1561                                                                'taxonomy'   => $taxonomy,
    15621562                                                                'fields'     => 'names',
    15631563                                                                'hide_empty' => false,
     
    23912391                }
    23922392
    2393                 $query = array();
     2393                $query = array( 'taxonomy' => $taxonomy->name );
    23942394
    23952395                if ( isset( $filter['number'] ) ) {
     
    24192419                }
    24202420
    2421                 $terms = get_terms( $taxonomy->name, $query );
     2421                $terms = get_terms( $query );
    24222422
    24232423                if ( is_wp_error( $terms ) ) {
  • trunk/src/wp-includes/deprecated.php

    r45674 r45723  
    12881288
    12891289        if ( ! $cat_ids = wp_cache_get( 'all_category_ids', 'category' ) ) {
    1290                 $cat_ids = get_terms( 'category', array('fields' => 'ids', 'get' => 'all') );
     1290                $cat_ids = get_terms(
     1291                        array(
     1292                                'taxonomy' => 'category',
     1293                                'fields'   => 'ids',
     1294                                'get'      => 'all',
     1295                        )
     1296                );
    12911297                wp_cache_add( 'all_category_ids', $cat_ids, 'category' );
    12921298        }
  • trunk/src/wp-includes/nav-menu.php

    r45656 r45723  
    598598function wp_get_nav_menus( $args = array() ) {
    599599        $defaults = array(
     600                'taxonomy'   => 'nav_menu',
    600601                'hide_empty' => false,
    601602                'orderby'    => 'name',
     
    613614         * @param array $args  An array of arguments used to retrieve menu objects.
    614615         */
    615         return apply_filters( 'wp_get_nav_menus', get_terms( 'nav_menu', $args ), $args );
     616        return apply_filters( 'wp_get_nav_menus', get_terms( $args ), $args );
    616617}
    617618
     
    728729                        foreach ( array_keys( $terms ) as $taxonomy ) {
    729730                                get_terms(
    730                                         $taxonomy,
    731731                                        array(
     732                                                'taxonomy'     => $taxonomy,
    732733                                                'include'      => $terms[ $taxonomy ],
    733734                                                'hierarchical' => false,
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php

    r45590 r45723  
    185185                );
    186186
    187                 $prepared_args = array();
     187                $prepared_args = array( 'taxonomy' => $this->taxonomy );
    188188
    189189                /*
     
    250250                        $prepared_args['object_ids'] = $prepared_args['post'];
    251251                } else {
    252                         $query_result = get_terms( $this->taxonomy, $prepared_args );
     252                        $query_result = get_terms( $prepared_args );
    253253                }
    254254
  • 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',
  • trunk/src/wp-includes/widgets/class-wp-widget-links.php

    r45590 r45723  
    138138                        )
    139139                );
    140                 $link_cats = get_terms( 'link_category' );
     140                $link_cats = get_terms( array( 'taxonomy' => 'link_category' ) );
    141141                $limit     = intval( $instance['limit'] );
    142142                if ( ! $limit ) {
Note: See TracChangeset for help on using the changeset viewer.