#29454 closed defect (bug) (fixed)
comments_link filter can not be run on comments_popup_link if post has no comments.
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 4.4 | Priority: | normal |
| Severity: | normal | Version: | 2.5 |
| Component: | Comments | Keywords: | |
| Focuses: | template | Cc: |
Description
The filter 'comments_link' is run in the function comments_link(), called by comments_popup_link(). However, if a post has no comments, it doesn't call comments_link(); it calls get_permalink() and appends hashtag fragment (basically, recreating what comments_link() does.)
This means that you can't filter the comments link separately from the permalink if a post has no comments.
Additionally, comments_link() is a deprecated function, so core shouldn't be using it.
Patch uses get_comments_link regardless of number of comments & removes comments_link from function.
Attachments (2)
Change History (9)
#1
@
11 years ago
Additionally, comments_link() is a deprecated function, so core shouldn't be using it.
comments_link() has two deprecated arguments, but the function itself is not deprecated.
#2
@
11 years ago
Ah - moving too quickly; misread that. Regardless, the rest of the statement stands.
#4
@
11 years ago
comments_link() has an additional benefit of esc_url() after the filter, we should keep using it here.
Note that get_permalink() . '#respond' is a direct link to the comment form, while comments_link() is a link to the comments block. There is no difference in default themes with no comments, but there might be a difference in other themes.
Perhaps we could add a new filter, get_respond_link.
#5
@
11 years ago
I think that a new filter would definitely work, too - I'll add a patch for that, instead. Practically speaking, the important thing is to be able to filter the comment link whether the post has comments or not; using get_respond_link as a filter would fulfill that.
For consistency, I think that the filter should probably be respond_link, since it's run in a printing function.
Use get_comments_link() instead of get_permalink/comments_link