From 2b280c576114342d3e54afcf4edaf485db62ca89 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Tue, 27 Aug 2013 13:16:34 +0000 Subject: [PATCH] Ensure a user exists in get_comment_author(). props azaozz. see #24084. git-svn-id: https://develop.svn.wordpress.org/trunk@25136 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/comment-template.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/wp-includes/comment-template.php b/src/wp-includes/comment-template.php index 9a09d28d54..3ab1167740 100644 --- a/src/wp-includes/comment-template.php +++ b/src/wp-includes/comment-template.php @@ -22,17 +22,17 @@ */ function get_comment_author( $comment_ID = 0 ) { $comment = get_comment( $comment_ID ); - if ( empty($comment->comment_author) ) { - if (!empty($comment->user_id)){ - $user=get_userdata($comment->user_id); - $author=$user->user_login; - } else { + + if ( empty( $comment->comment_author ) ) { + if ( $comment->user_id && $user = get_userdata( $comment->user_id ) ) + $author = $user->display_name; + else $author = __('Anonymous'); - } } else { $author = $comment->comment_author; } - return apply_filters('get_comment_author', $author); + + return apply_filters( 'get_comment_author', $author ); } /**