From e01352fe2f166d817b8662e60140145b1c73c8c4 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Tue, 27 Aug 2013 13:17:09 +0000 Subject: [PATCH] Ensure a user exists in get_comment_author(). props azaozz. see #24084. Built from https://develop.svn.wordpress.org/trunk@25136 git-svn-id: http://core.svn.wordpress.org/trunk@25116 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/comment-template.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php index 9a09d28d54..3ab1167740 100644 --- a/wp-includes/comment-template.php +++ b/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 ); } /**