From b9b57cc5748cacf4570ebfbab693c140a00a4f6b Mon Sep 17 00:00:00 2001 From: Rostislav Wolny Date: Tue, 16 Jan 2024 16:51:00 +0100 Subject: [PATCH] Refactor getSettings to work with the mered theme The method was loading both themes separately. This commit changes the behavior so that it uses only the email theme which contains also the core theme settings. Instead of modifying the core theme settings in PHP we can now move these settings into the email editor theme, which is merged into the core theme. [MAILPOET-5740] --- .../lib/EmailEditor/Engine/SettingsController.php | 15 ++------------- mailpoet/lib/EmailEditor/Engine/theme.json | 7 +++++++ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/mailpoet/lib/EmailEditor/Engine/SettingsController.php b/mailpoet/lib/EmailEditor/Engine/SettingsController.php index 5e2e079b00..3f7b032784 100644 --- a/mailpoet/lib/EmailEditor/Engine/SettingsController.php +++ b/mailpoet/lib/EmailEditor/Engine/SettingsController.php @@ -60,19 +60,8 @@ class SettingsController { public function getSettings(): array { $coreDefaultSettings = get_default_block_editor_settings(); - $coreThemeData = \WP_Theme_JSON_Resolver::get_core_data(); - $coreSettings = $coreThemeData->get_settings(); - - // Email Editor Theme $editorTheme = $this->getTheme(); - - // Enable custom spacing - $coreSettings['spacing']['units'] = ['px']; - $coreSettings['spacing']['padding'] = true; - // Typography - $coreSettings['typography']['dropCap'] = false; // Showing large initial letter cannot be implemented in emails - $coreSettings['typography']['fontWeight'] = false; // Font weight will be handled by the font family later - $coreSettings['typography']['fontFamilies']['default'] = $editorTheme->get_data()['settings']['typography']['fontFamilies']; + $themeSettings = $editorTheme->get_settings(); // body selector is later transformed to .editor-styles-wrapper // setting padding for bottom and top is needed because \WP_Theme_JSON::get_stylesheet() set them only for .wp-site-blocks selector @@ -94,7 +83,7 @@ class SettingsController { ['css' => $flexEmailLayoutStyles], ]; - $settings['__experimentalFeatures'] = $coreSettings; + $settings['__experimentalFeatures'] = $themeSettings; // Enable border radius, color, style and width where possible $settings['__experimentalFeatures']['border'] = [ "radius" => true, diff --git a/mailpoet/lib/EmailEditor/Engine/theme.json b/mailpoet/lib/EmailEditor/Engine/theme.json index c00de3375b..60010a4eed 100644 --- a/mailpoet/lib/EmailEditor/Engine/theme.json +++ b/mailpoet/lib/EmailEditor/Engine/theme.json @@ -5,7 +5,14 @@ "layout": { "contentSize": "660px" }, + "spacing": { + "units": ["px"], + "padding": true, + "margin": false + }, "typography": { + "dropCap": false, + "fontWeight": false, "fontFamilies": [ { "name": "Arial",