Docs: Document that get_tags() returns a WP_Error object if any of the specified taxonomies do not exist.

Props coffee2code.
Fixes #50344.
Built from https://develop.svn.wordpress.org/trunk@47930


git-svn-id: http://core.svn.wordpress.org/trunk@47703 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-06-09 11:14:12 +00:00
parent 784908ae5f
commit 40584118d9
3 changed files with 25 additions and 21 deletions

View File

@ -280,10 +280,14 @@ function sanitize_category_field( $field, $value, $cat_id, $context ) {
* Retrieves all post tags.
*
* @since 2.3.0
* @see get_terms() For list of arguments to pass.
*
* @param string|array $args Tag arguments to use when retrieving tags.
* @return WP_Term[]|int $tags Array of 'post_tag' term objects, or a count thereof.
* @param string|array $args {
* Optional. Arguments to retrieve tags. See get_terms() for additional options.
*
* @type string $taxonomy Taxonomy to retrieve terms for. Default 'post_tag'.
* }
* @return WP_Term[]|int|WP_Error $tags Array of 'post_tag' term objects, a count thereof,
* or WP_Error if any of the taxonomies do not exist.
*/
function get_tags( $args = '' ) {
$defaults = array( 'taxonomy' => 'post_tag' );
@ -292,20 +296,20 @@ function get_tags( $args = '' ) {
$tags = get_terms( $args );
if ( empty( $tags ) ) {
$return = array();
return $return;
$tags = array();
} else {
/**
* Filters the array of term objects returned for the 'post_tag' taxonomy.
*
* @since 2.3.0
*
* @param WP_Term[]|int|WP_Error $tags Array of 'post_tag' term objects, a count thereof,
* or WP_Error if any of the taxonomies do not exist.
* @param array $args An array of arguments. @see get_terms()
*/
$tags = apply_filters( 'get_tags', $tags, $args );
}
/**
* Filters the array of term objects returned for the 'post_tag' taxonomy.
*
* @since 2.3.0
*
* @param WP_Term[]|int $tags Array of 'post_tag' term objects, or a count thereof.
* @param array $args An array of arguments. @see get_terms()
*/
$tags = apply_filters( 'get_tags', $tags, $args );
return $tags;
}

View File

@ -1133,11 +1133,11 @@ function get_term_to_edit( $id, $taxonomy ) {
*
* @param array|string $args Optional. Array or string of arguments. See WP_Term_Query::__construct()
* for information on accepted arguments. Default empty.
* @param array|string $deprecated Argument array, when using the legacy function parameter format. If present, this
* parameter will be interpreted as `$args`, and the first function parameter will
* be parsed as a taxonomy or array of taxonomies.
* @return WP_Term[]|int|WP_Error List of WP_Term instances and their children. Will return WP_Error, if any of taxonomies
* do not exist.
* @param array|string $deprecated Argument array, when using the legacy function parameter format. If present,
* this parameter will be interpreted as `$args`, and the first function parameter
* will be parsed as a taxonomy or array of taxonomies.
* @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.
*/
function get_terms( $args = array(), $deprecated = '' ) {
$term_query = new WP_Term_Query();

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.5-alpha-47929';
$wp_version = '5.5-alpha-47930';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.