From 26ce4c7e17b9638116f5667656ef47cac4faa5a7 Mon Sep 17 00:00:00 2001 From: Tom Zwiers Date: Mon, 22 Jul 2024 09:38:17 +0200 Subject: [PATCH 1/2] Undefined array key error when viewing pages in admin panel --- class-simple-page-ordering.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/class-simple-page-ordering.php b/class-simple-page-ordering.php index db816a5..81dcc9a 100644 --- a/class-simple-page-ordering.php +++ b/class-simple-page-ordering.php @@ -435,10 +435,14 @@ public static function page_row_actions( $actions, $post ) { // Get the relevant siblings. if ( 0 === $post->post_parent ) { - $siblings = $top_level_pages; - } else { - $siblings = $children_pages[ $post->post_parent ]; - } + $siblings = $top_level_pages; + } else { + if (isset($children_pages[$post->post_parent])) { + $siblings = $children_pages[$post->post_parent]; + } else { + $siblings = []; + } + } // Assume no sibling. $sibling = 0; From 642c02a2e5a75f69ec0d7c0b5ffdb43b59742f11 Mon Sep 17 00:00:00 2001 From: Tom Zwiers Date: Tue, 23 Jul 2024 14:15:50 +0200 Subject: [PATCH 2/2] Cleaning up code --- class-simple-page-ordering.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/class-simple-page-ordering.php b/class-simple-page-ordering.php index 81dcc9a..8098e2d 100644 --- a/class-simple-page-ordering.php +++ b/class-simple-page-ordering.php @@ -435,14 +435,10 @@ public static function page_row_actions( $actions, $post ) { // Get the relevant siblings. if ( 0 === $post->post_parent ) { - $siblings = $top_level_pages; - } else { - if (isset($children_pages[$post->post_parent])) { - $siblings = $children_pages[$post->post_parent]; - } else { - $siblings = []; - } - } + $siblings = $top_level_pages; + } else { + $siblings = $children_pages[ $post->post_parent ] ?? []; + } // Assume no sibling. $sibling = 0;