diff --git src/wp-includes/taxonomy.php src/wp-includes/taxonomy.php
index e910e33..82d16ae 100644
|
|
function get_terms( $args = array(), $deprecated = '' ) { |
1183 | 1183 | * (a) a second non-empty parameter is passed, or |
1184 | 1184 | * (b) the first parameter shares no keys with the default array (ie, it's a list of taxonomies) |
1185 | 1185 | */ |
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 ); |
1187 | 1188 | $do_legacy_args = $deprecated || empty( $key_intersect ); |
1188 | 1189 | |
1189 | 1190 | if ( $do_legacy_args ) { |
1190 | 1191 | $taxonomies = (array) $args; |
1191 | | $args = $deprecated; |
| 1192 | $args = wp_parse_args( $deprecated ); |
1192 | 1193 | $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 | } |
1195 | 1199 | } |
1196 | 1200 | |
1197 | 1201 | $empty_array = array(); |
diff --git tests/phpunit/tests/term/getTerms.php tests/phpunit/tests/term/getTerms.php
index 47e199b..891c536 100644
|
|
class Tests_Term_getTerms extends WP_UnitTestCase { |
30 | 30 | |
31 | 31 | /** |
32 | 32 | * @ticket 35495 |
| 33 | * @ticket 35381 |
| 34 | */ |
| 35 | public function test_legacy_params_as_query_string_should_be_properly_parsed() { |
| 36 | register_taxonomy( 'wptests_tax', 'post' ); |
| 37 | $term = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 38 | |
| 39 | $found = get_terms( 'wptests_tax', 'hide_empty=0&fields=ids&update_term_meta_cache=0' ); |
| 40 | |
| 41 | $this->assertEqualSets( array( $term ), $found ); |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * @ticket 35495 |
| 46 | * @ticket 35381 |
| 47 | */ |
| 48 | public function test_new_params_as_query_string_should_be_properly_parsed() { |
| 49 | register_taxonomy( 'wptests_tax', 'post' ); |
| 50 | $term = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 51 | |
| 52 | $found = get_terms( 'taxonomy=wptests_tax&hide_empty=0&fields=ids&update_term_meta_cache=0' ); |
| 53 | |
| 54 | $this->assertEqualSets( array( $term ), $found ); |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * @ticket 35495 |
33 | 59 | */ |
34 | 60 | public function test_excluding_taxonomy_arg_should_return_terms_from_all_taxonomies() { |
35 | 61 | register_taxonomy( 'wptests_tax1', 'post' ); |