PluginProbe
YayMail – WooCommerce Email Customizer / 2.1.4
YayMail – WooCommerce Email Customizer v2.1.4
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
yaymail / includes / Page / Settings.php

Settings.php in YayMail – WooCommerce Email Customizer 2.1.4, at includes/Page/Settings.php

848 lines 34.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace YayMail\Page;
4
5 use YayMail\Ajax;
6 use YayMail\Page\Source\CustomPostType;
7 use YayMail\Page\Source\DefaultElement;
8 use YayMail\Templates\Templates;
9
10 defined( 'ABSPATH' ) || exit;
11 /**
12 * Settings Page
13 */
14 class Settings {
15
16 protected static $instance = null;
17
18 public static function getInstance() {
19 if ( null == self::$instance ) {
20 self::$instance = new self();
21 self::$instance->doHooks();
22 }
23
24 return self::$instance;
25 }
26
27 private $pageId = null;
28 private $templateAccount;
29 private $emails = null;
30 public function doHooks() {
31 $this->templateAccount = array( 'customer_new_account', 'customer_new_account_activation', 'customer_reset_password' );
32
33 // Register Custom Post Type use Email Builder
34 add_action( 'init', array( $this, 'registerCustomPostType' ) );
35
36 // Register Menu
37 add_action( 'admin_menu', array( $this, 'settingsMenu' ) );
38
39 // Register Style & Script use for Menu Backend
40 add_action( 'admin_enqueue_scripts', array( $this, 'enqueueAdminScripts' ) );
41
42 add_filter( 'plugin_action_links_' . YAYMAIL_PLUGIN_BASENAME, array( $this, 'plugin_action_links' ) );
43
44 // free version
45 $optionNotice = get_option( 'yaymail_notice' );
46 if ( time() >= (int) $optionNotice ) {
47 add_action( 'admin_notices', array( $this, 'renderNotice' ) );
48 }
49
50 // Ajax display notive
51 add_action( 'wp_ajax_yaymail_notice', array( $this, 'yaymailNotice' ) );
52
53 // Add Woocommerce email setting columns
54 add_filter( 'woocommerce_email_setting_columns', array( $this, 'yaymail_email_setting_columns' ) );
55 add_action( 'woocommerce_email_setting_column_template', array( $this, 'column_template' ) );
56
57 // Excute Ajax
58 Ajax::getInstance();
59 }
60 public function __construct() {}
61
62 public function yaymail_email_setting_columns( $array ) {
63 if ( isset( $array['actions'] ) ) {
64 unset( $array['actions'] );
65 return array_merge(
66 $array,
67 array(
68 'template' => '',
69 'actions' => '',
70 )
71 );
72 }
73 return $array;
74 }
75 public function column_template( $email ) {
76 echo '<td class="wc-email-settings-table-template">
77 <a class="button alignright" target="_blank" href="' . esc_attr( admin_url( 'admin.php?page=yaymail-settings' ) ) . '&template=' . esc_attr( $email->id ) . '">' . esc_html( __( 'Customize with YayMail', 'yaymail' ) ) . '</a></td>';
78 }
79
80 public function renderNotice() {
81 if ( is_plugin_active( 'woocommerce-subscriptions/woocommerce-subscriptions.php' )
82 || is_plugin_active( 'woocommerce-shipment-tracking/woocommerce-shipment-tracking.php' )
83 || is_plugin_active( 'woocommerce-order-status-manager/woocommerce-order-status-manager.php' )
84 || is_plugin_active( 'woocommerce-admin-custom-order-fields/woocommerce-admin-custom-order-fields.php' )
85 || is_plugin_active( 'woo-advanced-shipment-tracking/woo-advanced-shipment-tracking.php' )
86 || is_plugin_active( 'yith-woocommerce-subscription-premium/init.php' )
87 || is_plugin_active( 'yith-woocommerce-subscription/init.php' )
88 ) {
89 ?>
90
91 <div id="yaymail-notice" class="notice-info notice is-dismissible">
92 <h4 style="color: #000"><?php esc_html_e( 'Please upgrade to YayMail Pro to customize emails with:', 'yaymail' ); ?></h4>
93 <ul style="list-style: inside;">
94 <?php
95 ob_start();
96 $path = YAYMAIL_PLUGIN_PATH . '/includes/Page/Source/DisplayNotice.php';
97 include $path;
98 ?>
99 </ul>
100 <p style="padding-left:0">
101 <a href="https://yaycommerce.com/yaymail-woocommerce-email-customizer/ " target="_blank" data="upgradenow" class="button button-primary" style="margin-right: 5px"><?php esc_html_e( 'Upgrade Now', 'yaymail' ); ?></a>
102 <a href="javascript:;" data="later" class="button yaymail-nothank" style="margin-right: 5px"><?php esc_html_e( 'No, thanks', 'yaymail' ); ?></a>
103 </p>
104 </div>
105 <?php
106 }
107 }
108
109
110 public function yaymailNotice() {
111 if ( isset( $_POST ) ) {
112 $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( $_POST['nonce'] ) : null;
113
114 if ( ! wp_verify_nonce( $nonce, 'yaymail_nonce' ) ) {
115 wp_send_json_error( array( 'status' => 'Wrong nonce validate!' ) );
116 exit();
117 }
118 update_option( 'yaymail_notice', time() + 7 * 60 * 60 * 24 ); // After 7 days show
119 wp_send_json_success();
120 }
121 wp_send_json_error( array( 'message' => 'Update fail!' ) );
122 }
123
124 public function plugin_action_links( $links ) {
125 $action_links = array(
126 'settings' => '<a href="' . admin_url( 'admin.php?page=yaymail-settings' ) . '" aria-label="' . esc_attr__( 'View WooCommerce Email Builder', 'yaymail' ) . '">' . esc_html__( 'Settings', 'yaymail' ) . '</a>',
127 );
128 $links[] = '<a target="_blank" href="https://yaycommerce.com/yaymail-woocommerce-email-customizer/" style="color: #43B854; font-weight: bold">' . __( 'Go Pro', 'yaymail' ) . '</a>';
129 return array_merge( $action_links, $links );
130 }
131
132 public function registerCustomPostType() {
133 $labels = array(
134 'name' => __( 'Email Template', 'yaymail' ),
135 'singular_name' => __( 'Email Template', 'yaymail' ),
136 'add_new' => __( 'Add New Email Template', 'yaymail' ),
137 'add_new_item' => __( 'Add a new Email Template', 'yaymail' ),
138 'edit_item' => __( 'Edit Email Template', 'yaymail' ),
139 'new_item' => __( 'New Email Template', 'yaymail' ),
140 'view_item' => __( 'View Email Template', 'yaymail' ),
141 'search_items' => __( 'Search Email Template', 'yaymail' ),
142 'not_found' => __( 'No Email Template found', 'yaymail' ),
143 'not_found_in_trash' => __( 'No Email Template currently trashed', 'yaymail' ),
144 'parent_item_colon' => '',
145 );
146 $capabilities = array();
147 $args = array(
148 'labels' => $labels,
149 'public' => true,
150 'publicly_queryable' => true,
151 'show_ui' => false,
152 'query_var' => true,
153 'rewrite' => true,
154 'capability_type' => 'yaymail_template',
155 'capabilities' => $capabilities,
156 'hierarchical' => false,
157 'menu_position' => null,
158 'supports' => array( 'title', 'author', 'thumbnail' ),
159 );
160 register_post_type( 'yaymail_template', $args );
161 }
162 public function settingsMenu() {
163 add_submenu_page( 'woocommerce', __( 'Email Builder Settings', 'yaymail' ), __( 'Email Customizer', 'yaymail' ), 'manage_options', $this->getPageId(), array( $this, 'settingsPage' ) );
164 }
165
166 public function nitWebPluginRegisterButtons( $buttons ) {
167 $buttons[] = 'table';
168 $buttons[] = 'searchreplace';
169 $buttons[] = 'visualblocks';
170 $buttons[] = 'code';
171 $buttons[] = 'insertdatetime';
172 $buttons[] = 'autolink';
173 $buttons[] = 'contextmenu';
174 $buttons[] = 'advlist';
175 return $buttons;
176 }
177
178 public function njtWebPluginRegisterPlugin( $plugin_array ) {
179 $plugin_array['table'] = YAYMAIL_PLUGIN_URL . 'assets/tinymce/table/plugin.min.js';
180 $plugin_array['searchreplace'] = YAYMAIL_PLUGIN_URL . 'assets/tinymce/searchreplace/plugin.min.js';
181 $plugin_array['visualblocks'] = YAYMAIL_PLUGIN_URL . 'assets/tinymce/visualblocks/plugin.min.js';
182 $plugin_array['code'] = YAYMAIL_PLUGIN_URL . 'assets/tinymce/code/plugin.min.js';
183 $plugin_array['insertdatetime'] = YAYMAIL_PLUGIN_URL . 'assets/tinymce/insertdatetime/plugin.min.js';
184 $plugin_array['autolink'] = YAYMAIL_PLUGIN_URL . 'assets/tinymce/autolink/plugin.min.js';
185 $plugin_array['contextmenu'] = YAYMAIL_PLUGIN_URL . 'assets/tinymce/contextmenu/plugin.min.js';
186 $plugin_array['advlist'] = YAYMAIL_PLUGIN_URL . 'assets/tinymce/advlist/plugin.min.js';
187 return $plugin_array;
188 }
189
190 public function settingsPage() {
191 // When load this page will not show adminbar
192 ?>
193 <style type="text/css">
194 #wpcontent, #footer {opacity: 0}
195 #adminmenuback, #adminmenuwrap { display: none !important; }
196 </style>
197 <script type="text/javascript" id="yaymail-onload">
198 jQuery(document).ready( function() {
199 jQuery('#adminmenuback, #adminmenuwrap').remove();
200 });
201 </script>
202 <?php
203 // add new buttons
204 add_filter( 'mce_buttons', array( $this, 'nitWebPluginRegisterButtons' ) );
205
206 // Load the TinyMCE plugin
207 add_filter( 'mce_external_plugins', array( $this, 'njtWebPluginRegisterPlugin' ) );
208 $viewPath = YAYMAIL_PLUGIN_PATH . 'views/pages/html-settings.php';
209 include_once $viewPath;
210 }
211
212 public function enqueueAdminScripts( $screenId ) {
213 if ( class_exists( 'SitePress' ) ) {
214 global $sitepress_settings, $sitepress;
215 $custom_posts_sync = $sitepress_settings['custom_posts_sync_option'];
216 $custom_posts_sync['yaymail_template'] = 0;
217 $sitepress->set_setting( 'custom_posts_sync_option', $custom_posts_sync, true );
218 }
219 if ( class_exists( 'Polylang' ) ) {
220 $polylang_options = get_option( 'polylang' );
221 if ( isset( $polylang_options['post_types'] ) ) {
222 $yaymail_template_position = array_search( 'yaymail_template', $polylang_options['post_types'] );
223 if ( false !== $yaymail_template_position ) {
224 $polylang_options['post_types'] = array_splice( $polylang_options['post_types'], $yaymail_template_position + 1, 1 );
225 update_option( 'polylang', $polylang_options );
226 }
227 }
228 }
229 if ( strpos( $screenId, 'yaymail-settings' ) !== false && class_exists( 'WC_Emails' ) ) {
230 // Get list template from Woo
231 $wc_emails = \WC_Emails::instance();
232 $this->emails = (array) $wc_emails::instance()->emails;
233
234 // Insert database all order template from Woo
235 $templateEmail = Templates::getInstance();
236 $templates = $templateEmail::getList();
237
238 foreach ( $templates as $key => $template ) {
239 if ( ! CustomPostType::postIDByTemplate( $key ) ) {
240 $arr = array(
241 'mess' => '',
242 'post_date' => current_time( 'Y-m-d H:i:s' ),
243 'post_type' => 'yaymail_template',
244 'post_status' => 'publish',
245 '_yaymail_template' => $key,
246 '_email_backgroundColor_settings' => 'rgb(236, 236, 236)',
247 '_yaymail_elements' => json_decode( $template['elements'], true ),
248
249 );
250 $insert = CustomPostType::insert( $arr );
251 }
252 }
253
254 /*
255 @@@@ Enable Disable
256 @@@@ note: Note the default value section is required when displaying in vue
257 */
258
259 $settingDefaultEnableDisable = array(
260 'new_order' => 1,
261 'cancelled_order' => 1,
262 'failed_order' => 1,
263 'customer_on_hold_order' => 1,
264 'customer_processing_order' => 1,
265 'customer_completed_order' => 1,
266 'customer_refunded_order' => 1,
267 'customer_invoice' => 0,
268 'customer_note' => 0,
269 'customer_reset_password' => 0,
270 'customer_new_account' => 0,
271 );
272
273 $settingEnableDisables = ( CustomPostType::templateEnableDisable( false ) ) ? CustomPostType::templateEnableDisable( false ) : $settingDefaultEnableDisable;
274
275 foreach ( $this->emails as $key => $value ) {
276 if ( 'ORDDD_Email_Delivery_Reminder' == $key ) {
277 $value->id = 'orddd_delivery_reminder_customer';
278 }
279 if ( ! array_key_exists( $value->id, $settingEnableDisables ) ) {
280 $settingEnableDisables[ $value->id ] = '0';
281 }
282 }
283
284 $this->emails = apply_filters( 'YaymailCreateFollowUpTemplates', $this->emails );
285 $settingEnableDisables = apply_filters( 'YaymailCreateSelectFollowUpTemplates', $settingEnableDisables );
286
287 $settingDefaultGenerals = array(
288 'payment' => 2,
289 'product_image' => 0,
290 'image_size' => 'thumbnail',
291 'image_width' => '30px',
292 'image_height' => '30px',
293 'product_sku' => 1,
294 'background_color_table_items' => '#e5e5e5',
295 'content_items_color' => '#636363',
296 'title_items_color' => '#96588a',
297 'container_width' => '605px',
298 'order_url' => '',
299 'custom_css' => '',
300 'enable_css_custom' => 'no',
301 'image_position' => 'Top',
302 );
303 $settingGenerals = get_option( 'yaymail_settings' ) ? get_option( 'yaymail_settings' ) : $settingDefaultGenerals;
304 foreach ( $settingDefaultEnableDisable as $keyDefaultEnableDisable => $settingDefaultEnableDisable ) {
305 if ( ! array_key_exists( $keyDefaultEnableDisable, $settingEnableDisables ) ) {
306 $settingEnableDisables[ $keyDefaultEnableDisable ] = $settingDefaultEnableDisable;
307 };
308 }
309 $settings['enableDisable'] = $settingEnableDisables;
310
311 /*
312 @@@@ General
313 @@@@ note: Note the default value section is required when displaying in vue
314 */
315
316 $settingGenerals = get_option( 'yaymail_settings' ) ? get_option( 'yaymail_settings' ) : $settingDefaultGenerals;
317 foreach ( $settingDefaultGenerals as $keyDefaultGeneral => $settingGeneral ) {
318 if ( ! array_key_exists( $keyDefaultGeneral, $settingGenerals ) ) {
319 $settingGenerals[ $keyDefaultGeneral ] = $settingDefaultGenerals[ $keyDefaultGeneral ];
320 };
321 }
322
323 $settingGenerals['direction_rtl'] = get_option( 'yaymail_direction' ) ? get_option( 'yaymail_direction' ) : 'ltr';
324 $settings['general'] = $settingGenerals;
325
326 $scriptId = $this->getPageId();
327 $order = CustomPostType::getListOrders();
328 wp_enqueue_script( 'vue', YAYMAIL_PLUGIN_URL . ( YAYMAIL_DEBUG ? 'assets/libs/vue.js' : 'assets/libs/vue.min.js' ), '', YAYMAIL_VERSION, true );
329 wp_enqueue_script( 'vuex', YAYMAIL_PLUGIN_URL . 'assets/libs/vuex.js', '', YAYMAIL_VERSION, true );
330
331 wp_enqueue_script( $scriptId, YAYMAIL_PLUGIN_URL . 'assets/dist/js/main.js', array( 'jquery' ), YAYMAIL_VERSION, true );
332 wp_enqueue_style( $scriptId, YAYMAIL_PLUGIN_URL . 'assets/dist/css/main.css', array(), YAYMAIL_VERSION );
333
334 // Css of ant
335 // wp_enqueue_style($scriptId . 'antd-css', YAYMAIL_PLUGIN_URL . 'assets/admin/css/antd.min.css');
336 // Css file app
337 // wp_enqueue_style($scriptId, YAYMAIL_PLUGIN_URL . 'assets/dist/css/main.css');
338
339 wp_enqueue_script( $scriptId . '-script', YAYMAIL_PLUGIN_URL . 'assets/admin/js/script.js', '', YAYMAIL_VERSION, true );
340 $yaymailSettings = get_option( 'yaymail_settings' );
341
342 // Load ACE Editor -Start
343 if ( isset( $yaymailSettings['enable_css_custom'] ) && 'yes' == $yaymailSettings['enable_css_custom'] ) {
344 wp_enqueue_script( $scriptId . 'ace-script', YAYMAIL_PLUGIN_URL . 'assets/aceeditor/ace.js', '', YAYMAIL_VERSION, true );
345 wp_enqueue_script( $scriptId . 'ace1-script', YAYMAIL_PLUGIN_URL . 'assets/aceeditor/ext-language_tools.js', '', YAYMAIL_VERSION, true );
346 wp_enqueue_script( $scriptId . 'ace2-script', YAYMAIL_PLUGIN_URL . 'assets/aceeditor/mode-css.js', '', YAYMAIL_VERSION, true );
347 wp_enqueue_script( $scriptId . 'ace3-script', YAYMAIL_PLUGIN_URL . 'assets/aceeditor/theme-merbivore_soft.js', '', YAYMAIL_VERSION, true );
348 wp_enqueue_script( $scriptId . 'ace4-script', YAYMAIL_PLUGIN_URL . 'assets/aceeditor/worker-css.js', '', YAYMAIL_VERSION, true );
349 wp_enqueue_script( $scriptId . 'ace5-script', YAYMAIL_PLUGIN_URL . 'assets/aceeditor/snippets/css.js ', '', YAYMAIL_VERSION, true );
350 } else {
351 wp_dequeue_script( $scriptId . 'ace-script' );
352 wp_dequeue_script( $scriptId . 'ace1-script' );
353 wp_dequeue_script( $scriptId . 'ace2-script' );
354 wp_dequeue_script( $scriptId . 'ace3-script' );
355 wp_dequeue_script( $scriptId . 'ace4-script' );
356 wp_dequeue_script( $scriptId . 'ace5-script' );
357 }
358 // Load ACE Editor -End
359 // Css for page admin of WordPress.
360 wp_enqueue_style( $scriptId . '-css', YAYMAIL_PLUGIN_URL . 'assets/admin/css/css.css', array(), YAYMAIL_VERSION );
361 $current_user = wp_get_current_user();
362 $default_email_test = false != get_user_meta( get_current_user_id(), 'yaymail_default_email_test', true ) ? get_user_meta( get_current_user_id(), 'yaymail_default_email_test', true ) : $current_user->user_email;
363 $element = new DefaultElement();
364 $yaymailSettingsDefaultLogo = get_option( 'yaymail_settings_default_logo' );
365 $setDefaultLogo = false != $yaymailSettingsDefaultLogo ? $yaymailSettingsDefaultLogo['set_default'] : '0';
366 $yaymailSettingsDefaultFooter = get_option( 'yaymail_settings_default_footer' );
367 $setDefaultFooter = false != $yaymailSettingsDefaultFooter ? $yaymailSettingsDefaultFooter['set_default'] : '0';
368 if ( isset( $_GET['template'] ) || ! empty( $_GET['template'] ) ) {
369 $req_template['id'] = sanitize_text_field( $_GET['template'] );
370 } else {
371 $req_template['id'] = 'new_order';
372 }
373 foreach ( $this->emails as $value ) {
374 if ( $value->id == $req_template['id'] ) {
375 $req_template['title'] = $value->title;
376 }
377 }
378
379 // List email supported
380
381 $list_email_supported = array(
382 'WC_Subscription' => array(
383 'plugin_name' => 'WooCommerce Subscriptions',
384 'template_name' => array(
385 'cancelled_subscription',
386 'expired_subscription',
387 'suspended_subscription',
388 'customer_completed_renewal_order',
389 'customer_completed_switch_order',
390 'customer_on_hold_renewal_order',
391 'customer_renewal_invoice',
392 'new_renewal_order',
393 'new_switch_order',
394 'customer_processing_renewal_order',
395 ),
396 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-woo-subscriptions',
397 ),
398 'yith_wishlist_constructor' => array(
399 'plugin_name' => 'YITH WooCommerce Wishlist Premium',
400 'template_name' => array(
401 'estimate_mail',
402 'yith_wcwl_back_in_stock',
403 'yith_wcwl_on_sale_item',
404 'yith_wcwl_promotion_mail',
405 ),
406 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-yith-wishlist',
407 ),
408 'SUMO_Subscription' => array(
409 'plugin_name' => 'SUMO Subscription',
410 'template_name' => array(
411 'subscription_new_order',
412 'subscription_new_order_old_subscribers',
413 'subscription_processing_order',
414 'subscription_completed_order',
415 'subscription_pause_order',
416 'subscription_invoice_order_manual',
417 'subscription_expiry_reminder',
418 'subscription_automatic_charging_reminder',
419 'subscription_renewed_order_automatic',
420 'auto_to_manual_subscription_renewal',
421 'subscription_overdue_order_automatic',
422 'subscription_overdue_order_manual',
423 'subscription_suspended_order_automatic',
424 'subscription_suspended_order_manual',
425 'subscription_preapproval_access_revoked',
426 'subscription_turnoff_automatic_payments_success',
427 'subscription_pending_authorization',
428 'subscription_cancel_order',
429 'subscription_cancel_request_submitted',
430 'subscription_cancel_request_revoked',
431 'subscription_expired_order',
432 ),
433 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-sumo-subscriptions',
434 ),
435
436 'YITH_Subscription' => array(
437 'plugin_name' => 'YITH WooCommerce Subscription Premium',
438 'template_name' => array(
439 'ywsbs_subscription_admin_mail',
440 'ywsbs_customer_subscription_cancelled',
441 'ywsbs_customer_subscription_suspended',
442 'ywsbs_customer_subscription_expired',
443 'ywsbs_customer_subscription_before_expired',
444 'ywsbs_customer_subscription_paused',
445 'ywsbs_customer_subscription_resumed',
446 'ywsbs_customer_subscription_request_payment',
447 'ywsbs_customer_subscription_renew_reminder',
448 'ywsbs_customer_subscription_payment_done',
449 'ywsbs_customer_subscription_payment_failed',
450 'ywsbs_customer_subscription_delivery_schedules',
451 ),
452 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-yith-subscription',
453 ),
454 'woo-b2b' => array(
455 'plugin_name' => 'WooCommerce B2B',
456 'template_name' => array(
457 'wcb2b_customer_onquote_order',
458 'wcb2b_customer_quoted_order',
459 'wcb2b_customer_status_notification',
460 'wcb2b_new_quote',
461 ),
462 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-b2b-woocommerce',
463 ),
464 'YITH_Vendors' => array(
465 'plugin_name' => 'YITH WooCommerce Multi Vendor Premium',
466 'template_name' => array(
467 'cancelled_order_to_vendor',
468 'commissions_paid',
469 'commissions_unpaid',
470 'new_order_to_vendor',
471 'new_vendor_registration',
472 'product_set_in_pending_review',
473 'vendor_commissions_bulk_action',
474 'vendor_commissions_paid',
475 'vendor_new_account',
476 ),
477 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-yith-multivendor',
478 ),
479 'Germanized_Pro' => array(
480 'plugin_name' => 'Germanized for WooCommerce',
481 'template_name' => array(
482 'sab_cancellation_invoice',
483 'sab_document',
484 'sab_document_admin',
485 'sab_simple_invoice',
486 'sab_packing_slip',
487 'customer_paid_for_order',
488 'customer_cancelled_order',
489 'customer_order_confirmation',
490 'customer_revocation',
491 'customer_new_account_activation',
492 'customer_shipment',
493 'customer_return_shipment',
494 'customer_return_shipment_delivered',
495 'new_return_shipment_request',
496 'customer_trusted_shops',
497 'customer_sepa_direct_debit_mandate',
498 'customer_guest_return_shipment_request',
499 ),
500 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-germanized',
501 ),
502 'WC_Bookings' => array(
503 'plugin_name' => 'WooCommerce Bookings',
504 'template_name' => array(
505 'admin_booking_cancelled',
506 'booking_cancelled',
507 'booking_confirmed',
508 'booking_notification',
509 'booking_pending_confirmation',
510 'booking_reminder',
511 'new_booking',
512 ),
513 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-woo-bookings',
514 ),
515 'WooCommerce_Waitlist' => array(
516 'plugin_name' => 'WooCommerce Waitlist',
517 'template_name' => array(
518 'woocommerce_waitlist_joined_email',
519 'woocommerce_waitlist_left_email',
520 'woocommerce_waitlist_mailout',
521 'woocommerce_waitlist_signup_email',
522 ),
523 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-woo-waitlist',
524 ),
525 'WooCommerce_Quotes' => array(
526 'plugin_name' => 'Quotes for WooCommerce',
527 'template_name' => array(
528 'qwc_req_new_quote',
529 'qwc_request_sent',
530 'qwc_send_quote',
531 ),
532 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-quotes-woocommerce',
533 ),
534 'YITH_Pre_Order' => array(
535 'plugin_name' => 'YITH Pre-Order for WooCommerce Premium ',
536 'template_name' => array(
537 'yith_ywpo_date_end',
538 'yith_ywpo_sale_date_changed',
539 'yith_ywpo_is_for_sale',
540 'yith_ywpo_out_of_stock',
541 ),
542 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-yith-pre-order',
543 ),
544 'WooCommerce_Appointments' => array(
545 'plugin_name' => 'WooCommerce Appointments',
546 'template_name' => array(
547 'admin_appointment_cancelled',
548 'admin_new_appointment',
549 'appointment_cancelled',
550 'appointment_confirmed',
551 'appointment_follow_up',
552 'appointment_reminder',
553 ),
554 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-appointments-woocommerce',
555 ),
556 'SG_Order_Approval' => array(
557 'plugin_name' => 'Sg Order Approval for Woocommerce',
558 'template_name' => array(
559 'wc_admin_order_new',
560 'wc_customer_order_new',
561 'wc_customer_order_approved',
562 'wc_customer_order_rejected',
563 'sgitsoa_wc_admin_order_new',
564 'sgitsoa_wc_customer_order_new',
565 'sgitsoa_wc_customer_order_approved',
566 'sgitsoa_wc_customer_order_rejected',
567 ),
568 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-order-approval-woocommerce',
569 ),
570 'YITH_Pre_Order' => array(
571 'plugin_name' => 'YITH Pre-Order for WooCommerce Premium ',
572 'template_name' => array(
573 'yith_ywpo_date_end',
574 'yith_ywpo_sale_date_changed',
575 'yith_ywpo_is_for_sale',
576 'yith_ywpo_out_of_stock',
577 ),
578 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-yith-pre-order',
579 ),
580 'Follow_Up_Emails' => array(
581 'plugin_name' => 'Follow Up Emails for WooCommerce ',
582 'template_name' => apply_filters( 'YaymailCreateListFollowUpNames', array() ),
583 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-woo-follow-ups',
584 ),
585 'Order_Delivery_Date' => array(
586 'plugin_name' => 'Order Delivery Date Pro for WooCommerce',
587 'template_name' => array(
588 'orddd_delivery_reminder',
589 'orddd_delivery_reminder_customer',
590 'orddd_update_date',
591 ),
592 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-order-delivery-date',
593 ),
594 'WC_Email_Cancelled_Customer_Order' => array(
595 'plugin_name' => 'Order Cancellation Email to Customer',
596 'template_name' => array(
597 'wc_customer_cancelled_order',
598 ),
599 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-order-cancellation-email-customer',
600 ),
601 'WC_Smart_Coupons' => array(
602 'plugin_name' => 'WooCommerce Smart Coupons',
603 'template_name' => array(
604 'wc_sc_combined_email_coupon',
605 'wc_sc_acknowledgement_email',
606 'wc_sc_email_coupon',
607 ),
608 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-smart-coupons',
609 ),
610 'Dokan' => array(
611 'plugin_name' => 'Dokan',
612 'template_name' => array(
613 'dokan_new_seller',
614 'dokan_email_vendor_disable',
615 'dokan_email_vendor_enable',
616 'dokan_contact_seller',
617 'new_product',
618 'new_product_pending',
619 'pending_product_published',
620 'updated_product_pending',
621 'dokan_vendor_new_order',
622 'dokan_vendor_completed_order',
623 'dokan_vendor_withdraw_request',
624 'dokan_vendor_withdraw_cancelled',
625 'dokan_vendor_withdraw_approved',
626 'dokan_refund_request',
627 'dokan_vendor_refund',
628 'dokan_announcement',
629 'dokan_staff_new_order',
630 'Dokan_Email_Wholesale_Register',
631 'dokan_email_shipping_status_tracking',
632 'dokan_email_subscription_invoice',
633 'updates_for_store_followers',
634 'vendor_new_store_follower',
635 'dokan_product_enquiry_email',
636 'dokan_report_abuse_admin_email',
637 'Dokan_Send_Coupon_Email',
638 'Dokan_Rma_Send_Warranty_Request',
639 ),
640 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-dokan',
641 ),
642 'B2B_Wholesale_Suite' => array(
643 'plugin_name' => 'B2B & Wholesale Suite',
644 'template_name' => array(
645 'b2bwhs_new_customer_email',
646 'b2bwhs_new_customer_requires_approval_email',
647 'b2bwhs_new_message_email',
648 'b2bwhs_new_quote_email',
649 'b2bwhs_your_account_approved_email',
650 ),
651 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-b2b-wholesale-suite',
652 ),
653 'WooCommerce_Deposits' => array(
654 'plugin_name' => 'WooCommerce Deposits',
655 'template_name' => array(
656 'customer_deposit_partially_paid',
657 'customer_partially_paid',
658 'customer_second_payment_reminder',
659 'full_payment',
660 'partial_payment',
661 ),
662 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-woocommerce-deposits',
663 ),
664 'YITH_Booking' => array(
665 'plugin_name' => 'YITH Booking and Appointment for WooCommerce Premium',
666 'template_name' => array(
667 'yith_wcbk_admin_new_booking',
668 'yith_wcbk_booking_status',
669 'yith_wcbk_customer_booking_note',
670 'yith_wcbk_customer_cancelled_booking',
671 'yith_wcbk_customer_completed_booking',
672 'yith_wcbk_customer_confirmed_booking',
673 'yith_wcbk_customer_new_booking',
674 'yith_wcbk_customer_paid_booking',
675 'yith_wcbk_customer_unconfirmed_booking',
676 'yith_wcbk_booking_status_vendor',
677 'yith_wcbk_vendor_new_booking',
678 ),
679 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-yith-booking',
680 ),
681 'WooCommerce_Points_Rewards' => array(
682 'plugin_name' => 'Points and Rewards for WooCommerce',
683 'template_name' => array(
684 'mwb_wpr_email_notification',
685 ),
686 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-points-and-rewards',
687 ),
688 'PW_WooCommerce_Gift_Cards' => array(
689 'plugin_name' => 'PW WooCommerce Gift Cards',
690 'template_name' => array(
691 'pwgc_email',
692 ),
693 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-pw-woocommerce-gift-cards',
694 ),
695 'YITH_WooCommerce_Gift_Cards_Premium' => array(
696 'plugin_name' => 'YITH WooCommerce Gift Cards Premium',
697 'template_name' => array(
698 'ywgc-email-delivered-gift-card',
699 'ywgc-email-send-gift-card',
700 ),
701 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-yith-woocommerce-gift-cards-premium',
702 ),
703 'YITH_WooCommerce_Membership_Premium' => array(
704 'plugin_name' => 'YITH WooCommerce Membership Premium',
705 'template_name' => array(
706 'membership_cancelled',
707 'membership_expired',
708 'membership_expiring',
709 'membership_welcome',
710 ),
711 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-yith-woocommerce-membership-premium',
712 ),
713 'WooCommerce_Order_Delivery' => array(
714 'plugin_name' => 'WooCommerce Order Delivery',
715 'template_name' => array(
716 'subscription_delivery_note',
717 'order_delivery_note',
718 ),
719 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-themesquad-delivery-date',
720 ),
721 'WooCommerce_Simple_Auction' => array(
722 'plugin_name' => 'WooCommerce Simple Auction',
723 'template_name' => array(
724 'auction_buy_now',
725 'auction_closing_soon',
726 'auction_fail',
727 'auction_finished',
728 'auction_relist',
729 'auction_relist_user',
730 'auction_win',
731 'bid_note',
732 'customer_bid_note',
733 'outbid_note',
734 'remind_to_pay',
735 'Reserve_fail',
736 ),
737 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-simple-auctions',
738 ),
739 'vendors_marketplace' => array(
740 'plugin_name' => 'Vendors marketplace',
741 'template_name' => array(
742 'admin_notify_approved',
743 'admin_notify_application',
744 'admin_notify_product',
745 'admin_notify_shipped',
746 'customer_notify_shipped',
747 'vendor_notify_application',
748 'vendor_notify_approved',
749 'vendor_notify_cancelled_order',
750 'vendor_notify_denied',
751 'vendor_notify_order',
752 'vendor_application',
753 'admin_new_vendor_product',
754 'vendor_notify_shipped',
755 'vendor_new_order',
756 'customer-mark-received',
757 'store_contact',
758 ),
759 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-simple-auctions',
760 ),
761 'WooCommerce_Pre_Orders' => array(
762 'plugin_name' => 'WooCommerce Pre-Orders',
763 'template_name' => array(
764 'wc_pre_orders_new_pre_order',
765 'wc_pre_orders_pre_order_available',
766 'wc_pre_orders_pre_order_cancelled',
767 'wc_pre_orders_pre_order_date_changed',
768 'wc_pre_orders_pre_ordered',
769 ),
770 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-woo-pre-orders',
771 ),
772 'WooCommerce_Split_Orders' => array(
773 'plugin_name' => 'WooCommerce Split Orders',
774 'template_name' => array(
775 'customer_order_split',
776 ),
777 'link_upgrade' => 'https://yaycommerce.com/yaymail-woocommerce-email-customizer/#yaymail-addon-split-orders',
778 ),
779 );
780
781 $list_plugin_for_pro = array();
782
783 if ( class_exists( 'WC_Shipment_Tracking_Actions' ) || class_exists( 'WC_Advanced_Shipment_Tracking_Actions' ) ) {
784 $list_plugin_for_pro[] = 'WC_Shipment_Tracking';
785 }
786 if ( class_exists( 'WC_Admin_Custom_Order_Fields' ) ) {
787 $list_plugin_for_pro[] = 'WC_Admin_Custom_Order_Fields';
788 }
789
790 $orderby = 'name';
791 $order_category = 'asc';
792 $hide_empty = false;
793
794 $cat_args = array(
795 'orderby' => $orderby,
796 'order' => $order_category,
797 'hide_empty' => $hide_empty,
798 );
799
800 $product_categories = get_terms( 'product_cat', $cat_args );
801 $billing_country = WC()->countries->countries;
802
803 wp_localize_script(
804 $scriptId,
805 'yaymail_data',
806 array(
807 'orders' => $order,
808 'imgUrl' => YAYMAIL_PLUGIN_URL . 'assets/dist/images',
809 'nonce' => wp_create_nonce( 'email-nonce' ),
810 'defaultDataElement' => $element->defaultDataElement,
811 'home_url' => home_url(),
812 'settings' => $settings,
813 'admin_url' => get_admin_url(),
814 'yaymail_plugin_url' => YAYMAIL_PLUGIN_URL,
815 'wc_emails' => $this->emails,
816 'default_email_test' => $default_email_test,
817 'template' => $req_template,
818 'set_default_logo' => $setDefaultLogo,
819 'set_default_footer' => $setDefaultFooter,
820 'list_plugin_for_pro' => $list_plugin_for_pro,
821 'plugins' => apply_filters( 'yaymail_plugins', array() ),
822 'list_email_supported' => $list_email_supported,
823 'product_categories' => $product_categories,
824 'billing_country' => $billing_country,
825 )
826 );
827 do_action( 'yaymail_enqueue_script_conditional_logic' );
828 do_action( 'yaymail_before_enqueue_dependence' );
829 }
830 wp_enqueue_script( 'yaymail-notice', YAYMAIL_PLUGIN_URL . 'assets/admin/js/notice.js', array( 'jquery' ), YAYMAIL_VERSION, false );
831 wp_localize_script(
832 'yaymail-notice',
833 'yaymail_notice',
834 array(
835 'admin_ajax' => admin_url( 'admin-ajax.php' ),
836 'nonce' => wp_create_nonce( 'yaymail_nonce' ),
837 )
838 );
839 }
840 public function getPageId() {
841 if ( null == $this->pageId ) {
842 $this->pageId = YAYMAIL_PREFIX . '-settings';
843 }
844
845 return $this->pageId;
846 }
847 }
848