Make WordPress Core

Opened 14 years ago

Closed 10 years ago

#16430 closed defect (bug) (fixed)

Comment 'Reply' button still present when comment max depth has been reached, just without text.

Reported by: thegremlyn's profile TheGremlyn Owned by: rachelbaker's profile rachelbaker
Milestone: 4.1 Priority: normal
Severity: normal Version: 3.0.4
Component: Comments Keywords: has-patch
Focuses: Cc:

Description

With comment max depth set, in my case, to 5 on the admin panel, the div for the reply link would still appear even though the text that says 'Reply' would not. Basically, it was an empty div with class="reply". The fix is quite easy, which I implemented in test on one of my WP sites.

Around line 1372 of wp-includes/comment-template.php, there is the following is code:

<div class="reply">
<?php comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
</div>

This can simply be enhanced to this:

<?php if ( $depth < $args['max_depth'] ) : ?>
<div class="reply">
<?php comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
</div>
<?php endif; ?>

I just added a quick check to make sure our current comment depth did not meet (or somehow exceed?) our set max depth.

Attachments (1)

16430.1.patch (3.2 KB) - added by brokentone 12 years ago.

Download all attachments as: .zip

Change History (9)

#1 follow-up: @scribu
14 years ago

An opposite view: #14540

#2 in reply to: ↑ 1 @TheGremlyn
14 years ago

Replying to scribu:

An opposite view: #14540

I can see that, but I would argue that if we wanted the user to keep on posting comments in reply to other comments we wouldn't limit the depth in the first place. I would also think that it would be confusing for other users to read and figure out if a comment was meant for the comment immediately above it OR if it was in replay to the comment it is nested in.

Either way, the 'Reply' text wasn't present for me, just a small, empty box (<div class="reply"></div>) where the text would have been were more comments allowed. The comment_reply_link() function returns nothing when max depth is reached it seems, not even the text for the link. Doing what is suggested in your link would be fine, but I think it would be something users should be able to allow or disallow, making it an entirely separate concept and code change. In short... I agree with the dissenters on that ticket ;)

#3 @scribu
14 years ago

Yeah, maybe "opposite" wasn't the right word. Bottom line is that this should be fixed, one way or the other.

#4 @travelvice
14 years ago

I could've sworn that I saw a 'before' and 'after' variables that could be set in get_comment_reply_link, which is called by comment_reply_link.

Perhaps possible to remove the depth evaluation and simply move the opening and closing div's to be placed before and after when it returns true.

http://core.trac.wordpress.org/browser/tags/3.1.1/wp-includes/comment-template.php

@brokentone
12 years ago

#5 @brokentone
12 years ago

@travelvice is absolutely right, the markup can be passed to the function in which case it only displays if it returns. I've created and tested a patch that covers the default function and the implementations in the core themes.

#6 @rachelbaker
10 years ago

  • Keywords needs-refresh needs-unit-tests added
  • Milestone changed from Awaiting Review to Future Release
  • Owner set to rachelbaker
  • Status changed from new to assigned

#7 @wonderboymusic
10 years ago

  • Milestone changed from Future Release to 4.4

#8 @wonderboymusic
10 years ago

  • Keywords needs-refresh needs-unit-tests removed
  • Milestone changed from 4.4 to 4.1
  • Resolution set to fixed
  • Status changed from assigned to closed

Fixed in [29908]

Note: See TracTickets for help on using tickets.