Make WordPress Core


Ignore:
Timestamp:
01/08/2021 03:22:17 PM (6 years ago)
Author:
johnbillion
Message:

Taxonomy: Correct and clarify documentation for the return types of term query functions.

See #51800, #38266

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-term-query.php

    r49946 r49947  
    286286
    287287        /**
    288          * Sets up the query for retrieving terms.
     288         * Sets up the query and retrieves the results.
     289         *
     290         * The return type varies depending on the value passed to `$args['fields']`. See
     291         * WP_Term_Query::get_terms() for details.
    289292         *
    290293         * @since 4.6.0
    291294         *
    292295         * @param string|array $query Array or URL query string of parameters.
    293          * @return array|int List of terms, or number of terms when 'count' is passed as a query var.
     296         * @return WP_Term[]|int[]|string[]|string Array of terms, or number of terms as numeric string
     297         *                                         when 'count' is passed as a query var.
    294298         */
    295299        public function query( $query ) {
     
    299303
    300304        /**
    301          * Get terms, based on query_vars.
     305         * Retrieves the query results.
     306         *
     307         * The return type varies depending on the value passed to `$args['fields']`.
     308         *
     309         * The following will result in an array of `WP_Term` objects being returned:
     310         *
     311         *   - 'all'
     312         *   - 'all_with_object_id'
     313         *
     314         * The following will result in a numeric string being returned:
     315         *
     316         *   - 'count'
     317         *
     318         * The following will result in an array of text strings being returned:
     319         *
     320         *   - 'id=>name'
     321         *   - 'id=>slug'
     322         *   - 'names'
     323         *   - 'slugs'
     324         *
     325         * The following will result in an array of numeric strings being returned:
     326         *
     327         *   - 'id=>parent'
     328         *
     329         * The following will result in an array of integers being returned:
     330         *
     331         *   - 'ids'
     332         *   - 'tt_ids'
     333         *
     334         * In all cases, a `WP_Error` object will be returned if an invalid taxonomy is used.
    302335         *
    303336         * @since 4.6.0
     
    305338         * @global wpdb $wpdb WordPress database abstraction object.
    306339         *
    307          * @return array List of terms.
     340         * @return WP_Term[]|int[]|string[]|string Array of terms, or number of terms as numeric string
     341         *                                         when 'count' is passed as a query var.
    308342         */
    309343        public function get_terms() {
Note: See TracChangeset for help on using the changeset viewer.