Make WordPress Core


Ignore:
Timestamp:
05/31/2016 12:53:27 PM (8 years ago)
Author:
boonebgorges
Message:

Ensure that get_terms() can accept querystring-style arguments.

Prior to [37572], arguments passed to get_terms() were passed immediately
through wp_parse_args(), which made it possible to pass arguments as a
querystring (hide_empty=0) rather than an array
(array( 'hide_empty' => false )). [37572] moved default argument parsing
into WP_Term_Query, while assuming that arguments passed to get_terms()
would be formatted as an array.

To provide compatibility, we now parse all args passed to get_terms() into
an array before processing.

See #35381.

File:
1 edited

Legend:

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

    r37593 r37599  
    11841184     * (b) the first parameter shares no keys with the default array (ie, it's a list of taxonomies)
    11851185     */
    1186     $key_intersect  = array_intersect_key( $term_query->query_var_defaults, (array) $args );
     1186    $_args = wp_parse_args( $args );
     1187    $key_intersect  = array_intersect_key( $term_query->query_var_defaults, (array) $_args );
    11871188    $do_legacy_args = $deprecated || empty( $key_intersect );
    11881189
    11891190    if ( $do_legacy_args ) {
    11901191        $taxonomies = (array) $args;
    1191         $args = $deprecated;
     1192        $args = wp_parse_args( $deprecated );
    11921193        $args['taxonomy'] = $taxonomies;
    1193     } elseif ( isset( $args['taxonomy'] ) && null !== $args['taxonomy'] ) {
    1194         $args['taxonomy'] = (array) $args['taxonomy'];
     1194    } else {
     1195        $args = wp_parse_args( $args );
     1196        if ( isset( $args['taxonomy'] ) && null !== $args['taxonomy'] ) {
     1197            $args['taxonomy'] = (array) $args['taxonomy'];
     1198        }
    11951199    }
    11961200
Note: See TracChangeset for help on using the changeset viewer.