WordPress.org

Make WordPress Core

Changeset 38145


Ignore:
Timestamp:
07/23/16 10:04:20 (17 months ago)
Author:
SergeyBiryukov
Message:

Permalinks: In get_page_uri(), don't prepend a parent page slug if it's empty.

Props inderpreet99, SergeyBiryukov.
Fixes #36174.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r38125 r38145  
    43344334    foreach ( $page->ancestors as $parent ) { 
    43354335        $parent = get_post( $parent ); 
    4336         if ( $parent ) { 
     4336        if ( $parent && $parent->post_name ) { 
    43374337            $uri = $parent->post_name . '/' . $uri; 
    43384338        } 
  • trunk/tests/phpunit/tests/post/getPageUri.php

    r38144 r38145  
    4848 
    4949    /** 
     50     * @ticket 36174 
     51     */ 
     52    function test_get_page_uri_with_a_draft_parent_with_empty_slug() { 
     53        $parent_id = self::factory()->post->create( array( 'post_name' => 'parent' ) ); 
     54        $child_id = self::factory()->post->create( array( 'post_name' => 'child', 'post_parent' => $parent_id ) ); 
     55 
     56        wp_update_post( array( 'ID' => $parent_id, 'post_name' => '', 'post_status' => 'draft' ) ); 
     57 
     58        $this->assertEquals( 'child', get_page_uri( $child_id ) ); 
     59    } 
     60 
     61    /** 
    5062     * @ticket 26284 
    5163     */ 
Note: See TracChangeset for help on using the changeset viewer.