Ticket #13771: 13771.2.2.diff
File 13771.2.2.diff, 1.9 KB (added by , 11 years ago) |
---|
-
src/wp-includes/general-template.php
1420 1420 } 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. 1426 1426 * Modify output with 'get_the_date' filter. 1427 1427 * 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. 1431 * @return string Date the current post was written. 1430 * @param string $d Optional. PHP date format defaults to the date_format option if not specified. 1431 * @param int|WP_Post $post Optional. WP_Post object or ID. Default is global $post object. 1432 * @return string Date the current post was written. 1432 1433 */ 1433 function get_the_date( $d = '' ) {1434 $post = get_post( );1434 function get_the_date( $d = '', $post = 0 ) { 1435 $post = get_post( $post ); 1435 1436 1436 1437 if ( '' == $d ) 1437 1438 $the_date = mysql2date( get_option( 'date_format' ), $post->post_date ); -
tests/phpunit/tests/post.php
865 865 $this->assertEquals( 9, $after_trash_counts->publish ); 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_data = array( 874 'post_status' => 'public', 875 'post_content' => rand_str(), 876 'post_title' => 'Post test', 877 'post_date' => '2014-03-01 16:35:00', 878 ); 879 $insert_post_id = wp_insert_post( $post_data ); 880 881 $this->assertEquals( 'March 1, 2014', get_the_date( 'F j, Y', $insert_post_id ) ); 882 } 868 883 }