From 40391f4e370ee457c992d6406ed1129195cfa1bf Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 2 Nov 2013 12:20:11 +0000 Subject: [PATCH] Fall back to comment author email in get_avatar() if the user who left the comment no longer exists. props mauryaratan, lite3. fixes #25803. Built from https://develop.svn.wordpress.org/trunk@26000 git-svn-id: http://core.svn.wordpress.org/trunk@25933 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/pluggable.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index 6839b015ac..3fce716f4b 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -1645,14 +1645,15 @@ function get_avatar( $id_or_email, $size = '96', $default = '', $alt = false ) { if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) return false; - if ( !empty($id_or_email->user_id) ) { + if ( ! empty( $id_or_email->user_id ) ) { $id = (int) $id_or_email->user_id; $user = get_userdata($id); - if ( $user) + if ( $user ) $email = $user->user_email; - } elseif ( !empty($id_or_email->comment_author_email) ) { - $email = $id_or_email->comment_author_email; } + + if ( ! $email && ! empty( $id_or_email->comment_author_email ) ) + $email = $id_or_email->comment_author_email; } else { $email = $id_or_email; }