WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 3 months ago

#17763 new enhancement

comments_popup_link() need a get_* version

Reported by: dd32 Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.2
Component: Comments Keywords: has-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 (1)

17763.diff (5.4 KB) - added by kawauso 3 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 kawauso3 years ago

  • Keywords has-patch added; needs-patch removed

The following patch:

  • Introduces get_comments_popup_link()
  • Drops @return null Returns null on single posts and pages (this never worked as no other values were ever returned)
  • Changes most @param to bool|string
  • Adds $echo parameter to comments_number() (get_comments_number() returns the raw number, not the template used by comments_number())

kawauso3 years ago

comment:2 MeanderingCode3 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?

comment:3 goto102 years ago

  • Cc dromsey@… added

comment:4 follow-up: leblogdudeveloppeur2 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.

comment:5 in reply to: ↑ 4 SergeyBiryukov2 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.

comment:6 pauldewouters23 months ago

  • Cc pauldewouters added

comment:7 nacin3 months ago

  • Component changed from Template to Comments
  • Focuses template added
Note: See TracTickets for help on using tickets.