Docs: Document that get_tags()
returns a WP_Error
object if any of the specified taxonomies do not exist.
Props coffee2code. Fixes #50344. git-svn-id: https://develop.svn.wordpress.org/trunk@47930 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
ba994f6c09
commit
eb1c55a7ac
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user