Ticket #21195: 21195-get_avatar_url.diff

File 21195-get_avatar_url.diff, 2.8 KB (added by batmoo, 10 months ago)
  • wp-includes/pluggable.php

     
    15691569} 
    15701570endif; 
    15711571 
    1572 if ( !function_exists( 'get_avatar' ) ) : 
     1572if ( !function_exists( 'get_avatar_url' ) ) : 
    15731573/** 
    1574  * Retrieve the avatar for a user who provided a user ID or email address. 
     1574 * Retrieve the avatar URL for a user who provided a user ID or email address. 
    15751575 * 
    1576  * @since 2.5 
     1576 * @since 3.5 
    15771577 * @param int|string|object $id_or_email A user ID,  email address, or comment object 
    15781578 * @param int $size Size of the avatar image 
    15791579 * @param string $default URL to a default image to use if no avatar is available 
    1580  * @param string $alt Alternate text to use in image tag. Defaults to blank 
    15811580 * @return string <img> tag for the user's avatar 
    15821581*/ 
    1583 function get_avatar( $id_or_email, $size = '96', $default = '', $alt = false ) { 
    1584         if ( ! get_option('show_avatars') ) 
    1585                 return false; 
     1582function get_avatar_url( $id_or_email, $size = '96', $default = '' ) { 
    15861583 
    1587         if ( false === $alt) 
    1588                 $safe_alt = ''; 
    1589         else 
    1590                 $safe_alt = esc_attr( $alt ); 
    1591  
    15921584        if ( !is_numeric($size) ) 
    15931585                $size = '96'; 
    15941586 
     
    16591651                if ( !empty( $rating ) ) 
    16601652                        $out .= "&amp;r={$rating}"; 
    16611653 
    1662                 $avatar = "<img alt='{$safe_alt}' src='{$out}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />"; 
     1654                $avatar_url = $out; 
    16631655        } else { 
    1664                 $avatar = "<img alt='{$safe_alt}' src='{$default}' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />"; 
     1656                $avatar_url = $default; 
    16651657        } 
    16661658 
     1659        return apply_filters( 'get_avatar_url', $avatar_url, $id_or_email, $size, $default ); 
     1660} 
     1661endif; 
     1662 
     1663if ( !function_exists( 'get_avatar' ) ) : 
     1664/** 
     1665 * Retrieve the avatar for a user who provided a user ID or email address. 
     1666 * 
     1667 * @since 2.5 
     1668 * @param int|string|object $id_or_email A user ID,  email address, or comment object 
     1669 * @param int $size Size of the avatar image 
     1670 * @param string $default URL to a default image to use if no avatar is available 
     1671 * @param string $alt Alternate text to use in image tag. Defaults to blank 
     1672 * @return string <img> tag for the user's avatar 
     1673*/ 
     1674function get_avatar( $id_or_email, $size = '96', $default = '', $alt = false ) { 
     1675        if ( ! get_option('show_avatars') ) 
     1676                return false; 
     1677 
     1678        if ( false === $alt ) 
     1679                $safe_alt = ''; 
     1680        else 
     1681                $safe_alt = esc_attr( $alt ); 
     1682 
     1683        if ( !is_numeric($size) ) 
     1684                $size = '96'; 
     1685 
     1686        $avatar_url = get_avatar_url( $id_or_email, $size, $default ); 
     1687 
     1688        if ( ! $avatar_url ) 
     1689                return false; 
     1690 
     1691        $avatar = "<img alt='{$safe_alt}' src='{$avatar_url}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />"; 
     1692 
    16671693        return apply_filters('get_avatar', $avatar, $id_or_email, $size, $default, $alt); 
    16681694} 
    16691695endif;