Make WordPress Core


Ignore:
Timestamp:
07/14/2019 02:34:02 PM (7 years ago)
Author:
SergeyBiryukov
Message:

REST API: Allow rest_get_avatar_urls() to accept full user, post, or comment objects, rather than just an email address, to provide better flexibility for alternative avatar data.

Since the function uses get_avatar_url() internally, which already supports it, this should not have any backward compatibility concerns.

Props donmhico, dshanske, pputzer, joehoyle, TimothyBlynJacobs.
Fixes #40030.

File:
1 edited

Legend:

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

    r45566 r45632  
    10861086
    10871087/**
    1088  * Retrieves the avatar urls in various sizes based on a given email address.
     1088 * Retrieves the avatar urls in various sizes.
    10891089 *
    10901090 * @since 4.7.0
     
    10921092 * @see get_avatar_url()
    10931093 *
    1094  * @param string $email Email address.
     1094 * @param mixed $id_or_email The Gravatar to retrieve a URL for. Accepts a user_id, gravatar md5 hash,
     1095 *                           user email, WP_User object, WP_Post object, or WP_Comment object.
    10951096 * @return array $urls Gravatar url for each size.
    10961097 */
    1097 function rest_get_avatar_urls( $email ) {
     1098function rest_get_avatar_urls( $id_or_email ) {
    10981099    $avatar_sizes = rest_get_avatar_sizes();
    10991100
    11001101    $urls = array();
    11011102    foreach ( $avatar_sizes as $size ) {
    1102         $urls[ $size ] = get_avatar_url( $email, array( 'size' => $size ) );
     1103        $urls[ $size ] = get_avatar_url( $id_or_email, array( 'size' => $size ) );
    11031104    }
    11041105
Note: See TracChangeset for help on using the changeset viewer.