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. Built from https://develop.svn.wordpress.org/trunk@47865 git-svn-id: http://core.svn.wordpress.org/trunk@47641 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2277a9df24
commit
7798f64340
|
@ -913,10 +913,11 @@ function get_term( $term, $taxonomy = '', $output = OBJECT, $filter = 'raw' ) {
|
|||
* @since 2.3.0
|
||||
* @since 4.4.0 `$taxonomy` is optional if `$field` is 'term_taxonomy_id'. Converted to return
|
||||
* a WP_Term object if `$output` is `OBJECT`.
|
||||
* @since 5.5.0 ID is an alias of id.
|
||||
*
|
||||
* @see sanitize_term_field() The $context param lists the available values for get_term_by() $filter param.
|
||||
*
|
||||
* @param string $field Either 'slug', 'name', 'id' (term_id), or 'term_taxonomy_id'
|
||||
* @param string $field Either 'slug', 'name', 'id' (term_id or ID), or 'term_taxonomy_id'
|
||||
* @param string|int $value Search for this term value
|
||||
* @param string $taxonomy Taxonomy name. Optional, if `$field` is 'term_taxonomy_id'.
|
||||
* @param string $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which correspond to
|
||||
|
@ -941,7 +942,7 @@ function get_term_by( $field, $value, $taxonomy = '', $output = OBJECT, $filter
|
|||
}
|
||||
}
|
||||
|
||||
if ( 'id' === $field || 'term_id' === $field ) {
|
||||
if ( 'id' === $field || 'term_id' === $field || 'ID' === $field ) {
|
||||
$term = get_term( (int) $value, $taxonomy, $output, $filter );
|
||||
if ( is_wp_error( $term ) || null === $term ) {
|
||||
$term = false;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.5-alpha-47864';
|
||||
$wp_version = '5.5-alpha-47865';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue