From 04dc28af1c48aa07745a8be688b52a8795c054b8 Mon Sep 17 00:00:00 2001 From: Antoine M Date: Fri, 24 Nov 2023 13:41:36 +0100 Subject: [PATCH] handling erro case when no $thematique of get the term for admin classes --- includes/admin.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/includes/admin.php b/includes/admin.php index f4d2140..272c066 100644 --- a/includes/admin.php +++ b/includes/admin.php @@ -267,9 +267,11 @@ function wpdocs_admin_classes($classes) global $post; $thematique = get_the_terms(get_the_ID(), 'thematiques')[0] ?? null; + if (!$thematique) return $classes; + $thematiqueParent = getParentThematique($thematique); - $thematiqueColorSlug = getThematiqueFamilySlug($thematiqueParent->slug) ?? null; - $postType = get_post_type($post->ID); + $thematiqueColorSlug = getThematiqueFamilySlug($thematiqueParent->slug); + $postType = get_post_type($post->ID) ?? null; if (in_array($pagenow, array('post.php', 'post-new.php'), true) && $thematiqueColorSlug && ($postType == 'conseils' || $postType == 'questions')) { $classes .= ' ' . $thematiqueParent->slug;