Allow comment object to be passed to get_avatar() for convenience. see #5775
git-svn-id: http://svn.automattic.com/wordpress/trunk@6945 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
865a634fb4
commit
3355f0c2af
|
@ -1186,13 +1186,21 @@ function get_avatar( $id_or_email, $size = '96', $default = '' ) {
|
||||||
if ( ! get_option('show_avatars') )
|
if ( ! get_option('show_avatars') )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
$email = '';
|
||||||
if ( is_numeric($id_or_email) ) {
|
if ( is_numeric($id_or_email) ) {
|
||||||
$id = (int) $id_or_email;
|
$id = (int) $id_or_email;
|
||||||
$user = get_userdata($id);
|
$user = get_userdata($id);
|
||||||
if ( !$user)
|
if ( $user )
|
||||||
$email = '';
|
|
||||||
else
|
|
||||||
$email = $user->user_email;
|
$email = $user->user_email;
|
||||||
|
} elseif ( is_object($id_or_email) ) {
|
||||||
|
if ( !empty($id_or_email->user_id) ) {
|
||||||
|
$id = (int) $id_or_email->user_id;
|
||||||
|
$user = get_userdata();
|
||||||
|
if ( $user)
|
||||||
|
$email = $user->user_email;
|
||||||
|
} elseif ( !empty($id_or_email->comment_author_email) ) {
|
||||||
|
$email = $id_or_email->comment_author_email;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$email = $id_or_email;
|
$email = $id_or_email;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue