Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#25310 closed defect (bug) (fixed)

comment_reply_link() doesn't work properly

Reported by: raminmt's profile raminmt Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 3.7 Priority: normal
Severity: normal Version: 3.6
Component: Inline Docs Keywords: has-patch
Focuses: Cc:

Description

Hi,
I was hired for a client job and I was working on it,
The client asked me to design a custom template for comments.
I decided to not use wp_list_comments then fetch data using available wp functions and when I was trying to create reply link the function comment_reply_link() and get_comment_reply_link() failed to generate and print the link
To make sure that my work is not wrong I checked different formats of using function and it's parameters as below:
comment_reply_link()
comment_reply_link(array())
comment_reply_link(array(), comment_ID(), the_ID())
Also I passed comment id and post id directly to test but failed

Note: Even I passed some parameters to first arguement

tnx
Ramin MT

Attachments (1)

25310.diff (5.4 KB) - added by DrewAPicture 11 years ago.
functional + filter docs

Download all attachments as: .zip

Change History (13)

#1 follow-up: @SergeyBiryukov
11 years ago

  • Keywords needs-patch removed

get_comment_reply_link() bails out early if depth argument is not passed:
tags/3.6.1/wp-includes/comment-template.php#L1043.

#2 in reply to: ↑ 1 @raminmt
11 years ago

Replying to SergeyBiryukov:

get_comment_reply_link() bails out early if depth argument is not passed:
tags/3.6.1/wp-includes/comment-template.php#L1043.

So you mean I must set this argument? Right?

#3 @SergeyBiryukov
11 years ago

It looks like max_depth is also required, so this should work:

comment_reply_link( array( 'depth' => 1, 'max_depth' => get_option( 'thread_comments_depth' ) ) );

#4 follow-up: @SergeyBiryukov
11 years ago

You may want to take a look how Twenty Twelve or Twenty Eleven define a custom comment callback instead of avoiding wp_list_comments().

#5 in reply to: ↑ 4 @raminmt
11 years ago

Replying to SergeyBiryukov:

You may want to take a look how Twenty Twelve or Twenty Eleven define a custom comment callback instead of avoiding wp_list_comments().

Thanks bro, that snippet works fine ;)

About using custom comment fallback I should tell that I was seen it in codex documents.
I tried it and I found that is works fine.
Anyway thank you for your help :)

Ramin MT

#6 follow-up: @SergeyBiryukov
11 years ago

  • Keywords needs-docs added

Perhaps we should mention in Codex or in the inline docs that depth and max_depth are required if the function is called separately from wp_list_comments() (if that makes sense). Currently $args is marked as optional.

#7 in reply to: ↑ 6 @raminmt
11 years ago

Replying to SergeyBiryukov:

Perhaps we should mention in Codex or in the inline docs that depth and max_depth are required if the function is called separately from wp_list_comments() (if that makes sense). Currently $args is marked as optional.

Yes, your're right
In the Codex $args is marked as optional but after your description I got that those are required and I will fix the Codex documents soon

Ramin MT

@DrewAPicture
11 years ago

functional + filter docs

#8 @DrewAPicture
11 years ago

  • Keywords needs-docs removed

25310.diff adds functional docs for get_comment_reply_link() and filter docs for the comment_reply_link hook.

Side note: I added a todo note in get_post_reply_link() for the docs team for when we get around to standardizing the docs in this file.

Last edited 11 years ago by DrewAPicture (previous) (diff)

#9 @DrewAPicture
11 years ago

  • Keywords has-patch added

#10 @SergeyBiryukov
11 years ago

  • Milestone changed from Awaiting Review to 3.7

#11 @SergeyBiryukov
11 years ago

  • Component changed from Comments to Inline Docs

#12 @SergeyBiryukov
11 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 25428:

Inline documentation for get_comment_reply_link() and 'comment_reply_link' filter.

props DrewAPicture.
fixes #25310.

Note: See TracTickets for help on using tickets.