Changeset 37738
- Timestamp:
- 06/17/2016 05:11:29 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/general-template.php
r37674 r37738 2255 2255 * 2256 2256 * @since 2.1.0 2257 * 2258 * @param string $d Optional. PHP date format. Defaults to the "date_format" option 2259 * @return string 2260 */ 2261 function get_the_modified_date($d = '') { 2262 if ( '' == $d ) 2263 $the_time = get_post_modified_time(get_option('date_format'), null, null, true); 2264 else 2265 $the_time = get_post_modified_time($d, null, null, true); 2257 * @since 4.6.0 The `$post` parameter was added. 2258 * 2259 * @param string $d Optional. PHP date format defaults to the date_format option if not specified. 2260 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post. 2261 * @return false|string Date the current post was modified. False on failure. 2262 */ 2263 function get_the_modified_date( $d = '', $post = null ) { 2264 $post = get_post( $post ); 2265 2266 if ( ! $post ) { 2267 return false; 2268 } 2269 2270 if ( empty( $d ) ) { 2271 $the_time = get_post_modified_time( get_option( 'date_format' ), false, $post, true ); 2272 } else { 2273 $the_time = get_post_modified_time( $d, false, $post, true ); 2274 } 2266 2275 2267 2276 /** … … 2269 2278 * 2270 2279 * @since 2.1.0 2271 * 2272 * @param string $the_time The formatted date. 2273 * @param string $d PHP date format. Defaults to value specified in 2274 * 'date_format' option. 2275 */ 2276 return apply_filters( 'get_the_modified_date', $the_time, $d ); 2280 * @since 4.6.0 The `$post` parameter was added. 2281 * 2282 * @param string $the_time The formatted date. 2283 * @param string $d PHP date format. Defaults to value specified in 2284 * 'date_format' option. 2285 * @param WP_Post $post WP_Post object. 2286 */ 2287 return apply_filters( 'get_the_modified_date', $the_time, $d, $post ); 2277 2288 } 2278 2289 … … 2398 2409 * 2399 2410 * @since 2.0.0 2400 * 2401 * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option. 2402 * @return string 2403 */ 2404 function get_the_modified_time($d = '') { 2405 if ( '' == $d ) 2406 $the_time = get_post_modified_time(get_option('time_format'), null, null, true); 2407 else 2408 $the_time = get_post_modified_time($d, null, null, true); 2411 * @since 4.6.0 The `$post` parameter was added. 2412 * 2413 * @param string $d Optional. Format to use for retrieving the time the post 2414 * was modified. Either 'G', 'U', or php date format defaults 2415 * to the value specified in the time_format option. Default empty. 2416 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post. 2417 * @return false|string Formatted date string or Unix timestamp. False on failure. 2418 */ 2419 function get_the_modified_time( $d = '', $post = null ) { 2420 $post = get_post( $post ); 2421 2422 if ( ! $post ) { 2423 return false; 2424 } 2425 2426 if ( empty( $d ) ) { 2427 $the_time = get_post_modified_time( get_option( 'time_format' ), false, $post, true ); 2428 } else { 2429 $the_time = get_post_modified_time( $d, false, $post, true ); 2430 } 2409 2431 2410 2432 /** … … 2412 2434 * 2413 2435 * @since 2.0.0 2436 * @since 4.6.0 The `$post` parameter was added. 2414 2437 * 2415 2438 * @param string $the_time The formatted time. … … 2417 2440 * written. Accepts 'G', 'U', or php date format. Defaults 2418 2441 * to value specified in 'time_format' option. 2419 */ 2420 return apply_filters( 'get_the_modified_time', $the_time, $d ); 2442 * @param WP_Post $post WP_Post object. 2443 */ 2444 return apply_filters( 'get_the_modified_time', $the_time, $d, $post ); 2421 2445 } 2422 2446 -
trunk/tests/phpunit/tests/general/template.php
r37135 r37738 346 346 return $this->custom_logo_id; 347 347 } 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 } 348 390 }
Note: See TracChangeset
for help on using the changeset viewer.