PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.5
YayMail – WooCommerce Email Customizer v4.4.5
4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 All 57 releases
← All changes | src/Engine/Backend/SettingsPage.php +61 -18 4.4.2 → 4.4.5 View file →
@@ -31,14 +31,18 @@
31 31 /**
32 32 * Initialize hooks when class init
33 33 */
34 34 protected function init_hooks() {
35 - // Submenu is registered by YayCommerce AdminShell (YaymailPluginAdapter); keep hook id for enqueue/screen checks.
36 - if ( defined( 'YAYMAIL_PREFIX' ) ) {
37 - $this->yaymail_hook_surfix = 'yaycommerce_page_' . YAYMAIL_PREFIX . '-settings';
35 + // Submenu is registered by YayCommerce AdminShell; keep each platform's
36 + // settings-screen hook id (sourced from the registered platform) for the
37 + // enqueue/screen checks below.
38 + $yaymail_platform = \YayMail\Platform\PlatformRegistry::get( 'yaymail' );
39 + if ( $yaymail_platform ) {
40 + $this->yaymail_hook_surfix = $yaymail_platform->hook_suffix();
38 41 }
39 - if ( defined( 'YAYMAIL_WP_VERSION' ) ) {
40 - $this->yay_wp_hook_surfix = 'yaycommerce_page_yay-wp-email-customizer-settings';
42 + $wp_platform = \YayMail\Platform\PlatformRegistry::get( 'yaymagic-email-builder' );
43 + if ( $wp_platform ) {
44 + $this->yay_wp_hook_surfix = $wp_platform->hook_suffix();
41 45 }
42 46 add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueue_scripts' ], 30 );
43 47 add_filter( 'mce_external_plugins', [ $this, 'register_wp_editor_plugins_script' ] );
44 48
@@ -55,17 +59,30 @@
55 59 /**
56 60 * Enqueue scripts using in settings page
57 61 */
58 62 public function register_wp_editor_plugins_script( $plugin_array ) {
63 + // mce_external_plugins also runs on the frontend (e.g. Avada Live Builder
64 + // calling _WP_Editors::editor_settings() from wp_footer). get_current_screen()
65 + // is admin-only and is not defined there.
66 + if ( ! function_exists( 'get_current_screen' ) ) {
67 + return $plugin_array;
68 + }
59 69
60 - $plugin_array['advlist'] = YAYMAIL_PLUGIN_URL . 'assets/scripts/wp-editor-plugins/advlist/plugin.min.js';
61 - $plugin_array['autolink'] = YAYMAIL_PLUGIN_URL . 'assets/scripts/wp-editor-plugins/autolink/plugin.min.js';
62 - $plugin_array['searchreplace'] = YAYMAIL_PLUGIN_URL . 'assets/scripts/wp-editor-plugins/searchreplace/plugin.min.js';
63 - $plugin_array['code'] = YAYMAIL_PLUGIN_URL . 'assets/scripts/wp-editor-plugins/code/plugin.min.js';
64 - $plugin_array['visualblocks'] = YAYMAIL_PLUGIN_URL . 'assets/scripts/wp-editor-plugins/visualblocks/plugin.min.js';
65 - $plugin_array['table'] = YAYMAIL_PLUGIN_URL . 'assets/scripts/wp-editor-plugins/table/plugin.min.js';
66 - $plugin_array['insertdatetime'] = YAYMAIL_PLUGIN_URL . 'assets/scripts/wp-editor-plugins/insertdatetime/plugin.min.js';
70 + $plugin_url = YAYMAIL_PLUGIN_URL;
71 + $screen = get_current_screen();
72 + $yaymail_platform = \YayMail\Platform\PlatformRegistry::get( 'yaymail' );
73 + if ( ( ! $yaymail_platform || ! $screen || $screen->id !== $yaymail_platform->hook_suffix() ) && defined( 'YAYWP_PLUGIN_URL' ) ) {
74 + $plugin_url = YAYWP_PLUGIN_URL;
75 + }
67 76
77 + $plugin_array['advlist'] = $plugin_url . 'assets/scripts/wp-editor-plugins/advlist/plugin.min.js';
78 + $plugin_array['autolink'] = $plugin_url . 'assets/scripts/wp-editor-plugins/autolink/plugin.min.js';
79 + $plugin_array['searchreplace'] = $plugin_url . 'assets/scripts/wp-editor-plugins/searchreplace/plugin.min.js';
80 + $plugin_array['code'] = $plugin_url . 'assets/scripts/wp-editor-plugins/code/plugin.min.js';
81 + $plugin_array['visualblocks'] = $plugin_url . 'assets/scripts/wp-editor-plugins/visualblocks/plugin.min.js';
82 + $plugin_array['table'] = $plugin_url . 'assets/scripts/wp-editor-plugins/table/plugin.min.js';
83 + $plugin_array['insertdatetime'] = $plugin_url . 'assets/scripts/wp-editor-plugins/insertdatetime/plugin.min.js';
84 +
68 85 return $plugin_array;
69 86 }
70 87
71 88 public function admin_enqueue_scripts( $hook_suffix ) {
@@ -85,9 +102,10 @@
85 102 /**
86 103 * Register localize data
87 104 */
88 105 public function localize_js_vars() {
89 - $screen = get_current_screen();
106 + $screen = get_current_screen();
107 + $current_platform = \YayMail\Platform\PlatformRegistry::from_screen( $screen );
90 108 if ( $screen->id === $this->yaymail_hook_surfix ) {
91 109 $_wc_emails = wc()->mailer()->emails;
92 110
93 111 // override template base for wc emails
@@ -165,21 +183,43 @@
165 183 '"Lucida Console", Monaco, monospace',
166 184 '"Outfit", "DM Sans", sans-serif',
167 185 '"Kodchasan", system-ui, sans-serif',
168 186 '"Fraunces", serif',
187 + '"Rethink Sans","Helvetica Neue",Helvetica,Roboto,Arial,sans-serif',
169 188 ],
170 189 'social_icons' => Localize::get_social_icons_data(),
171 190 'revision_limit' => RevisionController::YAYMAIL_TEMPLATE_REVISION_LIMIT,
172 - 'global_headers_footers' => Localize::get_global_headers_footers(),
191 + // Two compiled JS bundles still read global_headers_footers as a single
192 + // legacy { global_header_elements, global_footer_elements } object rather
193 + // than the per-language array Localize::get_global_headers_footers()
194 + // returns: (1) the "yaymagic-email-builder" (WP core mail) bundle -- confirmed
195 + // byte-identical to the free "yaymail" lite bundle, it never received the
196 + // multi-language upgrade -- and (2) the "yaymail" lite bundle itself when
197 + // YAYMAIL_LITE_LEGACY_GHF_SHAPE is set. The paid yaymail-pro /
198 + // email-customizer-for-woocommerce variants already expect the array.
199 + // Feeding the array shape to a legacy bundle leaves globalHeaderElements/
200 + // globalFooterElements undefined and crashes the customizer with "Cannot
201 + // read properties of undefined (reading 'find')"; feeding the legacy shape
202 + // to an array-expecting bundle breaks it with "global_headers_footers.find
203 + // is not a function". Keep both conditions -- don't collapse into version
204 + // checks, they gate an unrelated concern (see YAYWP_HOSTS_CORE above).
205 + 'global_headers_footers' => ( $current_platform && (
206 + 'yaymagic-email-builder' === $current_platform->key()
207 + || ( 'yaymail' === $current_platform->key() && defined( 'YAYMAIL_LITE_LEGACY_GHF_SHAPE' ) && YAYMAIL_LITE_LEGACY_GHF_SHAPE )
208 + ) )
209 + ? \YayMail\Models\TemplateModel::get_global_header_and_footer( '', $current_platform->ghf_option_key() )
210 + : Localize::get_global_headers_footers(
211 + $current_platform ? $current_platform->ghf_option_key() : 'yaymail_global_header_footer'
212 + ),
173 213 'section_templates' => SectionTemplateService::get_instance()->get_list_data(),
174 214 'patterns' => PatternService::get_instance()->get_list_data(),
175 215 ],
176 216 'colors' => [
177 217 'default_background_color' => YAYMAIL_COLOR_BACKGROUND_DEFAULT,
178 - 'default_text_link_color' => YAYMAIL_COLOR_WC_DEFAULT,
218 + 'default_text_link_color' => ( $current_platform && 'yaymagic-email-builder' === $current_platform->key() ) ? YAYMAIL_COLOR_WP_DEFAULT : YAYMAIL_COLOR_WC_DEFAULT,
179 219 'default_content_background_color' => YAYMAIL_COLOR_CONTENT_BACKGROUND_DEFAULT,
180 220 'default_content_text_color' => YAYMAIL_COLOR_CONTENT_TEXT_DEFAULT,
181 - 'default_title_color' => YAYMAIL_COLOR_TITLE_DEFAULT,
221 + 'default_title_color' => ( $current_platform && 'yaymagic-email-builder' === $current_platform->key() ) ? YAYMAIL_COLOR_WP_DEFAULT : YAYMAIL_COLOR_TITLE_DEFAULT,
182 222 ],
183 223 'smtp' => [
184 224 'link_detail' => self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=yaysmtp&section=description&TB_iframe=true&width=600&height=800' ),
185 225 'setting' => admin_url( 'admin.php?page=yaysmtp' ),
@@ -184,8 +224,9 @@
184 224 'link_detail' => self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=yaysmtp&section=description&TB_iframe=true&width=600&height=800' ),
185 225 'setting' => admin_url( 'admin.php?page=yaysmtp' ),
186 226 'is_active' => Helpers::check_plugin_installed( 'yaysmtp/yay-smtp.php' ) || Helpers::check_plugin_installed( 'yaysmtp-pro/yay-smtp.php' ),
187 227 ],
228 + 'translate_integrations' => Localize::get_translate_integrations(),
188 229 'reviewed' => boolval( get_option( 'yaymail_review' ) ),
189 230 'ghf_tour' => get_option( 'yaymail_ghf_tour', 'initial' ),
190 231 'test_email_address' => get_option( 'yaymail_default_email_test', wp_get_current_user()->user_email ),
191 232 'site_title' => get_option( 'blogname' ),
@@ -194,9 +235,11 @@
194 235 'is_critical_migration_required' => MigrationModel::get_instance()->check_if_critical_migration_required(),
195 236 'supported_plugins' => SupportedPlugins::get_instance()->get_slug_name_supported_plugins(),
196 237 'show_multi_select_notice' => get_option( 'yaymail_show_multi_select_notice', 'yes' ),
197 238 'viewed_new_elements' => ! empty( get_option( 'yaymail_viewed_new_elements', [] ) ) ? get_option( 'yaymail_viewed_new_elements' ) : [],
198 - 'platform' => $screen->id === $this->yay_wp_hook_surfix ? 'email-builder' : 'yaymail',
239 + 'ghf_disallowed_element_types' => yaymail_get_ghf_disallowed_element_types(),
240 + 'platform' => $current_platform ? $current_platform->key() : 'yaymail',
241 + 'version' => yaymail_version(),
199 242 'woocommerce_email_styles' => $this->get_scoped_woocommerce_email_styles(),
200 243 ],
201 244 apply_filters( 'yaymail_additional_localized_variables', [] )
202 245 )
@@ -256,5 +299,5 @@
256 299 wp_dequeue_script( 'real-media-library-rml' );
257 300 wp_dequeue_style( 'real-category-library-admin' );
258 301 }
259 302 }
260 -}
303 +}