Changeset 54244
- Timestamp:
- 09/20/2022 04:29:11 AM (2 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/post.php
r54122 r54244 1400 1400 $original_date = $post->post_date; 1401 1401 $original_name = $post->post_name; 1402 $original_filter = $post->filter; 1402 1403 1403 1404 // Hack: get_permalink() would return plain permalink for drafts, so we will fake that our post is published. … … 1444 1445 $post->post_date = $original_date; 1445 1446 $post->post_name = $original_name; 1446 unset( $post->filter );1447 $post->filter = $original_filter; 1447 1448 1448 1449 /** -
trunk/tests/phpunit/tests/admin/includesPost.php
r54122 r54244 685 685 $this->assertSame( home_url() . '/parent-page/%pagename%/', $actual[0] ); 686 686 $this->assertSame( 'child-page', $actual[1] ); 687 } 688 689 /** 690 * Tests that get_sample_permalink() preserves the original WP_Post properties. 691 * 692 * @ticket 54736 693 * 694 * @covers ::get_sample_permalink 695 */ 696 public function test_get_sample_permalink_should_preserve_the_original_post_properties() { 697 $post = self::factory()->post->create_and_get( 698 array( 699 'post_status' => 'draft', 700 ) 701 ); 702 703 $post_original = clone $post; 704 705 add_filter( 706 'get_sample_permalink', 707 function( $permalink, $post_id, $title, $name, $post ) use ( $post_original ) { 708 $this->assertEquals( $post_original, $post, 'Modified post object passed to get_sample_permalink filter.' ); 709 return $permalink; 710 }, 711 10, 712 5 713 ); 714 715 get_sample_permalink( $post ); 716 $this->assertEquals( $post_original, $post, 'get_sample_permalink() modifies the post object.' ); 687 717 } 688 718
Note: See TracChangeset
for help on using the changeset viewer.