Make WordPress Core


Ignore:
Timestamp:
06/09/2020 11:12:57 AM (5 years ago)
Author:
SergeyBiryukov
Message:

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

Props coffee2code.
Fixes #50344.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/category.php

    r47864 r47930  
    281281 *
    282282 * @since 2.3.0
    283  * @see get_terms() For list of arguments to pass.
    284  *
    285  * @param string|array $args Tag arguments to use when retrieving tags.
    286  * @return WP_Term[]|int $tags Array of 'post_tag' term objects, or a count thereof.
     283 *
     284 * @param string|array $args {
     285 *     Optional. Arguments to retrieve tags. See get_terms() for additional options.
     286 *
     287 *     @type string $taxonomy Taxonomy to retrieve terms for. Default 'post_tag'.
     288 * }
     289 * @return WP_Term[]|int|WP_Error $tags Array of 'post_tag' term objects, a count thereof,
     290 *                                      or WP_Error if any of the taxonomies do not exist.
    287291 */
    288292function get_tags( $args = '' ) {
     
    293297
    294298    if ( empty( $tags ) ) {
    295         $return = array();
    296         return $return;
    297     }
    298 
    299     /**
    300      * Filters the array of term objects returned for the 'post_tag' taxonomy.
    301     *
    302      * @since 2.3.0
    303      *
    304      * @param WP_Term[]|int $tags Array of 'post_tag' term objects, or a count thereof.
    305      * @param array         $args An array of arguments. @see get_terms()
    306      */
    307     $tags = apply_filters( 'get_tags', $tags, $args );
     299        $tags = array();
     300    } else {
     301        /**
     302         * Filters the array of term objects returned for the 'post_tag' taxonomy.
     303         *
     304         * @since 2.3.0
     305        *
     306         * @param WP_Term[]|int|WP_Error $tags Array of 'post_tag' term objects, a count thereof,
     307         *                                     or WP_Error if any of the taxonomies do not exist.
     308         * @param array                  $args An array of arguments. @see get_terms()
     309         */
     310        $tags = apply_filters( 'get_tags', $tags, $args );
     311    }
    308312
    309313    return $tags;
Note: See TracChangeset for help on using the changeset viewer.