Make WordPress Core

Opened 3 years ago

Last modified 6 months ago

#37267 new defect (bug)

Don't output a cancel comment reply link if comments aren't threaded

Reported by: henry.wright Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 2.9
Component: Comments Keywords: has-patch needs-refresh
Focuses: Cc:
PR Number:


cancel_comment_reply_link() is used inside comment_form() to output a cancel comment reply link. If comments aren't threaded, the cancel comment reply link isn't needed. It currently appears in the HTML source regardless of the status of thread_comments.

Attachments (2)

37267.patch (729 bytes) - added by jignesh.nakrani 3 years ago.
@rachelbaker @henry.wright here is a patch to skip rendering cancel comment reply link if comments aren't threaded.
37267.diff (493 bytes) - added by henry.wright 3 years ago.

Download all attachments as: .zip

Change History (8)

#1 @rachelbaker
3 years ago

  • Component changed from General to Comments
  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release
  • Version changed from 4.5.3 to 2.9

@henry.wright Thanks for the report. While cancel_comment_reply_link() is always called, if you look at the code in get_cancel_comment_reply_link() the reply link is still output, but hidden unless the replytocom param is set:

$style = isset($_GET['replytocom']) ? '' : ' style="display:none;"';

If threaded comments aren't allowed, I don't see why we need to output anything. Would you be willing to submit a patch?

Introduced in [12810]

3 years ago

@rachelbaker @henry.wright here is a patch to skip rendering cancel comment reply link if comments aren't threaded.

#2 @jignesh.nakrani
3 years ago

  • Keywords has-patch added; needs-patch removed

This ticket was mentioned in Slack in #core by jignesh. View the logs.

3 years ago

#4 @henry.wright
3 years ago

Thanks for the patch. Personally, I'd just bail from the function early if comments aren't threaded.

function get_cancel_comment_reply_link( $text = '' ) {
    if ( ! get_option( 'thread_comments' ) ) {
        return '';
    // Rest of code.
Last edited 3 years ago by henry.wright (previous) (diff)

3 years ago

#5 @henry.wright
3 years ago

37267.diff is an alternative to @jignesh.nakrani's patch.

37267.diff won't stop cancel_reply_before and cancel_reply_before output, but it will stop the actual cancel comment reply link output.

#6 @desrosj
6 months ago

  • Keywords needs-refresh added

The latest patch no longer applies to trunk.

Note: See TracTickets for help on using tickets.