Pages: get_page_uri()
should return the URI at which the resource being accessed is available at, this may include non-'publish' status posts.
Reverts [34001] and fixes the original issue in #15963 - avoiding a PHP Notice for when the post doesn't exist. Props tharsheblows. See #15963. Fixes #35084. git-svn-id: https://develop.svn.wordpress.org/trunk@36094 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
1fdddd302e
commit
1d2904bf2a
@ -4300,7 +4300,7 @@ function get_page_uri( $page ) {
|
||||
|
||||
foreach ( $page->ancestors as $parent ) {
|
||||
$parent = get_post( $parent );
|
||||
if ( 'publish' === $parent->post_status ) {
|
||||
if ( $parent ) {
|
||||
$uri = $parent->post_name . '/' . $uri;
|
||||
}
|
||||
}
|
||||
|
@ -674,8 +674,8 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
// try the child normally
|
||||
$this->assertEquals( 'parent/child', get_page_uri( $child_id ) );
|
||||
|
||||
// now delete the parent and check
|
||||
wp_delete_post( $parent_id );
|
||||
// now delete the parent from the database and check
|
||||
wp_delete_post( $parent_id, true );
|
||||
$this->assertEquals( 'child', get_page_uri( $child_id ) );
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user