mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-05-29 15:44:27 +00:00
Posts: Add $post parameter to modified date and time functions.
Unifies the APIs for getting a post's modified date or time with getting a post's date or time. Adds the `$post` parameter to the functions `get_the_modified_date` and `get_the_modified_time`. Adds the `$post` parameter to the filters `get_the_modified_date` and `get_the_modified_time`. Props Soean, lukecavanagh. Fixes #37059. git-svn-id: https://develop.svn.wordpress.org/trunk@37738 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -345,4 +345,46 @@ class Tests_General_Template extends WP_UnitTestCase {
|
||||
$this->custom_logo_id = $this->_make_attachment( $upload );
|
||||
return $this->custom_logo_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get_the_modified_time
|
||||
*
|
||||
* @ticket 37059
|
||||
*
|
||||
* @since 4.6.0
|
||||
*/
|
||||
function test_get_the_modified_time_default() {
|
||||
$details = array(
|
||||
'post_date' => '2016-01-21 15:34:36',
|
||||
'post_date_gmt' => '2016-01-21 15:34:36',
|
||||
);
|
||||
$post_id = $this->factory->post->create( $details );
|
||||
$post = get_post( $post_id );
|
||||
|
||||
$GLOBALS['post'] = $post;
|
||||
|
||||
$expected = '1453390476';
|
||||
$d = 'G';
|
||||
$actual = get_the_modified_time( $d );
|
||||
$this->assertEquals( $expected, $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get_the_modified_time with post_id parameter.
|
||||
*
|
||||
* @ticket 37059
|
||||
*
|
||||
* @since 4.6.0
|
||||
*/
|
||||
function test_get_the_modified_time_with_post_id() {
|
||||
$details = array(
|
||||
'post_date' => '2016-01-21 15:34:36',
|
||||
'post_date_gmt' => '2016-01-21 15:34:36',
|
||||
);
|
||||
$post_id = $this->factory->post->create( $details );
|
||||
$d = 'G';
|
||||
$expected = '1453390476';
|
||||
$actual = get_the_modified_time( $d, $post_id );
|
||||
$this->assertEquals( $expected, $actual );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user