Improve getTheme to return merged core theme + email theme

The idea is that the core theme is a base and we add email-specific
modifications on top of and create a core email theme.
[MAILPOET-5740]
This commit is contained in:
Rostislav Wolny
2024-01-16 16:29:10 +01:00
committed by Jan Lysý
parent 0e04a892c2
commit 55dd1d0ab0

View File

@ -184,10 +184,12 @@ class SettingsController {
} }
public function getTheme(): \WP_Theme_JSON { public function getTheme(): \WP_Theme_JSON {
$coreThemeData = \WP_Theme_JSON_Resolver::get_core_data();
$themeJson = (string)file_get_contents(dirname(__FILE__) . '/theme.json'); $themeJson = (string)file_get_contents(dirname(__FILE__) . '/theme.json');
$themeJson = json_decode($themeJson, true); $themeJson = json_decode($themeJson, true);
/** @var array $themeJson */ /** @var array $themeJson */
return new \WP_Theme_JSON($themeJson); $coreThemeData->merge(new \WP_Theme_JSON($themeJson, 'default'));
return $coreThemeData;
} }
public function getStylesheetForRendering(): string { public function getStylesheetForRendering(): string {
@ -195,7 +197,7 @@ class SettingsController {
$emailThemeSettings = $this->getTheme()->get_settings(); $emailThemeSettings = $this->getTheme()->get_settings();
$css = ''; $css = '';
// Font family classes // Font family classes
foreach ($emailThemeSettings['typography']['fontFamilies']['theme'] as $fontFamily) { foreach ($emailThemeSettings['typography']['fontFamilies']['default'] as $fontFamily) {
$css .= ".has-{$fontFamily['slug']}-font-family { font-family: {$fontFamily['fontFamily']}; } \n"; $css .= ".has-{$fontFamily['slug']}-font-family { font-family: {$fontFamily['fontFamily']}; } \n";
} }
// Font size classes // Font size classes