Changeset 37866
- Timestamp:
- 06/26/2016 11:29:13 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/general-template.php
r37753 r37866 2266 2266 2267 2267 if ( ! $post ) { 2268 return false; 2269 } 2270 2271 if ( empty( $d ) ) { 2268 // For backward compatibility, failures go through the filter below. 2269 $the_time = false; 2270 } elseif ( empty( $d ) ) { 2272 2271 $the_time = get_post_modified_time( get_option( 'date_format' ), false, $post, true ); 2273 2272 } else { … … 2422 2421 2423 2422 if ( ! $post ) { 2424 return false; 2425 } 2426 2427 if ( empty( $d ) ) { 2423 // For backward compatibility, failures go through the filter below. 2424 $the_time = false; 2425 } elseif ( empty( $d ) ) { 2428 2426 $the_time = get_post_modified_time( get_option( 'time_format' ), false, $post, true ); 2429 2427 } else { -
trunk/tests/phpunit/tests/general/template.php
r37738 r37866 371 371 372 372 /** 373 * Test get_the_modified_time failures are filtered 374 * 375 * @ticket 37059 376 * 377 * @since 4.6.0 378 */ 379 function test_get_the_modified_time_failures_are_filtered() { 380 // Remove global post objet 381 $GLOBALS['post'] = null; 382 383 $expected = 'filtered modified time failure result'; 384 add_filter( 'get_the_modified_time', array( $this, '_filter_get_the_modified_time_failure' ) ); 385 $actual = get_the_modified_time(); 386 $this->assertEquals( $expected, $actual ); 387 remove_filter( 'get_the_modified_time', array( $this, '_filter_get_the_modified_time_failure' ) ); 388 } 389 390 function _filter_get_the_modified_time_failure( $the_time ) { 391 $expected = false; 392 $actual = $the_time; 393 $this->assertEquals( $expected, $actual ); 394 395 if ( false === $the_time ) { 396 return 'filtered modified time failure result'; 397 } 398 return $the_time; 399 } 400 401 /** 402 * Test get_the_modified_time with post_id parameter. 403 * 404 * @ticket 37059 405 * 406 * @since 4.6.0 407 */ 408 function test_get_the_modified_date_with_post_id() { 409 $details = array( 410 'post_date' => '2016-01-21 15:34:36', 411 'post_date_gmt' => '2016-01-21 15:34:36', 412 ); 413 $post_id = $this->factory->post->create( $details ); 414 $d = 'Y-m-d'; 415 $expected = '2016-01-21'; 416 $actual = get_the_modified_date( $d, $post_id ); 417 $this->assertEquals( $expected, $actual ); 418 } 419 420 /** 421 * Test get_the_modified_date 422 * 423 * @ticket 37059 424 * 425 * @since 4.6.0 426 */ 427 function test_get_the_modified_date_default() { 428 $details = array( 429 'post_date' => '2016-01-21 15:34:36', 430 'post_date_gmt' => '2016-01-21 15:34:36', 431 ); 432 $post_id = $this->factory->post->create( $details ); 433 $post = get_post( $post_id ); 434 435 $GLOBALS['post'] = $post; 436 437 $expected = '2016-01-21'; 438 $d = 'Y-m-d'; 439 $actual = get_the_modified_date( $d ); 440 $this->assertEquals( $expected, $actual ); 441 } 442 443 /** 444 * Test get_the_modified_date failures are filtered 445 * 446 * @ticket 37059 447 * 448 * @since 4.6.0 449 */ 450 function test_get_the_modified_date_failures_are_filtered() { 451 // Remove global post objet 452 $GLOBALS['post'] = null; 453 454 $expected = 'filtered modified date failure result'; 455 add_filter( 'get_the_modified_date', array( $this, '_filter_get_the_modified_date_failure' ) ); 456 $actual = get_the_modified_date(); 457 $this->assertEquals( $expected, $actual ); 458 remove_filter( 'get_the_modified_date', array( $this, '_filter_get_the_modified_date_failure' ) ); 459 } 460 461 function _filter_get_the_modified_date_failure( $the_date ) { 462 $expected = false; 463 $actual = $the_date; 464 $this->assertEquals( $expected, $actual ); 465 466 if ( false === $the_date ) { 467 return 'filtered modified date failure result'; 468 } 469 return $the_date; 470 } 471 472 /** 373 473 * Test get_the_modified_time with post_id parameter. 374 474 *
Note: See TracChangeset
for help on using the changeset viewer.