WordPress.org

Make WordPress Core

Ticket #40030: pass_object_to_rest_get_avatar_urls.40030.diff

File pass_object_to_rest_get_avatar_urls.40030.diff, 2.4 KB (added by donmhico, 17 months ago)
  • src/wp-includes/rest-api.php

    diff --git src/wp-includes/rest-api.php src/wp-includes/rest-api.php
    index 716b425e57..31223c6f30 100644
    function rest_is_boolean( $maybe_bool ) { 
    10851085}
    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
    10911091 *
    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
    11051106        return $urls;
  • src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

    diff --git src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
    index 8fafc20e80..b730844fde 100644
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    949949                }
    950950
    951951                if ( in_array( 'author_avatar_urls', $fields, true ) ) {
    952                         $data['author_avatar_urls'] = rest_get_avatar_urls( $comment->comment_author_email );
     952                        $data['author_avatar_urls'] = rest_get_avatar_urls( $comment );
    953953                }
    954954
    955955                if ( in_array( 'meta', $fields, true ) ) {
  • src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php

    diff --git src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
    index 7553678456..bd09b70b32 100644
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    938938                }
    939939
    940940                if ( in_array( 'avatar_urls', $fields, true ) ) {
    941                         $data['avatar_urls'] = rest_get_avatar_urls( $user->user_email );
     941                        $data['avatar_urls'] = rest_get_avatar_urls( $user );
    942942                }
    943943
    944944                if ( in_array( 'meta', $fields, true ) ) {