mirror of
git://develop.git.wordpress.org/
synced 2025-04-21 20:51:55 +02:00
In WP_Term_Query
, accept a string value for taxonomy
.
Props endocreative. Props ocean90 for review. Fixes #37545. git-svn-id: https://develop.svn.wordpress.org/trunk@38181 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
6efa061bd5
commit
fa21c5e675
@ -219,7 +219,7 @@ class WP_Term_Query {
|
||||
$query = $this->query_vars;
|
||||
}
|
||||
|
||||
$taxonomies = isset( $query['taxonomy'] ) ? $query['taxonomy'] : null;
|
||||
$taxonomies = isset( $query['taxonomy'] ) ? (array) $query['taxonomy'] : null;
|
||||
|
||||
/**
|
||||
* Filters the terms query default arguments.
|
||||
|
@ -4,6 +4,41 @@
|
||||
* @group taxonomy
|
||||
*/
|
||||
class Tests_Term_Query extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 37545
|
||||
*/
|
||||
public function test_taxonomy_should_accept_single_taxonomy_as_string() {
|
||||
register_taxonomy( 'wptests_tax_1', 'post' );
|
||||
register_taxonomy( 'wptests_tax_2', 'post' );
|
||||
|
||||
$term_1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax_1' ) );
|
||||
$term_2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax_2' ) );
|
||||
|
||||
$q = new WP_Term_Query( array(
|
||||
'taxonomy' => 'wptests_tax_2',
|
||||
'fields' => 'ids',
|
||||
'hide_empty' => false,
|
||||
) );
|
||||
|
||||
$this->assertEqualSets( array( $term_2 ), $q->terms );
|
||||
}
|
||||
|
||||
public function test_taxonomy_should_accept_taxonomy_array() {
|
||||
register_taxonomy( 'wptests_tax_1', 'post' );
|
||||
register_taxonomy( 'wptests_tax_2', 'post' );
|
||||
|
||||
$term_1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax_1' ) );
|
||||
$term_2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax_2' ) );
|
||||
|
||||
$q = new WP_Term_Query( array(
|
||||
'taxonomy' => array( 'wptests_tax_2' ),
|
||||
'fields' => 'ids',
|
||||
'hide_empty' => false,
|
||||
) );
|
||||
|
||||
$this->assertEqualSets( array( $term_2 ), $q->terms );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 37074
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user