theme'] = $siteThemeSettings['color']['palette']['theme']; } return $emailEditorThemeSettings; } public function getStylesheetFromContext($context, $options = []): string { return function_exists('gutenberg_style_engine_get_stylesheet_from_context') ? gutenberg_style_engine_get_stylesheet_from_context($context, $options) : wp_style_engine_get_stylesheet_from_context($context, $options); } public function getStylesheetForRendering($post = null, $template = null): string { $emailThemeSettings = $this->getSettings(); $cssPresets = ''; // Font family classes foreach ($emailThemeSettings['typography']['fontFamilies']['default'] as $fontFamily) { $cssPresets .= ".has-{$fontFamily['slug']}-font-family { font-family: {$fontFamily['fontFamily']}; } \n"; } // Font size classes foreach ($emailThemeSettings['typography']['fontSizes']['default'] as $fontSize) { $cssPresets .= ".has-{$fontSize['slug']}-font-size { font-size: {$fontSize['size']}; } \n"; } // Color palette classes $colorDefinitions = array_merge($emailThemeSettings['color']['palette']['theme'], $emailThemeSettings['color']['palette']['default']); foreach ($colorDefinitions as $color) { $cssPresets .= ".has-{$color['slug']}-color { color: {$color['color']}; } \n"; $cssPresets .= ".has-{$color['slug']}-background-color { background-color: {$color['color']}; } \n"; $cssPresets .= ".has-{$color['slug']}-border-color { border-color: {$color['color']}; } \n"; } // Block specific styles $cssBlocks = ''; $blocks = $this->getTheme()->get_styles_block_nodes(); foreach ($blocks as $blockMetadata) { $cssBlocks .= $this->getTheme()->get_styles_for_block($blockMetadata); } // Element specific styles $elementsStyles = $this->getTheme()->get_raw_data()['styles']['elements'] ?? []; // Because the section styles is not a part of the output the `get_styles_block_nodes` method, we need to get it separately if ($template && $template->wp_id) { // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps $templateTheme = (array)get_post_meta($template->wp_id, 'mailpoet_email_theme', true); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps $templateStyles = (array)($templateTheme['styles'] ?? []); $templateElements = $templateStyles['elements'] ?? []; $elementsStyles = array_replace_recursive((array)$elementsStyles, (array)$templateElements); } if ($post) { $postTheme = (array)get_post_meta($post->ID, 'mailpoet_email_theme', true); $postStyles = (array)($postTheme['styles'] ?? []); $postElements = $postStyles['elements'] ?? []; $elementsStyles = array_replace_recursive((array)$elementsStyles, (array)$postElements); } $cssElements = ''; foreach ($elementsStyles as $key => $elementsStyle) { $selector = $key; if ($key === 'button') { $selector = '.wp-block-button'; $cssElements .= wp_style_engine_get_styles($elementsStyle, ['selector' => '.wp-block-button'])['css']; // Add color to link element. $cssElements .= wp_style_engine_get_styles(['color' => ['text' => $elementsStyle['color']['text'] ?? '']], ['selector' => '.wp-block-button a'])['css']; continue; } switch ($key) { case 'heading': $selector = 'h1, h2, h3, h4, h5, h6'; break; case 'link': $selector = 'a:not(.button-link)'; break; } $cssElements .= wp_style_engine_get_styles($elementsStyle, ['selector' => $selector])['css']; } $result = $cssPresets . $cssBlocks . $cssElements; // Because font-size can by defined by the clamp() function that is not supported in the e-mail clients, we need to replace it to the value. // Regular expression to match clamp() function and capture its max value $pattern = '/clamp\([^,]+,\s*[^,]+,\s*([^)]+)\)/'; // Replace clamp() with its maximum value $result = (string)preg_replace($pattern, '$1', $result); return $result; } public function translateSlugToFontSize(string $fontSize): string { $settings = $this->getSettings(); foreach ($settings['typography']['fontSizes']['default'] as $fontSizeDefinition) { if ($fontSizeDefinition['slug'] === $fontSize) { return $fontSizeDefinition['size']; } } return $fontSize; } public function translateSlugToColor(string $colorSlug): string { $settings = $this->getSettings(); $colorDefinitions = array_merge($settings['color']['palette']['theme'], $settings['color']['palette']['default']); foreach ($colorDefinitions as $colorDefinition) { if ($colorDefinition['slug'] === $colorSlug) { return strtolower($colorDefinition['color']); } } return $colorSlug; } public function getVariablesValuesMap(): array { $variablesCss = $this->getTheme()->get_stylesheet(['variables']); $map = []; // Regular expression to match CSS variable definitions $pattern = '/--(.*?):\s*(.*?);/'; if (preg_match_all($pattern, $variablesCss, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { // '--' . $match[1] is the variable name, $match[2] is the variable value $map['--' . $match[1]] = $match[2]; } } return $map; } }
Fatal error: Uncaught Error: Class "MailPoet\EmailEditor\Engine\ThemeController" not found in /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php:3406 Stack trace: #0 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(3376): MailPoetGenerated\FreeCachedContainer->getSettingsControllerService() #1 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(3386): MailPoetGenerated\FreeCachedContainer->getTypographyPreprocessorService() #2 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(3316): MailPoetGenerated\FreeCachedContainer->getProcessManagerService() #3 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(3396): MailPoetGenerated\FreeCachedContainer->getContentRendererService() #4 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(4031): MailPoetGenerated\FreeCachedContainer->getRenderer2Service() #5 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(5088): MailPoetGenerated\FreeCachedContainer->getRenderer6Service() #6 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(5098): MailPoetGenerated\FreeCachedContainer->getConfirmationEmailCustomizerService() #7 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(5198): MailPoetGenerated\FreeCachedContainer->getConfirmationEmailMailerService() #8 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(5368): MailPoetGenerated\FreeCachedContainer->getSubscriberActionsService() #9 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(2612): MailPoetGenerated\FreeCachedContainer->getCommentService() #10 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(2640): MailPoetGenerated\FreeCachedContainer->getHooks2Service() #11 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/symfony/dependency-injection/Container.php(122): MailPoetGenerated\FreeCachedContainer->getInitializerService() #12 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/symfony/dependency-injection/Container.php(110): MailPoetVendor\Symfony\Component\DependencyInjection\Container->make('MailPoet\\Config...', 1) #13 /htdocs/wp-content/plugins/mailpoet/lib/DI/ContainerWrapper.php(39): MailPoetVendor\Symfony\Component\DependencyInjection\Container->get('MailPoet\\Config...') #14 /htdocs/wp-content/plugins/mailpoet/mailpoet_initializer.php(89): MailPoet\DI\ContainerWrapper->get('MailPoet\\Config...') #15 /htdocs/wp-content/plugins/mailpoet/mailpoet.php(194): require_once('/htdocs/wp-cont...') #16 /htdocs/wp-settings.php(526): include_once('/htdocs/wp-cont...') #17 /htdocs/wp-config.php(85): require_once('/htdocs/wp-sett...') #18 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #19 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #20 /htdocs/index.php(17): require('/htdocs/wp-blog...') #21 {main} thrown in /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php on line 3406