From 1a87ade43689f58e3ac61ed8e500a272c1174691 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Mon, 12 Oct 2015 04:14:24 +0000 Subject: [PATCH] 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 --- wp-includes/taxonomy-functions.php | 18 +++++++++--------- wp-includes/version.php | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/wp-includes/taxonomy-functions.php b/wp-includes/taxonomy-functions.php index 02e0499e84..d61e726d37 100644 --- a/wp-includes/taxonomy-functions.php +++ b/wp-includes/taxonomy-functions.php @@ -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 ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 6dcce14b67..2332e227e2 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.