WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 8 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
Focuses: Cc:

Description

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 (3)

37267.patch (729 bytes) - added by jignesh.nakrani 4 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 4 years ago.
37267-1.patch (756 bytes) - added by jignesh.nakrani 8 months ago.
here is a patch to skip rendering cancel comment reply link if comments aren't threaded.

Download all attachments as: .zip

Change History (10)

#1 @rachelbaker
4 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]

@jignesh.nakrani
4 years ago

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

#2 @jignesh.nakrani
4 years ago

  • Keywords has-patch added; needs-patch removed

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


4 years ago

#4 @henry.wright
4 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 4 years ago by henry.wright (previous) (diff)

@henry.wright
4 years ago

#5 @henry.wright
4 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
20 months ago

  • Keywords needs-refresh added

The latest patch no longer applies to trunk.

@jignesh.nakrani
8 months ago

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

#7 @jignesh.nakrani
8 months ago

  • Keywords needs-refresh removed

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

I think if cancel_reply_link is not being added then we don’t have to print cancel_reply_before and cancel_reply_after

@henrywright @desrosj

Note: See TracTickets for help on using tickets.