Make WordPress Core

Opened 16 years ago

Closed 13 years ago

#13771 closed enhancement (fixed)

get_the_date() to accept optional $post argument

Reported by: bigdawggi Owned by: nacin
Priority: normal Milestone: 3.9
Component: Date/Time Version: 3.0
Severity: normal Keywords: has-patch dev-feedback commit
Cc: Focuses:

Description

Currently the get_the_date() function only utilizes the global $post. Allowing this function to accept an optional $post object as an argument would be beneficial for getting the formatted date of any post.

Attachments (7)

get_the_date.diff​ (526 bytes ) - added by bigdawggi 16 years ago.
Patch for get_the_date() to accept optional $post arg.
13771.diff​ (993 bytes ) - added by solarissmoke 16 years ago.
13771_2.diff​ (986 bytes ) - added by tanner m 13 years ago.
New patch.
13771_3.diff​ (983 bytes ) - added by tanner m 13 years ago.
Fix doc block grammar and use more conventional $post = 0.
13771.2.diff​ (1.1 KB ) - added by adamsilverstein 13 years ago.
Slight doc block cleanup, add 'Optional' to description of $post variable
13771.2.2.diff​ (1.9 KB ) - added by adamsilverstein 13 years ago.
add a unit test
13771.3.diff​ (2.3 KB ) - added by adamsilverstein 13 years ago.

Download all attachments as: .zip

Change History (24)

@bigdawggi
16 years ago

Patch for get_the_date() to accept optional $post arg.

#1 @ryan
16 years ago

  • Milestone 3.0 → 3.1

We typically call get_post() and let it figure out whether to use the global.

No more enhancements for 3.0. Moving to 3.1.

#2 @bigdawggi
16 years ago

  • Cc matt@… added

Thanks Ryan. I agree, I was just trying to trim the extra function calls; but after review it may not be worth the investment in time to set a precedent of allowing an optional $post arg in template tags, though I'll let you guys decide ;)

#3 @nacin
16 years ago

  • Keywords needs-patch added; date removed
  • Milestone Awaiting Triage → Future Release

#4 @solarissmoke
16 years ago

  • Keywords has-patch added; needs-patch removed

Also cleaned up the code/docs a bit.

#5 @devinreams
15 years ago

  • Cc devin@… added

#6 @barrykooij
14 years ago

  • Cc b.kooij@… added

When will this be added to core?

Version 2, edited 14 years ago by barrykooij (previous) (next) (diff)

#7 @jeremyfelt
13 years ago

  • Component General → Date/Time

#8 follow-up: @tanner m
13 years ago

Hey guys! Just added a new patch here. Let me know if there is anything else you need.

@tanner m
13 years ago

Fix doc block grammar and use more conventional $post = 0.

@adamsilverstein
13 years ago

Slight doc block cleanup, add 'Optional' to description of $post variable

#9 in reply to: ↑ 8 @adamsilverstein
13 years ago

  • Keywords dev-feedback added

Replying to tanner m:

Hey guys! Just added a new patch here. Let me know if there is anything else you need.

Hey Tanner - this looks good, I added the word 'Optional' to the doc block description of the new $post variable, and also cleaned up the alignment a bit.

Thanks for contributing! A unit test would be nice here...

#10 @adamsilverstein
13 years ago

13771.2.2.diff​ Adds a unit test verifying that get_the_date() returns the expected date when passed a post id (apologies for the funky filename).

#11 @tanner m
13 years ago

Great, thanks Adam!

#12 follow-up: @nacin
13 years ago

Nice work, tanner and adam. It looks like $post should also be passed to the get_the_date filter.

#13 in reply to: ↑ 12 @adamsilverstein
13 years ago

Replying to nacin:

Nice work, tanner and adam. It looks like $post should also be passed to the get_the_date filter.

Thanks & good point! Added $post to the filter in 13771.3.diff​ and added a doc block above the filter since I was touching it anyway.

This ticket was mentioned in IRC in #wordpress-dev by tannermoushey. ​View the logs.


13 years ago

#15 follow-up: @DrewAPicture
13 years ago

  • Keywords commit added
  • Milestone Future Release → 3.9

13771.3.diff​ seems to be in order. @adamsilverstein: nice work on the hook docs!

#16 in reply to: ↑ 15 @adamsilverstein
13 years ago

Replying to DrewAPicture:

13771.3.diff​ seems to be in order. @adamsilverstein: nice work on the hook docs!

Yea! that is the first time i've written a hook doc you didn’t have to fix!

#17 @nacin
13 years ago

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

In 27380:

Let get_the_date() accept a post object.

props tanner-m, adamsilverstein, bigdawggi.
fixes #13771.

Note: See TracTickets for help on using tickets.