Add `term_taxonomy_id` to available fields in `get_term_by()`. Adds unit test.
Props jchristopher. Fixes #21651. Built from https://develop.svn.wordpress.org/trunk@25334 git-svn-id: http://core.svn.wordpress.org/trunk@25296 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
02757de9d8
commit
7c2e7f8995
|
@ -954,7 +954,7 @@ function get_term($term, $taxonomy, $output = OBJECT, $filter = 'raw') {
|
|||
* @uses sanitize_term() Cleanses the term based on $filter context before returning.
|
||||
* @see sanitize_term_field() The $context param lists the available values for get_term_by() $filter param.
|
||||
*
|
||||
* @param string $field Either 'slug', 'name', or 'id'
|
||||
* @param string $field Either 'slug', 'name', 'id' (term_id), or 'term_taxonomy_id'
|
||||
* @param string|int $value Search for this term value
|
||||
* @param string $taxonomy Taxonomy Name
|
||||
* @param string $output Constant OBJECT, ARRAY_A, or ARRAY_N
|
||||
|
@ -976,6 +976,9 @@ function get_term_by($field, $value, $taxonomy, $output = OBJECT, $filter = 'raw
|
|||
// Assume already escaped
|
||||
$value = wp_unslash($value);
|
||||
$field = 't.name';
|
||||
} else if ( 'term_taxonomy_id' == $field ) {
|
||||
$value = (int) $value;
|
||||
$field = 'tt.term_taxonomy_id';
|
||||
} else {
|
||||
$term = get_term( (int) $value, $taxonomy, $output, $filter);
|
||||
if ( is_wp_error( $term ) )
|
||||
|
|
Loading…
Reference in New Issue