diff --git src/wp-includes/rest-api.php src/wp-includes/rest-api.php
index 716b425e57..31223c6f30 100644
|
|
function rest_is_boolean( $maybe_bool ) { |
1085 | 1085 | } |
1086 | 1086 | |
1087 | 1087 | /** |
1088 | | * Retrieves the avatar urls in various sizes based on a given email address. |
| 1088 | * Retrieves the avatar urls in various sizes. |
1089 | 1089 | * |
1090 | 1090 | * @since 4.7.0 |
1091 | 1091 | * |
1092 | 1092 | * @see get_avatar_url() |
1093 | 1093 | * |
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. |
1095 | 1096 | * @return array $urls Gravatar url for each size. |
1096 | 1097 | */ |
1097 | | function rest_get_avatar_urls( $email ) { |
| 1098 | function rest_get_avatar_urls( $id_or_email ) { |
1098 | 1099 | $avatar_sizes = rest_get_avatar_sizes(); |
1099 | 1100 | |
1100 | 1101 | $urls = array(); |
1101 | 1102 | 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 ) ); |
1103 | 1104 | } |
1104 | 1105 | |
1105 | 1106 | return $urls; |
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 { |
949 | 949 | } |
950 | 950 | |
951 | 951 | 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 ); |
953 | 953 | } |
954 | 954 | |
955 | 955 | if ( in_array( 'meta', $fields, true ) ) { |
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 { |
938 | 938 | } |
939 | 939 | |
940 | 940 | 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 ); |
942 | 942 | } |
943 | 943 | |
944 | 944 | if ( in_array( 'meta', $fields, true ) ) { |