Taxonomy: in get_terms()
, do not assume that legacy args are being passed when the only params are top-level meta_*
values. Add keys in WP_Term_Query::__construct()
.
Adds unit tests. Props flixos90, boonebgorges. Fixes #37568. git-svn-id: https://develop.svn.wordpress.org/trunk@38337 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
148b09a79e
commit
5e1193272f
@ -208,6 +208,10 @@ class WP_Term_Query {
|
||||
'cache_domain' => 'core',
|
||||
'update_term_meta_cache' => true,
|
||||
'meta_query' => '',
|
||||
'meta_key' => '',
|
||||
'meta_value' => '',
|
||||
'meta_type' => '',
|
||||
'meta_compare' => '',
|
||||
);
|
||||
|
||||
if ( ! empty( $query ) ) {
|
||||
|
@ -11,6 +11,29 @@ class Tests_Term_getTerms extends WP_UnitTestCase {
|
||||
wp_cache_delete( 'last_changed', 'terms' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 37568
|
||||
*/
|
||||
public function test_meta_query_args_only() {
|
||||
register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) );
|
||||
|
||||
$term1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
|
||||
$term2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
|
||||
|
||||
$post = self::factory()->post->create( array( 'post_type' => 'post' ) );
|
||||
|
||||
update_term_meta( $term1, 'somekey', 'thevalue' );
|
||||
|
||||
wp_set_post_terms( $post, array( $term1, $term2 ), 'wptests_tax' );
|
||||
|
||||
$found = get_terms( array(
|
||||
'meta_key' => 'somekey',
|
||||
'meta_value' => 'thevalue',
|
||||
) );
|
||||
|
||||
$this->assertEqualSets( array( $term1 ), wp_list_pluck( $found, 'term_id' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 35495
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user