Make WordPress Core

Changeset 56767


Ignore:
Timestamp:
10/03/2023 04:13:43 PM (22 months ago)
Author:
SergeyBiryukov
Message:

Docs: Improve documentation for get_avatar() and related functions.

Includes:

  • Expanding and synchronizing documentation for the default and rating arguments.
  • Adding @since entries for the loading, fetchpriority, and decoding arguments.
  • Wrapping long lines as per the documentation standards.
  • Fixing a typo in the identicon value.
  • Minor formatting edits for consistency.

Follow-up to [31107], [45632], [47554], [53480], [56037].

See #58833.

Location:
trunk/src/wp-includes
Files:
3 edited

Legend:

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

    r56740 r56767  
    42514251}
    42524252
    4253 
    42544253/**
    42554254 * Retrieves the avatar URL.
     
    42574256 * @since 4.2.0
    42584257 *
    4259  * @param mixed $id_or_email The Gravatar to retrieve a URL for. Accepts a user_id, gravatar md5 hash,
     4258 * @param mixed $id_or_email The avatar to retrieve a URL for. Accepts a user ID, Gravatar MD5 hash,
    42604259 *                           user email, WP_User object, WP_Post object, or WP_Comment object.
    42614260 * @param array $args {
     
    42634262 *
    42644263 *     @type int    $size           Height and width of the avatar in pixels. Default 96.
    4265  *     @type string $default        URL for the default image or a default type. Accepts '404' (return
    4266  *                                  a 404 instead of a default image), 'retro' (8bit), 'RoboHash' (robohash),
    4267  *                                  'monsterid' (monster), 'wavatar' (cartoon face), 'indenticon' (the "quilt"),
    4268  *                                  'mystery', 'mm', or 'mysteryman' (The Oyster Man), 'blank' (transparent GIF),
    4269  *                                  or 'gravatar_default' (the Gravatar logo). Default is the value of the
    4270  *                                  'avatar_default' option, with a fallback of 'mystery'.
    4271  *     @type bool   $force_default  Whether to always show the default image, never the Gravatar. Default false.
    4272  *     @type string $rating         What rating to display avatars up to. Accepts 'G', 'PG', 'R', 'X', and are
    4273  *                                  judged in that order. Default is the value of the 'avatar_rating' option.
     4264 *     @type string $default        URL for the default image or a default type. Accepts:
     4265 *                                  - '404' (return a 404 instead of a default image)
     4266 *                                  - 'retro' (a 8-bit arcade-style pixelated face)
     4267 *                                  - 'robohash' (a robot)
     4268 *                                  - 'monsterid' (a monster)
     4269 *                                  - 'wavatar' (a cartoon face)
     4270 *                                  - 'identicon' (the "quilt", a geometric pattern)
     4271 *                                  - 'mystery', 'mm', or 'mysteryman' (The Oyster Man)
     4272 *                                  - 'blank' (transparent GIF)
     4273 *                                  - 'gravatar_default' (the Gravatar logo)
     4274 *                                  Default is the value of the 'avatar_default' option,
     4275 *                                  with a fallback of 'mystery'.
     4276 *     @type bool   $force_default  Whether to always show the default image, never the Gravatar.
     4277 *                                  Default false.
     4278 *     @type string $rating         What rating to display avatars up to. Accepts:
     4279 *                                  - 'G' (suitable for all audiences)
     4280 *                                  - 'PG' (possibly offensive, usually for audiences 13 and above)
     4281 *                                  - 'R' (intended for adult audiences above 17)
     4282 *                                  - 'X' (even more mature than above)
     4283 *                                  Default is the value of the 'avatar_rating' option.
    42744284 *     @type string $scheme         URL scheme to use. See set_url_scheme() for accepted values.
    42754285 *                                  Default null.
     
    42844294}
    42854295
    4286 
    42874296/**
    42884297 * Check if this comment type allows avatars to be retrieved.
     
    43054314    return in_array( $comment_type, (array) $allowed_comment_types, true );
    43064315}
    4307 
    43084316
    43094317/**
     
    43174325 *     Optional. Arguments to use instead of the default arguments.
    43184326 *
    4319  *     @type int    $size           Height and width of the avatar image file in pixels. Default 96.
     4327 *     @type int    $size           Height and width of the avatar in pixels. Default 96.
    43204328 *     @type int    $height         Display height of the avatar in pixels. Defaults to $size.
    43214329 *     @type int    $width          Display width of the avatar in pixels. Defaults to $size.
    4322  *     @type string $default        URL for the default image or a default type. Accepts '404' (return
    4323  *                                  a 404 instead of a default image), 'retro' (8bit), 'monsterid' (monster),
    4324  *                                  'wavatar' (cartoon face), 'indenticon' (the "quilt"), 'mystery', 'mm',
    4325  *                                  or 'mysteryman' (The Oyster Man), 'blank' (transparent GIF), or
    4326  *                                  'gravatar_default' (the Gravatar logo). Default is the value of the
    4327  *                                  'avatar_default' option, with a fallback of 'mystery'.
    4328  *     @type bool   $force_default  Whether to always show the default image, never the Gravatar. Default false.
    4329  *     @type string $rating         What rating to display avatars up to. Accepts 'G', 'PG', 'R', 'X', and are
    4330  *                                  judged in that order. Default is the value of the 'avatar_rating' option.
     4330 *     @type string $default        URL for the default image or a default type. Accepts:
     4331 *                                  - '404' (return a 404 instead of a default image)
     4332 *                                  - 'retro' (a 8-bit arcade-style pixelated face)
     4333 *                                  - 'robohash' (a robot)
     4334 *                                  - 'monsterid' (a monster)
     4335 *                                  - 'wavatar' (a cartoon face)
     4336 *                                  - 'identicon' (the "quilt", a geometric pattern)
     4337 *                                  - 'mystery', 'mm', or 'mysteryman' (The Oyster Man)
     4338 *                                  - 'blank' (transparent GIF)
     4339 *                                  - 'gravatar_default' (the Gravatar logo)
     4340 *                                  Default is the value of the 'avatar_default' option,
     4341 *                                  with a fallback of 'mystery'.
     4342 *     @type bool   $force_default  Whether to always show the default image, never the Gravatar.
     4343 *                                  Default false.
     4344 *     @type string $rating         What rating to display avatars up to. Accepts:
     4345 *                                  - 'G' (suitable for all audiences)
     4346 *                                  - 'PG' (possibly offensive, usually for audiences 13 and above)
     4347 *                                  - 'R' (intended for adult audiences above 17)
     4348 *                                  - 'X' (even more mature than above)
     4349 *                                  Default is the value of the 'avatar_rating' option.
    43314350 *     @type string $scheme         URL scheme to use. See set_url_scheme() for accepted values.
    43324351 *                                  Default null.
    43334352 *     @type array  $processed_args When the function returns, the value will be the processed/sanitized $args
    43344353 *                                  plus a "found_avatar" guess. Pass as a reference. Default null.
    4335  *     @type string $extra_attr     HTML attributes to insert in the IMG element. Is not sanitized. Default empty.
     4354 *     @type string $extra_attr     HTML attributes to insert in the IMG element. Is not sanitized.
     4355 *                                  Default empty.
    43364356 * }
    43374357 * @return array {
  • trunk/src/wp-includes/pluggable.php

    r56756 r56767  
    27982798     *
    27992799     * @since 2.5.0
    2800      * @since 4.2.0 Optional `$args` parameter added.
    2801      *
    2802      * @param mixed  $id_or_email   The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
     2800     * @since 4.2.0 Added the optional `$args` parameter.
     2801     * @since 5.5.0 Added the `loading` argument.
     2802     * @since 6.1.0 Added the `decoding` argument.
     2803     * @since 6.3.0 Added the `fetchpriority` argument.
     2804     *
     2805     * @param mixed  $id_or_email   The avatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
    28032806     *                              user email, WP_User object, WP_Post object, or WP_Comment object.
    2804      * @param int    $size          Optional. Height and width of the avatar image file in pixels. Default 96.
    2805      * @param string $default_value URL for the default image or a default type. Accepts '404' (return
    2806      *                              a 404 instead of a default image), 'retro' (8bit), 'RoboHash' (robohash),
    2807      *                              'monsterid' (monster), 'wavatar' (cartoon face), 'indenticon' (the "quilt"),
    2808      *                              'mystery', 'mm', or 'mysteryman' (The Oyster Man), 'blank' (transparent GIF),
    2809      *                              or 'gravatar_default' (the Gravatar logo). Default is the value of the
    2810      *                              'avatar_default' option, with a fallback of 'mystery'.
    2811      * @param string $alt           Optional. Alternative text to use in img tag. Default empty.
     2807     * @param int    $size          Optional. Height and width of the avatar in pixels. Default 96.
     2808     * @param string $default_value URL for the default image or a default type. Accepts:
     2809     *                              - '404' (return a 404 instead of a default image)
     2810     *                              - 'retro' (a 8-bit arcade-style pixelated face)
     2811     *                              - 'robohash' (a robot)
     2812     *                              - 'monsterid' (a monster)
     2813     *                              - 'wavatar' (a cartoon face)
     2814     *                              - 'identicon' (the "quilt", a geometric pattern)
     2815     *                              - 'mystery', 'mm', or 'mysteryman' (The Oyster Man)
     2816     *                              - 'blank' (transparent GIF)
     2817     *                              - 'gravatar_default' (the Gravatar logo)
     2818     *                              Default is the value of the 'avatar_default' option,
     2819     *                              with a fallback of 'mystery'.
     2820     * @param string $alt           Optional. Alternative text to use in the avatar image tag.
     2821     *                              Default empty.
    28122822     * @param array  $args {
    28132823     *     Optional. Extra arguments to retrieve the avatar.
     
    28152825     *     @type int          $height        Display height of the avatar in pixels. Defaults to $size.
    28162826     *     @type int          $width         Display width of the avatar in pixels. Defaults to $size.
    2817      *     @type bool         $force_default Whether to always show the default image, never the Gravatar. Default false.
    2818      *     @type string       $rating        What rating to display avatars up to. Accepts 'G', 'PG', 'R', 'X', and are
    2819      *                                       judged in that order. Default is the value of the 'avatar_rating' option.
     2827     *     @type bool         $force_default Whether to always show the default image, never the Gravatar.
     2828     *                                       Default false.
     2829     *     @type string       $rating        What rating to display avatars up to. Accepts:
     2830     *                                       - 'G' (suitable for all audiences)
     2831     *                                       - 'PG' (possibly offensive, usually for audiences 13 and above)
     2832     *                                       - 'R' (intended for adult audiences above 17)
     2833     *                                       - 'X' (even more mature than above)
     2834     *                                       Default is the value of the 'avatar_rating' option.
    28202835     *     @type string       $scheme        URL scheme to use. See set_url_scheme() for accepted values.
    28212836     *                                       Default null.
     
    28262841     *     @type string       $loading       Value for the `loading` attribute.
    28272842     *                                       Default null.
    2828      *     @type string       $extra_attr    HTML attributes to insert in the IMG element. Is not sanitized. Default empty.
     2843     *     @type string       $fetchpriority Value for the `fetchpriority` attribute.
     2844     *                                       Default null.
     2845     *     @type string       $decoding      Value for the `decoding` attribute.
     2846     *                                       Default null.
     2847     *     @type string       $extra_attr    HTML attributes to insert in the IMG element. Is not sanitized.
     2848     *                                       Default empty.
    28292849     * }
    28302850     * @return string|false `<img>` tag for the user's avatar. False on failure.
     
    28452865            'loading'       => null,
    28462866            'fetchpriority' => null,
     2867            'decoding'      => null,
    28472868            'extra_attr'    => '',
    2848             'decoding'      => null,
    28492869        );
    28502870
     
    28842904         *
    28852905         * @param string|null $avatar      HTML for the user's avatar. Default null.
    2886          * @param mixed       $id_or_email The avatar to retrieve. Accepts a user_id, Gravatar MD5 hash,
     2906         * @param mixed       $id_or_email The avatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
    28872907         *                                 user email, WP_User object, WP_Post object, or WP_Comment object.
    28882908         * @param array       $args        Arguments passed to get_avatar_url(), after processing.
     
    29232943        }
    29242944
    2925         // Add `loading`, `fetchpriority` and `decoding` attributes.
     2945        // Add `loading`, `fetchpriority`, and `decoding` attributes.
    29262946        $extra_attr = $args['extra_attr'];
    29272947
     
    29362956        }
    29372957
     2958        if ( in_array( $args['fetchpriority'], array( 'high', 'low', 'auto' ), true )
     2959            && ! preg_match( '/\bfetchpriority\s*=/', $extra_attr )
     2960        ) {
     2961            if ( ! empty( $extra_attr ) ) {
     2962                $extra_attr .= ' ';
     2963            }
     2964
     2965            $extra_attr .= "fetchpriority='{$args['fetchpriority']}'";
     2966        }
     2967
    29382968        if ( in_array( $args['decoding'], array( 'async', 'sync', 'auto' ), true )
    29392969            && ! preg_match( '/\bdecoding\s*=/', $extra_attr )
     
    29442974
    29452975            $extra_attr .= "decoding='{$args['decoding']}'";
    2946         }
    2947 
    2948         // Add support for `fetchpriority`.
    2949         if ( in_array( $args['fetchpriority'], array( 'high', 'low', 'auto' ), true )
    2950             && ! preg_match( '/\bfetchpriority\s*=/', $extra_attr )
    2951         ) {
    2952             if ( ! empty( $extra_attr ) ) {
    2953                 $extra_attr .= ' ';
    2954             }
    2955 
    2956             $extra_attr .= "fetchpriority='{$args['fetchpriority']}'";
    29572976        }
    29582977
     
    29722991         *
    29732992         * @since 2.5.0
    2974          * @since 4.2.0 The `$args` parameter was added.
     2993         * @since 4.2.0 Added the `$args` parameter.
    29752994         *
    29762995         * @param string $avatar        HTML for the user's avatar.
    2977          * @param mixed  $id_or_email   The avatar to retrieve. Accepts a user_id, Gravatar MD5 hash,
     2996         * @param mixed  $id_or_email   The avatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
    29782997         *                              user email, WP_User object, WP_Post object, or WP_Comment object.
    2979          * @param int    $size          Square avatar width and height in pixels to retrieve.
    2980          * @param string $default_value URL for the default image or a default type. Accepts '404', 'retro', 'monsterid',
    2981          *                              'wavatar', 'indenticon', 'mystery', 'mm', 'mysteryman', 'blank', or 'gravatar_default'.
     2998         * @param int    $size          Height and width of the avatar in pixels.
     2999         * @param string $default_value URL for the default image or a default type. Accepts:
     3000         *                              - '404' (return a 404 instead of a default image)
     3001         *                              - 'retro' (a 8-bit arcade-style pixelated face)
     3002         *                              - 'robohash' (a robot)
     3003         *                              - 'monsterid' (a monster)
     3004         *                              - 'wavatar' (a cartoon face)
     3005         *                              - 'identicon' (the "quilt", a geometric pattern)
     3006         *                              - 'mystery', 'mm', or 'mysteryman' (The Oyster Man)
     3007         *                              - 'blank' (transparent GIF)
     3008         *                              - 'gravatar_default' (the Gravatar logo)
    29823009         * @param string $alt           Alternative text to use in the avatar image tag.
    29833010         * @param array  $args          Arguments passed to get_avatar_data(), after processing.
  • trunk/src/wp-includes/rest-api.php

    r56192 r56767  
    12161216
    12171217/**
    1218  * Retrieves the avatar urls in various sizes.
     1218 * Retrieves the avatar URLs in various sizes.
    12191219 *
    12201220 * @since 4.7.0
     
    12221222 * @see get_avatar_url()
    12231223 *
    1224  * @param mixed $id_or_email The Gravatar to retrieve a URL for. Accepts a user_id, gravatar md5 hash,
     1224 * @param mixed $id_or_email The avatar to retrieve a URL for. Accepts a user ID, Gravatar MD5 hash,
    12251225 *                           user email, WP_User object, WP_Post object, or WP_Comment object.
    12261226 * @return (string|false)[] Avatar URLs keyed by size. Each value can be a URL string or boolean false.
Note: See TracChangeset for help on using the changeset viewer.