mirror of
https://github.com/WordPress/WordPress.git
synced 2025-03-13 15:20:06 +01:00
Let get_the_date() accept a post object.
props tanner-m, adamsilverstein, bigdawggi. fixes #13771. Built from https://develop.svn.wordpress.org/trunk@27380 git-svn-id: http://core.svn.wordpress.org/trunk@27229 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
690481f8e8
commit
f1bcaeb35f
@ -1420,7 +1420,7 @@ function the_date( $d = '', $before = '', $after = '', $echo = true ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the date the current post was written.
|
||||
* Retrieve the date on which the post was written.
|
||||
*
|
||||
* Unlike the_date() this function will always return the date.
|
||||
* Modify output with 'get_the_date' filter.
|
||||
@ -1428,17 +1428,28 @@ function the_date( $d = '', $before = '', $after = '', $echo = true ) {
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string $d Optional. PHP date format defaults to the date_format option if not specified.
|
||||
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.
|
||||
* @return string Date the current post was written.
|
||||
*/
|
||||
function get_the_date( $d = '' ) {
|
||||
$post = get_post();
|
||||
function get_the_date( $d = '', $post = null ) {
|
||||
$post = get_post( $post );
|
||||
|
||||
if ( '' == $d )
|
||||
if ( '' == $d ) {
|
||||
$the_date = mysql2date( get_option( 'date_format' ), $post->post_date );
|
||||
else
|
||||
} else {
|
||||
$the_date = mysql2date( $d, $post->post_date );
|
||||
}
|
||||
|
||||
return apply_filters( 'get_the_date', $the_date, $d );
|
||||
/**
|
||||
* Filter the date returned from the get_the_date function.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string $the_date The formatted date.
|
||||
* @param string $d The date format.
|
||||
* @param int|WP_Post $post The post object or id.
|
||||
*/
|
||||
return apply_filters( 'get_the_date', $the_date, $d, $post );
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user