From 47ef18f71357b9f228a86bc859dc5f69d6460e79 Mon Sep 17 00:00:00 2001 From: Himanshu Pathak Date: Tue, 10 Feb 2026 18:23:13 +0530 Subject: [PATCH 1/9] Meta Boxes: Include post status options in page attributes meta box --- src/wp-admin/includes/meta-boxes.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wp-admin/includes/meta-boxes.php b/src/wp-admin/includes/meta-boxes.php index 506b38b3b9af0..835c2404c49aa 100644 --- a/src/wp-admin/includes/meta-boxes.php +++ b/src/wp-admin/includes/meta-boxes.php @@ -1010,6 +1010,7 @@ function page_attributes_meta_box( $post ) { 'show_option_none' => __( '(no parent)' ), 'sort_column' => 'menu_order, post_title', 'echo' => 0, + 'post_status' => array( 'publish', 'draft', 'pending', 'private' ), ); /** From 2fbbd8021f503f831925c9099eb67cf8e6e4b430 Mon Sep 17 00:00:00 2001 From: Himanshu Pathak Date: Tue, 10 Feb 2026 18:23:51 +0530 Subject: [PATCH 2/9] Fix: Handle case where page is orphan --- src/wp-includes/post.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index 4382aa003ff62..7bba8cbc4660e 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -6268,6 +6268,11 @@ function get_page_children( $page_id, $pages ) { } } + if ( 0 === $page_id ) { + $parent_ids = array_keys( $children ); + $page_ids = wp_list_pluck( $pages, 'ID' ); + } + return $page_list; } From 841e37cc63d6cccc73e24e2aa528cab536428e20 Mon Sep 17 00:00:00 2001 From: Himanshu Pathak Date: Tue, 10 Feb 2026 18:24:10 +0530 Subject: [PATCH 3/9] Fix: Handle orphan pages in get_page_children function --- src/wp-includes/post.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index 7bba8cbc4660e..fee42a9b1355f 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -6271,6 +6271,18 @@ function get_page_children( $page_id, $pages ) { if ( 0 === $page_id ) { $parent_ids = array_keys( $children ); $page_ids = wp_list_pluck( $pages, 'ID' ); + + foreach ( $parent_ids as $parent_id ) { + if ( 0 !== $parent_id && ! in_array( $parent_id, $page_ids, true ) ) { + foreach ( $children[ $parent_id ] as $orphan ) { + $page_list[] = $orphan; + if ( isset( $children[ $orphan->ID ] ) ) { + $orphan_pages = get_page_children( $orphan->ID, $pages ); + $page_list = array_merge( $page_list, $orphan_pages ); + } + } + } + } } return $page_list; From cd1a99ce8e32d1268f135b10b26e0b1e61687fa4 Mon Sep 17 00:00:00 2001 From: Himanshu Pathak Date: Tue, 10 Feb 2026 18:25:05 +0530 Subject: [PATCH 4/9] Lint: Fix linting --- src/wp-includes/post.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index fee42a9b1355f..68e79e5c01151 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -6271,14 +6271,14 @@ function get_page_children( $page_id, $pages ) { if ( 0 === $page_id ) { $parent_ids = array_keys( $children ); $page_ids = wp_list_pluck( $pages, 'ID' ); - + foreach ( $parent_ids as $parent_id ) { if ( 0 !== $parent_id && ! in_array( $parent_id, $page_ids, true ) ) { foreach ( $children[ $parent_id ] as $orphan ) { $page_list[] = $orphan; if ( isset( $children[ $orphan->ID ] ) ) { $orphan_pages = get_page_children( $orphan->ID, $pages ); - $page_list = array_merge( $page_list, $orphan_pages ); + $page_list = array_merge( $page_list, $orphan_pages ); } } } From c853a6a5ecf56b8c31fadf781996f269b7121b3b Mon Sep 17 00:00:00 2001 From: Himanshu Pathak Date: Tue, 10 Feb 2026 18:26:36 +0530 Subject: [PATCH 5/9] Test: Ensure published child pages remain selectable when parent is trashed --- tests/phpunit/tests/post/wpDropdownPages.php | 29 ++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/phpunit/tests/post/wpDropdownPages.php b/tests/phpunit/tests/post/wpDropdownPages.php index d838875f1d315..444c1dc64c699 100644 --- a/tests/phpunit/tests/post/wpDropdownPages.php +++ b/tests/phpunit/tests/post/wpDropdownPages.php @@ -219,4 +219,33 @@ public function test_wp_dropdown_pages_should_obey_class_parameter() { $this->assertMatchesRegularExpression( '/]+class=\'bar\'/', $found ); } + + /** + * Test that published child pages remain selectable when parent is trashed. + * + * @ticket 11235 + */ + public function test_child_page_available_when_parent_trashed() { + $parent_id = self::factory()->post->create( + array( + 'post_type' => 'page', + 'post_status' => 'publish', + ) + ); + + $child_id = self::factory()->post->create( + array( + 'post_type' => 'page', + 'post_parent' => $parent_id, + 'post_status' => 'publish', + ) + ); + + wp_trash_post( $parent_id ); + + $output = wp_dropdown_pages( array( 'echo' => 0 ) ); + + $this->assertStringContainsString( 'value="' . $child_id . '"', $output, 'Published child page should remain available even when parent is trashed.' ); + $this->assertStringNotContainsString( 'value="' . $parent_id . '"', $output, 'Trashed parent should not appear in dropdown.' ); + } } From c55fb0d1d085cc09b6cbf80e14b18c1ce9ffdf88 Mon Sep 17 00:00:00 2001 From: Himanshu Pathak Date: Tue, 10 Feb 2026 18:26:52 +0530 Subject: [PATCH 6/9] Test: Ensure published child pages remain selectable when parent is draft or pending --- tests/phpunit/tests/post/wpDropdownPages.php | 32 ++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/phpunit/tests/post/wpDropdownPages.php b/tests/phpunit/tests/post/wpDropdownPages.php index 444c1dc64c699..c8ec65633ee85 100644 --- a/tests/phpunit/tests/post/wpDropdownPages.php +++ b/tests/phpunit/tests/post/wpDropdownPages.php @@ -248,4 +248,36 @@ public function test_child_page_available_when_parent_trashed() { $this->assertStringContainsString( 'value="' . $child_id . '"', $output, 'Published child page should remain available even when parent is trashed.' ); $this->assertStringNotContainsString( 'value="' . $parent_id . '"', $output, 'Trashed parent should not appear in dropdown.' ); } + + /** + * Test that published child pages remain selectable when parent is draft or pending. + * + * @ticket 11235 + */ + public function test_child_page_available_when_parent_not_published() { + $parent_id = self::factory()->post->create( + array( + 'post_type' => 'page', + 'post_status' => 'publish', + ) + ); + + $child_id = self::factory()->post->create( + array( + 'post_type' => 'page', + 'post_parent' => $parent_id, + 'post_status' => 'publish', + ) + ); + + wp_update_post( + array( + 'ID' => $parent_id, + 'post_status' => 'draft', + ) + ); + + $output = wp_dropdown_pages( array( 'echo' => 0 ) ); + $this->assertStringContainsString( 'value="' . $child_id . '"', $output, 'Published child should be available when parent is draft.' ); + } } From 315d9d88d42a611d53dc9004d350001de1278404 Mon Sep 17 00:00:00 2001 From: Himanshu Pathak Date: Tue, 10 Feb 2026 18:27:26 +0530 Subject: [PATCH 7/9] Lint: Fix lintign --- tests/phpunit/tests/post/wpDropdownPages.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/post/wpDropdownPages.php b/tests/phpunit/tests/post/wpDropdownPages.php index c8ec65633ee85..3415cac085eb6 100644 --- a/tests/phpunit/tests/post/wpDropdownPages.php +++ b/tests/phpunit/tests/post/wpDropdownPages.php @@ -244,7 +244,7 @@ public function test_child_page_available_when_parent_trashed() { wp_trash_post( $parent_id ); $output = wp_dropdown_pages( array( 'echo' => 0 ) ); - + $this->assertStringContainsString( 'value="' . $child_id . '"', $output, 'Published child page should remain available even when parent is trashed.' ); $this->assertStringNotContainsString( 'value="' . $parent_id . '"', $output, 'Trashed parent should not appear in dropdown.' ); } From 72d68ec3976b15d81525de6cd76cd2632b3eea94 Mon Sep 17 00:00:00 2001 From: Himanshu Pathak Date: Tue, 10 Feb 2026 18:44:37 +0530 Subject: [PATCH 8/9] Dummy commit to trigger tests --- tests/phpunit/tests/post/wpDropdownPages.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/phpunit/tests/post/wpDropdownPages.php b/tests/phpunit/tests/post/wpDropdownPages.php index 3415cac085eb6..96fdeac3213af 100644 --- a/tests/phpunit/tests/post/wpDropdownPages.php +++ b/tests/phpunit/tests/post/wpDropdownPages.php @@ -233,6 +233,7 @@ public function test_child_page_available_when_parent_trashed() { ) ); + $child_id = self::factory()->post->create( array( 'post_type' => 'page', From 4adde328f7fdf9a3b7649e437a384dfe688322f4 Mon Sep 17 00:00:00 2001 From: Himanshu Pathak Date: Tue, 10 Feb 2026 18:44:47 +0530 Subject: [PATCH 9/9] Undo Dummy commit to trigger tests --- tests/phpunit/tests/post/wpDropdownPages.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/phpunit/tests/post/wpDropdownPages.php b/tests/phpunit/tests/post/wpDropdownPages.php index 96fdeac3213af..3415cac085eb6 100644 --- a/tests/phpunit/tests/post/wpDropdownPages.php +++ b/tests/phpunit/tests/post/wpDropdownPages.php @@ -233,7 +233,6 @@ public function test_child_page_available_when_parent_trashed() { ) ); - $child_id = self::factory()->post->create( array( 'post_type' => 'page',