From 337df6ce3ad091bfd6da1556fabd4b87fe0a1c6d Mon Sep 17 00:00:00 2001 From: Tom Anderson Date: Sun, 16 Aug 2020 12:07:36 +0930 Subject: [PATCH] Check if $post defined before trying to use its field values. Admin pages (e.g. in a custom plugin) may see $post as undefined. The existing usage to get permalinks for these pages can fill debug logs with PHP Notices. --- CRM/Utils/System/WordPress.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CRM/Utils/System/WordPress.php b/CRM/Utils/System/WordPress.php index 1e3aaac78e..f3691eff7c 100644 --- a/CRM/Utils/System/WordPress.php +++ b/CRM/Utils/System/WordPress.php @@ -319,9 +319,9 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { if ($config->userFrameworkFrontend) { global $post; if (get_option('permalink_structure') != '') { - $script = get_permalink($post->ID); + $script = $post ? get_permalink($post->ID) : ""; } - if ($config->wpBasePage == $post->post_name) { + if ($post && $config->wpBasePage == $post->post_name) { $basepage = TRUE; } // when shortcode is included in page -- 2.25.1