mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-22 07:22:01 +01:00
Don't require a $taxonomy
to be specified in get_term_field()
.
After [34997], the `$taxonomy` parameter of `get_term()` is optional. This changeset brings `get_term_field()` in line with the new usage. Adds unit tests for `get_term_field()`. Props DrewAPicture. See #34245. Built from https://develop.svn.wordpress.org/trunk@35028 git-svn-id: http://core.svn.wordpress.org/trunk@34993 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f60bd8d827
commit
1a87ade436
@ -920,20 +920,20 @@ function get_term_children( $term_id, $taxonomy ) {
|
||||
/**
|
||||
* Get sanitized Term field.
|
||||
*
|
||||
* Does checks for $term, based on the $taxonomy. The function is for contextual
|
||||
* reasons and for simplicity of usage. See sanitize_term_field() for more
|
||||
* information.
|
||||
* The function is for contextual reasons and for simplicity of usage.
|
||||
*
|
||||
* @since 2.3.0
|
||||
* @since 4.4.0 The `$taxonomy` parameter was made optional. `$term` can also now accept a WP_Term object.
|
||||
*
|
||||
* @param string $field Term field to fetch.
|
||||
* @param int $term Term ID.
|
||||
* @param string $taxonomy Taxonomy Name.
|
||||
* @see sanitize_term_field()
|
||||
*
|
||||
* @param string $field Term field to fetch.
|
||||
* @param int|WP_Term $term Term ID or object.
|
||||
* @param string $taxonomy Optional. Taxonomy Name. Default empty.
|
||||
* @param string $context Optional, default is display. Look at sanitize_term_field() for available options.
|
||||
* @return string|int|null|WP_Error Will return an empty string if $term is not an object or if $field is not set in $term.
|
||||
*/
|
||||
function get_term_field( $field, $term, $taxonomy, $context = 'display' ) {
|
||||
$term = (int) $term;
|
||||
function get_term_field( $field, $term, $taxonomy = '', $context = 'display' ) {
|
||||
$term = get_term( $term, $taxonomy );
|
||||
if ( is_wp_error($term) )
|
||||
return $term;
|
||||
@ -944,7 +944,7 @@ function get_term_field( $field, $term, $taxonomy, $context = 'display' ) {
|
||||
if ( !isset($term->$field) )
|
||||
return '';
|
||||
|
||||
return sanitize_term_field($field, $term->$field, $term->term_id, $taxonomy, $context);
|
||||
return sanitize_term_field( $field, $term->$field, $term->term_id, $term->taxonomy, $context );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.4-alpha-35027';
|
||||
$wp_version = '4.4-alpha-35028';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user