Make WordPress Core

Ticket #21195: 21195.patch

File 21195.patch, 1005 bytes (added by rachelbaker, 10 years ago)

Current approach used in the JSON REST API

  • src/wp-includes/pluggable.php

     
    22002200}
    22012201endif;
    22022202
     2203if ( !function_exists( 'get_avatar_url' ) ) :
     2204/**
     2205 * Retrieve the avatar url for a user who provided a user ID or email address.
     2206 *
     2207 * @uses get_avatar() Retrieves img tag string for user's avatar.
     2208 *
     2209 * @param int|string|object $id_or_email A user ID,  email address, or comment object
     2210 * @return string Empty string url not found or avatar URL.
     2211*/
     2212function get_avatar_url( $id_or_email ) {
     2213        $avatar_html = get_avatar( $id_or_email );
     2214
     2215        preg_match( '/src=["|\'](.+)[\&|"|\']/U', $avatar_html, $matches );
     2216
     2217        if ( ! empty( $matches[1] ) ) {
     2218                return esc_url_raw( $matches[1] );
     2219        }
     2220
     2221        return '';
     2222}
     2223endif;
     2224
    22032225if ( !function_exists( 'wp_text_diff' ) ) :
    22042226/**
    22052227 * Displays a human readable HTML representation of the difference between two strings.