Make WordPress Core

Changeset 25136


Ignore:
Timestamp:
08/27/2013 01:16:34 PM (13 years ago)
Author:
nacin
Message:

Ensure a user exists in get_comment_author().

props azaozz.
see #24084.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment-template.php

    r24573 r25136  
    2323function get_comment_author( $comment_ID = 0 ) {
    2424        $comment = get_comment( $comment_ID );
    25         if ( empty($comment->comment_author) ) {
    26                 if (!empty($comment->user_id)){
    27                         $user=get_userdata($comment->user_id);
    28                         $author=$user->user_login;
    29                 } else {
     25
     26        if ( empty( $comment->comment_author ) ) {
     27                if ( $comment->user_id && $user = get_userdata( $comment->user_id ) )
     28                        $author = $user->display_name;
     29                else
    3030                        $author = __('Anonymous');
    31                 }
    3231        } else {
    3332                $author = $comment->comment_author;
    3433        }
    35         return apply_filters('get_comment_author', $author);
     34
     35        return apply_filters( 'get_comment_author', $author );
    3636}
    3737
Note: See TracChangeset for help on using the changeset viewer.