Make WordPress Core

Opened 12 years ago

Closed 10 years ago

Last modified 10 years ago

#19849 closed enhancement (fixed)

Pass $comment_date to get_comment_time filter

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


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 10 years ago.

Download all attachments as: .zip

Change History (7)

#1 @MattyRob
10 years 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.

#2 follow-up: @SergeyBiryukov
10 years 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().

#3 in reply to: ↑ 2 @lexhair
10 years 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.

#4 @SergeyBiryukov
10 years ago

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

#5 @nacin
10 years 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.

#6 @jorbin
10 years ago

related #22380

Note: See TracTickets for help on using tickets.