Changeset 27380
- Timestamp:
- 03/03/2014 05:59:11 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/general-template.php
r27300 r27380 1421 1421 1422 1422 /** 1423 * Retrieve the date the currentpost was written.1423 * Retrieve the date on which the post was written. 1424 1424 * 1425 1425 * Unlike the_date() this function will always return the date. … … 1428 1428 * @since 3.0.0 1429 1429 * 1430 * @param string $d Optional. PHP date format defaults to the date_format option if not specified. 1430 * @param string $d Optional. PHP date format defaults to the date_format option if not specified. 1431 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post. 1431 1432 * @return string Date the current post was written. 1432 1433 */ 1433 function get_the_date( $d = '' ) {1434 $post = get_post( );1435 1436 if ( '' == $d ) 1434 function get_the_date( $d = '', $post = null ) { 1435 $post = get_post( $post ); 1436 1437 if ( '' == $d ) { 1437 1438 $the_date = mysql2date( get_option( 'date_format' ), $post->post_date ); 1438 else1439 } else { 1439 1440 $the_date = mysql2date( $d, $post->post_date ); 1440 1441 return apply_filters( 'get_the_date', $the_date, $d ); 1441 } 1442 1443 /** 1444 * Filter the date returned from the get_the_date function. 1445 * 1446 * @since 3.0.0 1447 * 1448 * @param string $the_date The formatted date. 1449 * @param string $d The date format. 1450 * @param int|WP_Post $post The post object or id. 1451 */ 1452 return apply_filters( 'get_the_date', $the_date, $d, $post ); 1442 1453 } 1443 1454 -
trunk/tests/phpunit/tests/post.php
r27081 r27380 866 866 $this->assertNotEquals( $initial_counts->publish, $after_trash_counts->publish ); 867 867 } 868 869 /** 870 * @ticket 13771 871 */ 872 function test_get_the_date_with_id() { 873 $post_id = $this->factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); 874 $this->assertEquals( 'March 1, 2014', get_the_date( 'F j, Y', $post_id ) ); 875 } 868 876 }
Note: See TracChangeset
for help on using the changeset viewer.