Make WordPress Core


Ignore:
Timestamp:
05/29/2020 10:41:25 PM (4 years ago)
Author:
whyisjake
Message:

Taxonomy: Extend get_term_by to accept ID as a term parameter.

Similar to get_user_by, both ID and id should be able to accepted.

Fixes #45163.
Props emrikol, esoj.

File:
1 edited

Legend:

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

    r46586 r47865  
    3232        $this->assertEquals( get_term( $term1['term_id'], 'category' ), $term2 );
    3333    }
     34
     35    /**
     36     * @ticket 45163
     37     */
     38    function test_get_term_by_uppercase_id() {
     39        $term1 = wp_insert_term( 'Foo', 'category', array( 'slug' => 'foo' ) );
     40        $term2 = get_term_by( 'ID', $term1['term_id'], 'category' );
     41        $this->assertEquals( get_term( $term1['term_id'], 'category' ), $term2 );
     42    }   
    3443
    3544    /**
Note: See TracChangeset for help on using the changeset viewer.