Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#44490 closed enhancement (fixed)

get_the_date() should be calling get_post_time()

Reported by: Rarst Owned by: SergeyBiryukov
Priority: normal Milestone: 5.1
Component: Date/Time Version: 3.0
Severity: minor Keywords: has-patch has-unit-tests
Cc: Focuses:

Description

Date/Time template tags follow a certain hierarchy with one exception:

  • the_time() > get_the_time() > get_post_time() > mysql2date()
  • the_modified_time() > get_the_modified_time() > get_post_modified_time() > mysql2date()
  • the_date() > get_the_date() > mysql2date()
  • the_modified_date() > get_the_modified_date() > get_post_modified_time() > mysql2date()

There is get_the_date() > get_post_time() level missing. Which means that low level get_post_time filter in it will only affect time branch, but not date branch. This is inconsistent and potentially unexpected.

Will work on a patch to adjust get_the_date() implementation.

Attachments (2)

trac-44490.diff​ (595 bytes ) - added by Rarst 8 years ago.
Changed get_the_date() to call get_post_time() for consistency.
trac-44490.2.diff​ (3.3 KB ) - added by Rarst 8 years ago.
Added test for hooks fired.

Download all attachments as: .zip

Change History (7)

@Rarst
8 years ago

Changed get_the_date() to call get_post_time() for consistency.

#1 @Rarst
8 years ago

  • Keywords has-patch added

#2 @flixos90
8 years ago

  • Keywords needs-unit-tests added
  • Milestone Awaiting Review → 5.0

A few tests here could be useful, ensuring that the intended filters are fired for all these functions.

@Rarst
8 years ago

Added test for hooks fired.

#3 @Rarst
8 years ago

  • Keywords has-unit-tests added; needs-unit-tests removed

#4 @SergeyBiryukov
8 years ago

  • Owner set to SergeyBiryukov
  • Resolution → fixed
  • Status new → closed

In 43591:

Date/Time: Make get_the_date() call get_post_time() for consistency with get_the_time().

Props Rarst.
Fixes #44490.

#5 @johnbillion
8 years ago

  • Milestone 5.0 → 5.1
Note: See TracTickets for help on using tickets.