Make WordPress Core


Ignore:
Timestamp:
01/02/2015 09:33:33 PM (10 years ago)
Author:
boonebgorges
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/term/getTerms.php

    r30688 r31024  
    423423
    424424        $this->assertEquals( array( $t1, $t3 ), $found );
     425    }
     426
     427    /**
     428     * @ticket 30611
     429     */
     430    public function test_get_terms_by_name() {
     431        $t1 = $this->factory->tag->create( array( 'name' => 'Foo' ) );
     432        $t2 = $this->factory->tag->create( array( 'name' => 'Bar' ) );
     433
     434        $found = get_terms( 'post_tag', array(
     435            'hide_empty' => false,
     436            'fields' => 'ids',
     437            'name' => 'Foo',
     438        ) );
     439
     440        $this->assertEquals( array( $t1 ), $found );
     441    }
     442
     443    /**
     444     * @ticket 30611
     445     */
     446    public function test_get_terms_by_multiple_names() {
     447        $t1 = $this->factory->tag->create( array( 'name' => 'Foo' ) );
     448        $t2 = $this->factory->tag->create( array( 'name' => 'Bar' ) );
     449        $t3 = $this->factory->tag->create( array( 'name' => 'Barry' ) );
     450
     451        $found = get_terms( 'post_tag', array(
     452            'hide_empty' => false,
     453            'fields' => 'ids',
     454            'name' => array( 'Foo', 'Barry' )
     455        ) );
     456
     457        $this->assertEqualSets( array( $t3, $t1 ), $found );
    425458    }
    426459
Note: See TracChangeset for help on using the changeset viewer.