Ticket #35084: 35084.3.diff
File 35084.3.diff, 2.0 KB (added by , 7 years ago) |
---|
-
src/wp-includes/post.php
4286 4286 * Sub pages will be in the "directory" under the parent page post name. 4287 4287 * 4288 4288 * @since 1.5.0 4289 * @since 4.4.0 Do not add parent slugs to orphaned pages 4290 * @since 4.4.1 Support custom post statuses 4289 4291 * 4290 4292 * @param WP_Post|object|int $page Page object or page ID. 4291 4293 * @return string|false Page URI, false on error. … … 4300 4302 4301 4303 foreach ( $page->ancestors as $parent ) { 4302 4304 $parent = get_post( $parent ); 4303 if ( 'publish' === $parent->post_status ){4305 if ( ! in_array( $parent->post_status, get_post_stati( array( 'internal' => true ) ) ) ){ 4304 4306 $uri = $parent->post_name . '/' . $uri; 4305 4307 } 4306 4308 } -
tests/phpunit/tests/post.php
680 680 } 681 681 682 682 /** 683 * @ticket 35084 684 */ 685 function test_get_post_uri_check_ancestor_post_status() { 686 687 $post_statuses = get_post_stati( array(), 'objects' ); 688 689 foreach( $post_statuses as $index => $post_status ){ 690 $parent_id = self::factory()->post->create( array( 'post_name' => 'parent_' . $index, 'post_status' => $post_status->name ) ); 691 $child_id = self::factory()->post->create( array( 'post_name' => 'child_' . $index, 'post_parent' => $parent_id ) ); 692 693 // check the parent for good measure 694 $this->assertEquals( 'parent_' . $index, get_page_uri( $parent_id ) ); 695 696 // if the parent's post status is not an internal post status, it should be in the uri 697 if( ! ( $post_status->internal ) ){ 698 $this->assertEquals( 'parent_' . $index . '/child_' . $index, get_page_uri( $child_id ) ); 699 } 700 else{ 701 $this->assertEquals( 'child_' . $index, get_page_uri( $child_id ) ); 702 } 703 } 704 } 705 706 /** 683 707 * @ticket 23708 684 708 */ 685 709 function test_get_post_ancestors_within_loop() {