WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 8 weeks ago

Last modified 8 weeks ago

#19849 closed enhancement (fixed)

Pass $comment_date to get_comment_time filter

Reported by: lexhair Owned by: nacin
Milestone: 3.9 Priority: normal
Severity: minor Version: 3.3.1
Component: Comments Keywords: has-patch
Focuses: Cc:

Description

I was writing a function to customize the formatted time to include the timezone in the comment meta data using the get_comment_time filter. In order for me to properly indicate whether daylight savings time was in effect at the time of the comment, I needed to globalize $comment to get the comment_time property. The filter passed the $date variable which is the formatted time part of the timestamp but not the $comment_date variable which contained the entire timestamp from $comment. In the function I developed, the $date string wasn't used at all. I returned the formatted time string from $comment->comment_date directly.

Since get_comment_time() already establishes $comment_date, why not pass it to the filter as well?

Attachments (1)

19849.patch (1.1 KB) - added by SergeyBiryukov 8 weeks ago.

Download all attachments as: .zip

Change History (7)

comment:1 MattyRob8 weeks ago

  • Keywords close added

Hi there, apologies that this ticket has remained unanswered for so long.

There is a get_comment_date() function that mirrors the get_comment_time() function with the former returning a formatted date while the latter returns a formatted time.

I think the confusion here is the use of a $date variable in the get_comment_time() function but the core code seems to consider that a 'time' is simply a small part of the overall timestamp which also includes the 'date'.

I think including 'date' information in the get_comment_time() function might confuse further when these 2 functions are available and documented in the codex.

SergeyBiryukov8 weeks ago

comment:2 follow-up: SergeyBiryukov8 weeks ago

  • Keywords has-patch added; close removed

I think we can pass the comment object to the filter in both get_comment_date() and get_comment_time().

comment:3 in reply to: ↑ 2 lexhair8 weeks ago

Replying to SergeyBiryukov:

I think we can pass the comment object to the filter in both get_comment_date() and get_comment_time().

Thank you. That's the solution I was looking for.

comment:4 SergeyBiryukov8 weeks ago

  • Component changed from Date/Time to Comments
  • Milestone changed from Awaiting Review to 3.9

comment:5 nacin8 weeks ago

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

In 27283:

Pass the comment object to the get_comment_date and get_comment_time.

props SergeyBiryukov.
fixes #19849.

comment:6 jorbin8 weeks ago

related #22380

Note: See TracTickets for help on using tickets.