From 1fab8a31f37e04f2252192abcf85f23161dcdf7f Mon Sep 17 00:00:00 2001 From: Rostislav Wolny Date: Mon, 6 May 2024 14:04:04 +0200 Subject: [PATCH] Ensure the template theme is always an object. Sending it as an empty array was causing that deepmerge in emailCss hook was returning null. It was happening for the general-email template which has no theme file [MAILPOET-5641] --- mailpoet/lib/EmailEditor/Engine/Templates/Templates.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mailpoet/lib/EmailEditor/Engine/Templates/Templates.php b/mailpoet/lib/EmailEditor/Engine/Templates/Templates.php index 398ae5f606..03fa2db544 100644 --- a/mailpoet/lib/EmailEditor/Engine/Templates/Templates.php +++ b/mailpoet/lib/EmailEditor/Engine/Templates/Templates.php @@ -12,6 +12,7 @@ use WP_Error; // phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps class Templates { const MAILPOET_EMAIL_META_THEME_TYPE = 'mailpoet_email_theme'; + const MAILPOET_TEMPLATE_EMPTY_THEME = ['version' => 2]; // The version 2 is important to merge themes correctly private string $templateDirectory; private string $pluginSlug; @@ -95,7 +96,7 @@ class Templates { } } - return $this->themeJson[$templateSlug] ?? []; + return $this->themeJson[$templateSlug] ?? self::MAILPOET_TEMPLATE_EMPTY_THEME; } public function getBlockFileTemplate($return, $templateId, $template_type) { @@ -261,7 +262,7 @@ class Templates { ], 'single' => true, 'type' => 'object', - 'default' => ['version' => 2], // The version 2 is important to merge themes correctly + 'default' => self::MAILPOET_TEMPLATE_EMPTY_THEME, ] );