From 641818a02b6651ff6aa57dab296487e74b1c8976 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 20 Feb 2008 20:57:21 +0000 Subject: [PATCH] Allow comment object to be passed to get_avatar() for convenience. see #5775 git-svn-id: https://develop.svn.wordpress.org/trunk@6945 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/pluggable.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index feb9186b2b..e4fa9f1cd8 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -1186,13 +1186,21 @@ function get_avatar( $id_or_email, $size = '96', $default = '' ) { if ( ! get_option('show_avatars') ) return false; + $email = ''; if ( is_numeric($id_or_email) ) { $id = (int) $id_or_email; $user = get_userdata($id); - if ( !$user) - $email = ''; - else + if ( $user ) $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 { $email = $id_or_email; }