From c02ec30048ef8c446649ca0229be7a9473dcb653 Mon Sep 17 00:00:00 2001 From: Sebastian Thulin Date: Fri, 1 Mar 2024 08:48:53 +0100 Subject: [PATCH] fix: do not throw warnings on undefined post_types --- source/php/Form.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/php/Form.php b/source/php/Form.php index ff6b2ab..0205003 100644 --- a/source/php/Form.php +++ b/source/php/Form.php @@ -19,12 +19,16 @@ public function appendForm() { global $post; + if(!is_a($post, 'WP_Post')) { + return; + } + $allowedPostTypes = apply_filters('CustomerFeedback/post_types', get_field('customer_feedback_posttypes', 'option')); if (is_null($allowedPostTypes)) { $allowedPostTypes = array('page'); } - if (!is_array($allowedPostTypes) || !in_array($post->post_type, $allowedPostTypes)) { + if (!is_array($allowedPostTypes) || !in_array($post->post_type ?? null, $allowedPostTypes)) { return; }