mirror of
git://develop.git.wordpress.org/
synced 2025-02-24 08:33:35 +01:00
Permalinks: Ensure the page hierarchy is correct for sample permalinks.
Fixes #35368. git-svn-id: https://develop.svn.wordpress.org/trunk@36253 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
28818255c2
commit
519051b305
@ -4291,7 +4291,9 @@ function _page_traverse_name( $page_id, &$children, &$result ){
|
||||
* @return string|false Page URI, false on error.
|
||||
*/
|
||||
function get_page_uri( $page ) {
|
||||
$page = get_post( $page );
|
||||
if ( ! $page instanceof WP_Post ) {
|
||||
$page = get_post( $page );
|
||||
}
|
||||
|
||||
if ( ! $page )
|
||||
return false;
|
||||
|
@ -454,6 +454,29 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
$this->assertEquals( '30', $found[1] );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 35368
|
||||
*/
|
||||
public function test_get_sample_permalink_should_respect_hierarchy_of_draft_pages() {
|
||||
$this->set_permalink_structure( '/%postname%/' );
|
||||
|
||||
$parent = self::factory()->post->create( array(
|
||||
'post_type' => 'page',
|
||||
'post_title' => 'Parent Page',
|
||||
) );
|
||||
|
||||
$child = self::factory()->post->create( array(
|
||||
'post_type' => 'page',
|
||||
'post_title' => 'Child Page',
|
||||
'post_parent' => $parent,
|
||||
'post_status' => 'draft',
|
||||
) );
|
||||
|
||||
$actual = get_sample_permalink( $child );
|
||||
$this->assertSame( home_url() . '/parent-page/%pagename%/', $actual[0] );
|
||||
$this->assertSame( 'child-page', $actual[1] );
|
||||
}
|
||||
|
||||
public function test_post_exists_should_match_title() {
|
||||
$p = self::factory()->post->create( array(
|
||||
'post_title' => 'Foo Bar',
|
||||
|
Loading…
x
Reference in New Issue
Block a user