Make WordPress Core

Opened 14 years ago

Closed 10 years ago

#13771 closed enhancement (fixed)

get_the_date() to accept optional $post argument

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

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

Download all attachments as: .zip

Change History (24)

@bigdawggi
14 years ago

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

#1 @ryan
14 years ago

  • Milestone changed from 3.0 to 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
14 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
13 years ago

  • Keywords needs-patch added; date removed
  • Milestone changed from Awaiting Triage to Future Release

@solarissmoke
13 years ago

#4 @solarissmoke
13 years ago

  • Keywords has-patch added; needs-patch removed

Also cleaned up the code/docs a bit.

#5 @devinreams
12 years ago

  • Cc devin@… added

#6 @barrykooij
11 years ago

  • Cc b.kooij@… added

When will this be added to core?

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

#7 @jeremyfelt
10 years ago

  • Component changed from General to Date/Time

@tanner m
10 years ago

New patch.

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

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

@tanner m
10 years ago

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

@adamsilverstein
10 years ago

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

#9 in reply to: ↑ 8 @adamsilverstein
10 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...

@adamsilverstein
10 years ago

add a unit test

#10 @adamsilverstein
10 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
10 years ago

Great, thanks Adam!

#12 follow-up: @nacin
10 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
10 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.


10 years ago

#15 follow-up: @DrewAPicture
10 years ago

  • Keywords commit added
  • Milestone changed from Future Release to 3.9

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

#16 in reply to: ↑ 15 @adamsilverstein
10 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
10 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to 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.