Make WordPress Core


Ignore:
Timestamp:
06/17/2016 05:11:29 AM (10 years ago)
Author:
peterwilsoncc
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/general/template.php

    r37135 r37738  
    346346                return $this->custom_logo_id;
    347347        }
     348
     349        /**
     350         * Test get_the_modified_time
     351         *
     352         * @ticket 37059
     353         *
     354         * @since 4.6.0
     355         */
     356        function test_get_the_modified_time_default() {
     357                $details = array(
     358                                'post_date' => '2016-01-21 15:34:36',
     359                                'post_date_gmt' => '2016-01-21 15:34:36',
     360                );
     361                $post_id = $this->factory->post->create( $details );
     362                $post = get_post( $post_id );
     363
     364                $GLOBALS['post'] = $post;
     365
     366                $expected = '1453390476';
     367                $d = 'G';
     368                $actual = get_the_modified_time( $d );
     369                $this->assertEquals( $expected, $actual );
     370        }
     371
     372        /**
     373         * Test get_the_modified_time with post_id parameter.
     374         *
     375         * @ticket 37059
     376         *
     377         * @since 4.6.0
     378         */
     379        function test_get_the_modified_time_with_post_id() {
     380                $details = array(
     381                                'post_date' => '2016-01-21 15:34:36',
     382                                'post_date_gmt' => '2016-01-21 15:34:36',
     383                );
     384                $post_id = $this->factory->post->create( $details );
     385                $d = 'G';
     386                $expected = '1453390476';
     387                $actual = get_the_modified_time( $d, $post_id );
     388                $this->assertEquals( $expected, $actual );
     389        }
    348390}
Note: See TracChangeset for help on using the changeset viewer.