Opened 13 years ago
Last modified 6 years ago
#17763 new enhancement
comments_popup_link() need a get_* version
Reported by: | dd32 | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.2 |
Component: | Comments | Keywords: | needs-patch |
Focuses: | template | Cc: |
Description
Currently comments_popup_link($zero = false, $one = false, $more = false, $css_class = '', $none = false)
has no get_*() version.
Usage situation: Where the link needs to be used within a larger string being concatenated.
Attachments (6)
Change History (29)
#2
@
13 years ago
I would like to make a case for adding a piece of functionality related to post_types and comment support:
If a post type does not have comment support, nothing should be output instead of a "Comments Off" message.
This would require:
- Checking comments support for $post->post_type, return empty string or null if no comments support
- Changing logic in twenty-ten/loop.php before comments_popup_link() is called to determine printing the | separator
Am I supported in thinking this makes sense?
#4
follow-up:
↓ 5
@
13 years ago
- Cc leblogdudeveloppeur added
Why not close this ticket now if the original problem is corrected by the patch ? For me the comment of MeanderingCode is the topic of a new ticket as an evolution.
The original topic is a real problem for internationalization because it is not easy (except if I rewrite the implementation without echo) to put the result of the function in a printf(). It means that we have things like this :
<div><?php printf(__('Published on: <span>%1$s</span> by <span>%2$s</span> - ', 'azsimple'), get_the_time($formatTime), get_the_author()); ?><?php comments_popup_link(__('Leave a Comment', 'azsimple'), __('1 Comment', 'azsimple'), __('% Comments', 'azsimple')); ?></div>
... in templates. If the translator want put the comment link before "Published on...", he can't with just *.po files.
#5
in reply to:
↑ 4
@
13 years ago
Replying to leblogdudeveloppeur:
Why not close this ticket now if the original problem is corrected by the patch ?
The patch still needs to be reviewed and committed.
#8
@
10 years ago
+1
Would love to see this added to core so that I don't have to include copy/edited/pasted custom functions or patch WP core in future projects. The patch was submitted 3 years ago, no?
#9
@
10 years ago
+1 on getting this into core. Would be very useful when string building the post meta.
#11
@
10 years ago
- Keywords has-patch needs-testing added; needs-refresh removed
I believe I got everything in 17763.2.diff. Needs testing.
This ticket was mentioned in Slack in #core by voldemortensen. View the logs.
10 years ago
#13
@
10 years ago
Updated a line after talking with obenland. Now checking with DrewAPicture to make sure the docs are correct.
This ticket was mentioned in Slack in #core by voldemortensen. View the logs.
10 years ago
This ticket was mentioned in Slack in #core by voldemortensen. View the logs.
10 years ago
#17
@
10 years ago
There is no need to instantiate the variable with an empty string:
$output = ''; $output .= '<a href="';
This could be reduced to:
$output = '<a href="';
#18
@
10 years ago
+1. Is this still being worked on? I need this very feature for one of our websites? If yes any idea when it will be included?
#19
@
10 years ago
- Keywords dev-feedback added
I took @voldemortensen's code and did some very minor housekeeping on it, as well as making @toscho's amend.
It works for me, but needs more testing.
#20
follow-up:
↓ 21
@
10 years ago
- Keywords good-first-bug removed
comments_popup_link()
has significant i18n issues, see #13651.
Instead of introducing a get_*() version with the same issues, could we introduce a new function, more i18n-friendly (accepting proper plural forms instead of a pseudo-plural '% Comments'
string), and with a more relevant name?
#21
in reply to:
↑ 20
@
10 years ago
Replying to SergeyBiryukov:
comments_popup_link()
has significant i18n issues, see #13651.
Instead of introducing a get_*() version with the same issues, could we introduce a new function, more i18n-friendly (accepting proper plural forms instead of a pseudo-plural
'% Comments'
string), and with a more relevant name?
+1 for a new approach.
The following patch:
get_comments_popup_link()
bool|string
$echo
parameter tocomments_number()
(get_comments_number()
returns the raw number, not the template used bycomments_number()
)