Introduce 'name' parameter for get_terms().

This enhancement requires a modification in the way that `wp_dropdown_categories()`
prepares its arguments for `get_terms()`, so that its unrelated 'name' param is
not mistaken for the new 'name' argument in `get_terms()`.

Props danielbachhuber.
Fixes #30611.

git-svn-id: https://develop.svn.wordpress.org/trunk@31024 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges
2015-01-02 21:33:33 +00:00
parent 95fd7b1590
commit 4cead42b26
3 changed files with 52 additions and 2 deletions
+33
View File
@@ -424,6 +424,39 @@ class Tests_Term_getTerms extends WP_UnitTestCase {
$this->assertEquals( array( $t1, $t3 ), $found );
}
/**
* @ticket 30611
*/
public function test_get_terms_by_name() {
$t1 = $this->factory->tag->create( array( 'name' => 'Foo' ) );
$t2 = $this->factory->tag->create( array( 'name' => 'Bar' ) );
$found = get_terms( 'post_tag', array(
'hide_empty' => false,
'fields' => 'ids',
'name' => 'Foo',
) );
$this->assertEquals( array( $t1 ), $found );
}
/**
* @ticket 30611
*/
public function test_get_terms_by_multiple_names() {
$t1 = $this->factory->tag->create( array( 'name' => 'Foo' ) );
$t2 = $this->factory->tag->create( array( 'name' => 'Bar' ) );
$t3 = $this->factory->tag->create( array( 'name' => 'Barry' ) );
$found = get_terms( 'post_tag', array(
'hide_empty' => false,
'fields' => 'ids',
'name' => array( 'Foo', 'Barry' )
) );
$this->assertEqualSets( array( $t3, $t1 ), $found );
}
public function test_get_terms_hierarchical_tax_hide_empty_false_fields_ids() {
// Set up a clean taxonomy.
$tax = 'hierarchical_fields';