diff --git a/wp-includes/class-wp-term-query.php b/wp-includes/class-wp-term-query.php index b507a0f874..0f679535c3 100644 --- a/wp-includes/class-wp-term-query.php +++ b/wp-includes/class-wp-term-query.php @@ -285,12 +285,16 @@ class WP_Term_Query { } /** - * Sets up the query for retrieving terms. + * Sets up the query and retrieves the results. + * + * The return type varies depending on the value passed to `$args['fields']`. See + * WP_Term_Query::get_terms() for details. * * @since 4.6.0 * * @param string|array $query Array or URL query string of parameters. - * @return array|int List of terms, or number of terms when 'count' is passed as a query var. + * @return WP_Term[]|int[]|string[]|string Array of terms, or number of terms as numeric string + * when 'count' is passed as a query var. */ public function query( $query ) { $this->query_vars = wp_parse_args( $query ); @@ -298,13 +302,43 @@ class WP_Term_Query { } /** - * Get terms, based on query_vars. + * Retrieves the query results. + * + * The return type varies depending on the value passed to `$args['fields']`. + * + * The following will result in an array of `WP_Term` objects being returned: + * + * - 'all' + * - 'all_with_object_id' + * + * The following will result in a numeric string being returned: + * + * - 'count' + * + * The following will result in an array of text strings being returned: + * + * - 'id=>name' + * - 'id=>slug' + * - 'names' + * - 'slugs' + * + * The following will result in an array of numeric strings being returned: + * + * - 'id=>parent' + * + * The following will result in an array of integers being returned: + * + * - 'ids' + * - 'tt_ids' + * + * In all cases, a `WP_Error` object will be returned if an invalid taxonomy is used. * * @since 4.6.0 * * @global wpdb $wpdb WordPress database abstraction object. * - * @return array List of terms. + * @return WP_Term[]|int[]|string[]|string Array of terms, or number of terms as numeric string + * when 'count' is passed as a query var. */ public function get_terms() { global $wpdb; diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 70f5d3bca8..5055b612c6 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -1131,11 +1131,15 @@ function get_term_to_edit( $id, $taxonomy ) { } /** - * Retrieve the terms in a given taxonomy or list of taxonomies. + * Retrieves the terms in a given taxonomy or list of taxonomies. * * You can fully inject any customizations to the query before it is sent, as * well as control the output with a filter. * + * The return type varies depending on the value passed to `$args['fields']`. See + * WP_Term_Query::get_terms() for details. In all cases, a `WP_Error` object will + * be returned if an invalid taxonomy is requested. + * * The {@see 'get_terms'} filter will be called when the cache has the term and will * pass the found term along with the array of $taxonomies and array of $args. * This filter is also called before the array of terms is passed and will pass @@ -1177,8 +1181,9 @@ function get_term_to_edit( $id, $taxonomy ) { * If present, this parameter will be interpreted as `$args`, and the first * function parameter will be parsed as a taxonomy or array of taxonomies. * Default empty. - * @return WP_Term[]|int|WP_Error Array of WP_Term instances, a count thereof, - * or WP_Error if any of the taxonomies do not exist. + * @return WP_Term[]|int[]|string[]|string|WP_Error Array of terms, a count thereof as a numeric string, + * or WP_Error if any of the taxonomies do not exist. + * See the function description for more information. */ function get_terms( $args = array(), $deprecated = '' ) { $term_query = new WP_Term_Query(); @@ -1745,7 +1750,8 @@ function sanitize_term_field( $field, $value, $term_id, $taxonomy, $context ) { * If present, this parameter will be interpreted as `$args`, and the first * function parameter will be parsed as a taxonomy or array of taxonomies. * Default empty. - * @return array|int|WP_Error Number of terms in that taxonomy or WP_Error if the taxonomy does not exist. + * @return string|WP_Error Numeric string containing the number of terms in that + * taxonomy or WP_Error if the taxonomy does not exist. */ function wp_count_terms( $args = array(), $deprecated = '' ) { $use_legacy_args = false; diff --git a/wp-includes/version.php b/wp-includes/version.php index 596f243860..1888a2aaa4 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.7-alpha-49946'; +$wp_version = '5.7-alpha-49947'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.