From e5c4f674b2061f4d58d827eec983bdb9afd24fdc Mon Sep 17 00:00:00 2001 From: shapeyourbits Date: Wed, 1 Feb 2023 01:21:38 +0000 Subject: [PATCH] Fixing the Uncaught TypeError in ListingRepository.php when using PHP 8 Uncaught TypeError: Cannot access offset of type string on string in /wp-content/plugins/wp-nested-pages/app/Entities/Listing/ListingRepository.php --- app/Entities/Listing/ListingRepository.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Entities/Listing/ListingRepository.php b/app/Entities/Listing/ListingRepository.php index 5e782ea..b3ae9aa 100644 --- a/app/Entities/Listing/ListingRepository.php +++ b/app/Entities/Listing/ListingRepository.php @@ -37,7 +37,10 @@ public function visiblePages($post_type) $meta = get_user_meta(get_current_user_id(), 'np_visible_posts', true); if ( $meta == '1' ) return []; $visible = unserialize($meta); - if ( !$visible || !isset($visible[$post_type]) ) $visible[$post_type] = []; + if ( !$visible || !isset($visible[$post_type]) ) { + $visible= array(); + $visible[$post_type] = []; + } return $visible[$post_type]; } @@ -182,4 +185,4 @@ public function showLinks($post_type, $user) ? true : false; return apply_filters('nestedpages_show_links', $show_links, $post_type, $user, $this); } -} \ No newline at end of file +}