Backport get_avatar_url() fix to v1 REST API

This commit is contained in:
Max Rice 2014-08-30 13:38:45 -04:00
parent 47b9e54797
commit 5b68ec6c80
1 changed files with 7 additions and 4 deletions

View File

@ -424,13 +424,16 @@ class WC_API_Customers extends WC_API_Resource {
*/
private function get_avatar_url( $email ) {
$dom = new DOMDocument();
$avatar_html = get_avatar( $email );
$dom->loadHTML( get_avatar( $email ) );
// Get the URL of the avatar from the provided HTML
preg_match( '/src=["|\'](.+)[\&|"|\']/U', $avatar_html, $matches );
$url = $dom->getElementsByTagName( 'img' )->item( 0 )->getAttribute( 'src' );
if ( isset( $matches[1] ) && ! empty( $matches[1] ) ) {
return esc_url_raw( $matches[1] );
}
return ( ! empty( $url ) ) ? $url : null;
return null;
}
/**