WordPress.org

Make WordPress Core

Changeset 47111


Ignore:
Timestamp:
01/26/2020 10:27:08 PM (9 months ago)
Author:
SergeyBiryukov
Message:

Comments: Add In reply to %s. prefix to child comments in comments feed.

The prefix includes a link to the parent comment and the name of its author.

Props zodiac1978, imath, SergeyBiryukov.
Fixes #43429.

File:
1 edited

Legend:

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

    r47060 r47111  
    950950 * @since 1.5.0
    951951 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
     952 * @since 5.4.0 Added 'In reply to %s.' prefix to child comments in comments feed.
    952953 *
    953954 * @see Walker_Comment::comment()
     
    961962    $comment = get_comment( $comment_ID );
    962963
     964    $comment_content = $comment->comment_content;
     965
     966    if ( is_comment_feed() && $comment->comment_parent ) {
     967        $parent = get_comment( $comment->comment_parent );
     968        if ( $parent ) {
     969            $parent_link = esc_url( get_comment_link( $parent ) );
     970            $name        = get_comment_author( $parent );
     971
     972            $comment_content = sprintf(
     973                /* translators: %s: Comment link. */
     974                ent2ncr( __( 'In reply to %s.' ) ),
     975                '<a href="' . $parent_link . '">' . $name . '</a>'
     976            ) . "\n\n" . $comment_content;
     977        }
     978    }
     979
    963980    /**
    964981     * Filters the text of a comment.
     
    972989     * @param array      $args            An array of arguments.
    973990     */
    974     return apply_filters( 'get_comment_text', $comment->comment_content, $comment, $args );
     991    return apply_filters( 'get_comment_text', $comment_content, $comment, $args );
    975992}
    976993
Note: See TracChangeset for help on using the changeset viewer.