From 5048f42a19beee5aac6efa7caa383536f6c990b8 Mon Sep 17 00:00:00 2001 From: Lee Maguire Date: Fri, 19 Dec 2025 16:36:03 +0000 Subject: [PATCH] Check array exists before using it ``` PHP Warning: Undefined array key 2 in /var/www/html/wp-content/plugins/long-read-plugin/src/InPageNavigation.php on line 16 ``` --- src/InPageNavigation.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/InPageNavigation.php b/src/InPageNavigation.php index d2ba1bb..92fe879 100644 --- a/src/InPageNavigation.php +++ b/src/InPageNavigation.php @@ -11,9 +11,10 @@ private function parseHeading(string $html): object { $matches = []; preg_match('/(id=")(.*?)"/', $html, $matches); + $tmp_id = (isset($matches[2])) ? $matches[2] : ''; return (object) [ 'title' => trim(strip_tags($html)), - 'id' => $matches[2] + 'id' => $tmp_id ]; }