PluginProbe
YayMail – WooCommerce Email Customizer / 3.2.2
YayMail – WooCommerce Email Customizer v3.2.2
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 3.4.2 3.4.3 All 55 releases
yaymail / includes / Page / Settings.php

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

610 lines 27.0 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 stdClass;
6 use YayMail\Ajax;
7 use YayMail\Page\Source\CustomPostType;
8 use YayMail\Page\Source\DefaultElement;
9 use YayMail\Templates\Templates;
10 use YayMail\I18n;
11 use YayMail\Helper\Helper;
12 use YayMail\Helper\PluginSupported;
13
14
15 defined( 'ABSPATH' ) || exit;
16 /**
17 * Settings Page
18 */
19 class Settings {
20
21 protected static $instance = null;
22
23 public static function getInstance() {
24 if ( null == self::$instance ) {
25 self::$instance = new self();
26 self::$instance->doHooks();
27 }
28
29 return self::$instance;
30 }
31
32 private $pageId = null;
33 private $templateAccount;
34 private $emails = null;
35 public function doHooks() {
36 $this->templateAccount = array( 'customer_new_account', 'customer_new_account_activation', 'customer_reset_password' );
37
38 // Register Custom Post Type use Email Builder
39 add_action( 'init', array( $this, 'registerCustomPostType' ) );
40
41 // Register Menu
42 add_action( 'admin_menu', array( $this, 'settingsMenu' ) );
43
44 // Register Style & Script use for Menu Backend
45 add_action( 'admin_enqueue_scripts', array( $this, 'enqueueAdminScripts' ) );
46
47 add_filter( 'plugin_action_links_' . YAYMAIL_PLUGIN_BASENAME, array( $this, 'plugin_action_links' ) );
48
49 add_filter( 'plugin_row_meta', array( $this, 'add_support_and_docs_links' ), 10, 2 );
50
51 // free version
52 $optionNotice = get_option( 'yaymail_notice' );
53 if ( time() >= (int) $optionNotice ) {
54 add_action( 'admin_notices', array( $this, 'renderNotice' ) );
55 }
56
57 // Ajax display notive
58 add_action( 'wp_ajax_yaymail_notice', array( $this, 'yaymailNotice' ) );
59
60 // Add Woocommerce email setting columns
61 add_filter( 'woocommerce_email_setting_columns', array( $this, 'yaymail_email_setting_columns' ) );
62 add_action( 'woocommerce_email_setting_column_template', array( $this, 'column_template' ) );
63
64 // Excute Ajax
65 Ajax::getInstance();
66 }
67 public function __construct() {}
68
69 public function yaymail_email_setting_columns( $array ) {
70 if ( isset( $array['actions'] ) ) {
71 unset( $array['actions'] );
72 return array_merge(
73 $array,
74 array(
75 'template' => '',
76 'actions' => '',
77 )
78 );
79 }
80 return $array;
81 }
82 public function column_template( $email ) {
83 $email_id = $email->id;
84 if ( 'yith-coupon-email-system' === $email->id ) {
85 if ( class_exists( 'YayMailYITHWooCouponEmailSystem\templateDefault\DefaultCouponEmailSystem' ) ) {
86 $email_id = 'YWCES_register';
87 }
88 }
89 echo '<td class="wc-email-settings-table-template">
90 <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>';
91 }
92
93 public function renderNotice() {
94
95 include YAYMAIL_PLUGIN_PATH . '/includes/Page/Source/DisplayAddonNotice.php';
96 }
97
98 public function yaymailNotice() {
99 if ( isset( $_POST ) ) {
100 $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( $_POST['nonce'] ) : null;
101
102 if ( ! wp_verify_nonce( $nonce, 'yaymail_nonce' ) ) {
103 wp_send_json_error( array( 'status' => 'Wrong nonce validate!' ) );
104 exit();
105 }
106 update_option( 'yaymail_notice', time() + 60 * 60 * 24 * 60 ); // After 60 days show
107 wp_send_json_success();
108 }
109 wp_send_json_error( array( 'message' => 'Update fail!' ) );
110 }
111
112 public function plugin_action_links( $links ) {
113 $action_links = array(
114 'settings' => '<a href="' . admin_url( 'admin.php?page=yaymail-settings' ) . '" aria-label="' . esc_attr__( 'View WooCommerce Email Builder', 'yaymail' ) . '">' . esc_html__( 'Start Customizing', 'yaymail' ) . '</a>',
115 );
116 $links[] = '<a target="_blank" href="https://yaycommerce.com/yaymail-woocommerce-email-customizer/" style="color: #43B854; font-weight: bold">' . __( 'Go Pro', 'yaymail' ) . '</a>';
117 return array_merge( $action_links, $links );
118 }
119
120 public function add_support_and_docs_links( $plugin_meta, $plugin_file ) {
121 if ( YAYMAIL_PLUGIN_BASENAME === $plugin_file ) {
122 $plugin_meta[] = '<a target="_blank" href="https://docs.yaycommerce.com/yaymail/getting-started/introduction">Docs</a>';
123 $plugin_meta[] = '<a target="_blank" href="https://yaycommerce.com/support/">Support</a>';
124 }
125 return $plugin_meta;
126 }
127
128 public function registerCustomPostType() {
129 $labels = array(
130 'name' => __( 'Email Template', 'yaymail' ),
131 'singular_name' => __( 'Email Template', 'yaymail' ),
132 'add_new' => __( 'Add New Email Template', 'yaymail' ),
133 'add_new_item' => __( 'Add a new Email Template', 'yaymail' ),
134 'edit_item' => __( 'Edit Email Template', 'yaymail' ),
135 'new_item' => __( 'New Email Template', 'yaymail' ),
136 'view_item' => __( 'View Email Template', 'yaymail' ),
137 'search_items' => __( 'Search Email Template', 'yaymail' ),
138 'not_found' => __( 'No Email Template found', 'yaymail' ),
139 'not_found_in_trash' => __( 'No Email Template currently trashed', 'yaymail' ),
140 'parent_item_colon' => '',
141 );
142 $capabilities = array();
143 $args = array(
144 'labels' => $labels,
145 'public' => true,
146 'publicly_queryable' => true,
147 'show_ui' => false,
148 'query_var' => true,
149 'rewrite' => true,
150 'capability_type' => 'yaymail_template',
151 'capabilities' => $capabilities,
152 'hierarchical' => false,
153 'menu_position' => null,
154 'exclude_from_search' => true,
155 'publicly_queryable' => false,
156 'supports' => array( 'title', 'author', 'thumbnail' ),
157 );
158 register_post_type( 'yaymail_template', $args );
159 }
160 public function settingsMenu() {
161 add_submenu_page( 'woocommerce', __( 'Email Builder Settings', 'yaymail' ), __( 'Email Customizer', 'yaymail' ), 'manage_woocommerce', $this->getPageId(), array( $this, 'settingsPage' ) );
162 }
163
164 public function nitWebPluginRegisterButtons( $buttons ) {
165 $buttons[] = 'table';
166 $buttons[] = 'searchreplace';
167 $buttons[] = 'visualblocks';
168 $buttons[] = 'code';
169 $buttons[] = 'insertdatetime';
170 $buttons[] = 'autolink';
171 $buttons[] = 'contextmenu';
172 $buttons[] = 'advlist';
173 return $buttons;
174 }
175
176 public function njtWebPluginRegisterPlugin( $plugin_array ) {
177 $plugin_array['table'] = YAYMAIL_PLUGIN_URL . 'assets/tinymce/table/plugin.min.js';
178 $plugin_array['searchreplace'] = YAYMAIL_PLUGIN_URL . 'assets/tinymce/searchreplace/plugin.min.js';
179 $plugin_array['visualblocks'] = YAYMAIL_PLUGIN_URL . 'assets/tinymce/visualblocks/plugin.min.js';
180 $plugin_array['code'] = YAYMAIL_PLUGIN_URL . 'assets/tinymce/code/plugin.min.js';
181 $plugin_array['insertdatetime'] = YAYMAIL_PLUGIN_URL . 'assets/tinymce/insertdatetime/plugin.min.js';
182 $plugin_array['autolink'] = YAYMAIL_PLUGIN_URL . 'assets/tinymce/autolink/plugin.min.js';
183 $plugin_array['contextmenu'] = YAYMAIL_PLUGIN_URL . 'assets/tinymce/contextmenu/plugin.min.js';
184 $plugin_array['advlist'] = YAYMAIL_PLUGIN_URL . 'assets/tinymce/advlist/plugin.min.js';
185 return $plugin_array;
186 }
187
188 public function settingsPage() {
189 // When load this page will not show adminbar
190 ?>
191 <style type="text/css">
192 #wpcontent, #footer {opacity: 0}
193 #adminmenuback, #adminmenuwrap { display: none !important; }
194 </style>
195 <script type="text/javascript" id="yaymail-onload">
196 jQuery(document).ready( function() {
197 jQuery('#adminmenuback, #adminmenuwrap').remove();
198 });
199 </script>
200 <?php
201 // add new buttons
202 add_filter( 'mce_buttons', array( $this, 'nitWebPluginRegisterButtons' ) );
203
204 // Load the TinyMCE plugin
205 add_filter( 'mce_external_plugins', array( $this, 'njtWebPluginRegisterPlugin' ) );
206 $viewPath = YAYMAIL_PLUGIN_PATH . 'views/pages/html-settings.php';
207 include_once $viewPath;
208 }
209
210 public function enqueueAdminScripts( $screenId ) {
211 if ( class_exists( 'SitePress' ) ) {
212 global $sitepress_settings, $sitepress;
213 $custom_posts_sync = $sitepress_settings['custom_posts_sync_option'];
214 $custom_posts_sync['yaymail_template'] = 0;
215 $sitepress->set_setting( 'custom_posts_sync_option', $custom_posts_sync, true );
216 }
217 if ( class_exists( 'Polylang' ) ) {
218 $polylang_options = get_option( 'polylang' );
219 if ( isset( $polylang_options['post_types'] ) ) {
220 $yaymail_template_position = array_search( 'yaymail_template', $polylang_options['post_types'] );
221 if ( false !== $yaymail_template_position ) {
222 $polylang_options['post_types'] = array_splice( $polylang_options['post_types'], $yaymail_template_position + 1, 1 );
223 update_option( 'polylang', $polylang_options );
224 }
225 }
226 }
227 if ( strpos( $screenId, 'yaymail-settings' ) !== false && class_exists( 'WC_Emails' ) ) {
228 // Filter to active tinymce
229 add_filter( 'user_can_richedit', '__return_true', PHP_INT_MAX );
230 // Get list template from Woo
231 $wc_emails = \WC_Emails::instance();
232 $this->emails = (array) $wc_emails::instance()->emails;
233 unset( $this->emails['WC_TrackShip_Email_Manager'] );
234 if ( isset( $this->emails['WC_GZD_Email_Customer_Shipment'] ) ) {
235 $partial_email = new stdClass();
236 $partial_email->id = 'customer_partial_shipment';
237 $partial_email->title = 'Order partial shipped';
238 $customer_shipment_position = array_search( 'WC_GZD_Email_Customer_Shipment', array_keys( $this->emails ) );
239 $this->emails = array_merge(
240 array_slice( $this->emails, 0, $customer_shipment_position ),
241 array( 'WC_GZD_Email_Customer_Partial_Shipment' => $partial_email ),
242 array_slice( $this->emails, $customer_shipment_position )
243 );
244 }
245 if ( class_exists( 'AW_Referrals_Plugin_Data' ) && ( is_plugin_active( 'yaymail-addon-for-automatewoo/yaymail-automatewoo.php' ) || is_plugin_active( 'email-customizer-automatewoo/yaymail-automatewoo.php' ) ) ) {
246 $referrals_email = new stdClass();
247 $referrals_email->id = 'AutomateWoo_Referrals_Email';
248 $referrals_email->title = __( 'AutomateWoo Referrals Email', 'yaymail' );
249 $this->emails = array_merge( $this->emails, array( 'AutomateWoo_Referrals_Email' => $referrals_email ) );
250 }
251 // Insert database all order template from Woo
252 $templateEmail = Templates::getInstance();
253 $templates = $templateEmail::getList();
254
255 foreach ( $templates as $key => $template ) {
256 if ( ! CustomPostType::postIDByTemplate( $key ) ) {
257 $arr = array(
258 'mess' => '',
259 'post_date' => current_time( 'Y-m-d H:i:s' ),
260 'post_type' => 'yaymail_template',
261 'post_status' => 'publish',
262 '_yaymail_template' => $key,
263 '_email_backgroundColor_settings' => 'rgb(236, 236, 236)',
264 '_yaymail_elements' => json_decode( $template['elements'], true ),
265
266 );
267 $insert = CustomPostType::insert( $arr );
268 }
269 }
270
271 /*
272 @@@@ Enable Disable
273 @@@@ note: Note the default value section is required when displaying in vue
274 */
275
276 $settingDefaultEnableDisable = array(
277 'new_order' => 1,
278 'cancelled_order' => 1,
279 'failed_order' => 1,
280 'customer_on_hold_order' => 1,
281 'customer_processing_order' => 1,
282 'customer_completed_order' => 1,
283 'customer_refunded_order' => 1,
284 'customer_invoice' => 0,
285 'customer_note' => 0,
286 'customer_reset_password' => 0,
287 'customer_new_account' => 0,
288 );
289
290 $settingEnableDisables = ( CustomPostType::templateEnableDisable( false ) ) ? CustomPostType::templateEnableDisable( false ) : $settingDefaultEnableDisable;
291
292 foreach ( $this->emails as $key => $value ) {
293 if ( 'ORDDD_Email_Delivery_Reminder' == $key ) {
294 $value->id = 'orddd_delivery_reminder_customer';
295 }
296 if ( 'WCVendors_Admin_Notify_Approved' == $key ) {
297 $value->id = 'admin_notify_approved';
298 }
299 if ( ! array_key_exists( $value->id, $settingEnableDisables ) ) {
300 $settingEnableDisables[ $value->id ] = '0';
301 }
302 }
303
304 $this->emails = apply_filters( 'YaymailCreateFollowUpTemplates', $this->emails );
305 $settingEnableDisables = apply_filters( 'YaymailCreateSelectFollowUpTemplates', $settingEnableDisables );
306
307 $this->emails = apply_filters( 'YaymailCreateAutomateWooTemplates', $this->emails );
308 $settingEnableDisables = apply_filters( 'YaymailCreateSelectAutomateWooTemplates', $settingEnableDisables );
309
310 $this->emails = apply_filters( 'YaymailCreateTrackShipWooTemplates', $this->emails );
311 $settingEnableDisables = apply_filters( 'YaymailCreateSelectTrackShipWooTemplates', $settingEnableDisables );
312
313 $this->emails = apply_filters( 'YaymailCreateWCFMWooFMTemplates', $this->emails );
314 $settingEnableDisables = apply_filters( 'YaymailCreateSelectWCFMWooFMTemplates', $settingEnableDisables );
315
316 $this->emails = apply_filters( 'YaymailCreateGermanMarketTemplates', $this->emails );
317
318 $this->emails = apply_filters( 'YaymailCreateListYWCESTemplates', $this->emails );
319 $settingEnableDisables = apply_filters( 'YaymailCreateSelectYWCESTemplates', $settingEnableDisables );
320
321 $settingDefaultGenerals = array(
322 'payment' => 2,
323 'product_image' => 0,
324 'image_size' => 'thumbnail',
325 'image_width' => '30px',
326 'image_height' => '30px',
327 'product_sku' => 1,
328 'product_des' => 0,
329 'product_hyper_links' => 0,
330 'product_regular_price' => 0,
331 'product_item_cost' => 0,
332 'background_color_table_items' => '#e5e5e5',
333 'content_items_color' => '#636363',
334 'title_items_color' => '#7f54b3',
335 'container_width' => '605px',
336 'order_url' => '',
337 'custom_css' => '',
338 'enable_css_custom' => 'no',
339 'image_position' => 'Top',
340 );
341 $settingGenerals = get_option( 'yaymail_settings' ) ? get_option( 'yaymail_settings' ) : $settingDefaultGenerals;
342 foreach ( $settingDefaultEnableDisable as $keyDefaultEnableDisable => $settingDefaultEnableDisable ) {
343 if ( ! array_key_exists( $keyDefaultEnableDisable, $settingEnableDisables ) ) {
344 $settingEnableDisables[ $keyDefaultEnableDisable ] = $settingDefaultEnableDisable;
345 };
346 }
347 $settings['enableDisable'] = $settingEnableDisables;
348
349 /*
350 @@@@ General
351 @@@@ note: Note the default value section is required when displaying in vue
352 */
353
354 $settingGenerals = get_option( 'yaymail_settings' ) ? get_option( 'yaymail_settings' ) : $settingDefaultGenerals;
355 foreach ( $settingDefaultGenerals as $keyDefaultGeneral => $settingGeneral ) {
356 if ( ! array_key_exists( $keyDefaultGeneral, $settingGenerals ) ) {
357 $settingGenerals[ $keyDefaultGeneral ] = $settingDefaultGenerals[ $keyDefaultGeneral ];
358 };
359 }
360
361 $settingGenerals['direction_rtl'] = get_option( 'yaymail_direction' ) ? get_option( 'yaymail_direction' ) : 'ltr';
362 $settings['general'] = $settingGenerals;
363
364 $scriptId = $this->getPageId();
365 $order = CustomPostType::getListOrders();
366
367 wp_deregister_script( 'vue' );
368 wp_deregister_script( 'vuex' );
369
370 wp_enqueue_script( 'vue', YAYMAIL_PLUGIN_URL . ( YAYMAIL_DEBUG ? 'assets/libs/vue.js' : 'assets/libs/vue.min.js' ), '', YAYMAIL_VERSION, true );
371 wp_enqueue_script( 'vuex', YAYMAIL_PLUGIN_URL . 'assets/libs/vuex.js', '', YAYMAIL_VERSION, true );
372
373 wp_enqueue_script( $scriptId, YAYMAIL_PLUGIN_URL . 'assets/dist/js/main.js', array( 'jquery' ), YAYMAIL_VERSION, true );
374 wp_enqueue_style( $scriptId, YAYMAIL_PLUGIN_URL . 'assets/dist/css/main.css', array(), YAYMAIL_VERSION );
375
376 wp_enqueue_script( $scriptId . '-script', YAYMAIL_PLUGIN_URL . 'assets/admin/js/script.js', '', YAYMAIL_VERSION, true );
377 wp_enqueue_script( $scriptId . '-plugin-install', YAYMAIL_PLUGIN_URL . 'assets/admin/js/plugin-install.js', '', YAYMAIL_VERSION, true );
378 $yaymailSettings = get_option( 'yaymail_settings' );
379
380 // Load ACE Editor -Start
381 if ( isset( $yaymailSettings['enable_css_custom'] ) && 'yes' == $yaymailSettings['enable_css_custom'] ) {
382 wp_enqueue_script( $scriptId . 'ace-script', YAYMAIL_PLUGIN_URL . 'assets/aceeditor/ace.js', '', YAYMAIL_VERSION, true );
383 wp_enqueue_script( $scriptId . 'ace1-script', YAYMAIL_PLUGIN_URL . 'assets/aceeditor/ext-language_tools.js', '', YAYMAIL_VERSION, true );
384 wp_enqueue_script( $scriptId . 'ace2-script', YAYMAIL_PLUGIN_URL . 'assets/aceeditor/mode-css.js', '', YAYMAIL_VERSION, true );
385 wp_enqueue_script( $scriptId . 'ace3-script', YAYMAIL_PLUGIN_URL . 'assets/aceeditor/theme-merbivore_soft.js', '', YAYMAIL_VERSION, true );
386 wp_enqueue_script( $scriptId . 'ace4-script', YAYMAIL_PLUGIN_URL . 'assets/aceeditor/worker-css.js', '', YAYMAIL_VERSION, true );
387 wp_enqueue_script( $scriptId . 'ace5-script', YAYMAIL_PLUGIN_URL . 'assets/aceeditor/snippets/css.js ', '', YAYMAIL_VERSION, true );
388 } else {
389 wp_dequeue_script( $scriptId . 'ace-script' );
390 wp_dequeue_script( $scriptId . 'ace1-script' );
391 wp_dequeue_script( $scriptId . 'ace2-script' );
392 wp_dequeue_script( $scriptId . 'ace3-script' );
393 wp_dequeue_script( $scriptId . 'ace4-script' );
394 wp_dequeue_script( $scriptId . 'ace5-script' );
395 }
396 // Load ACE Editor -End
397 // Css for page admin of WordPress.
398 wp_enqueue_style( $scriptId . '-css', YAYMAIL_PLUGIN_URL . 'assets/admin/css/css.css', array(), YAYMAIL_VERSION );
399 $current_user = wp_get_current_user();
400 $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;
401 $element = new DefaultElement();
402 $yaymailSettingsDefaultLogo = get_option( 'yaymail_settings_default_logo' );
403 $setDefaultLogo = false != $yaymailSettingsDefaultLogo ? $yaymailSettingsDefaultLogo['set_default'] : '0';
404 $yaymailSettingsDefaultFooter = get_option( 'yaymail_settings_default_footer' );
405 $setDefaultFooter = false != $yaymailSettingsDefaultFooter ? $yaymailSettingsDefaultFooter['set_default'] : '0';
406 if ( isset( $_GET['template'] ) || ! empty( $_GET['template'] ) ) {
407 $req_template['id'] = sanitize_text_field( $_GET['template'] );
408 } else {
409 $req_template['id'] = 'new_order';
410 }
411 foreach ( $this->emails as $value ) {
412 if ( is_array( $value ) ) {
413 if ( $value['id'] == $req_template['id'] ) {
414 $req_template['title'] = $value['title'];
415 }
416 } else {
417 if ( $value->id == $req_template['id'] ) {
418 $req_template['title'] = $value->title;
419 }
420 }
421 }
422
423 $allowed_html_tags = wp_kses_allowed_html( 'post' );
424 $allowed_html_tags['style'] = array();
425
426 // List email supported
427 $list_email_supported = PluginSupported::listAddonSupported();
428 $list_plugin_for_pro = PluginSupported::listPluginForProSupported();
429
430 $orderby = 'name';
431 $order_category = 'asc';
432 $hide_empty = false;
433
434 $cat_args = array(
435 'orderby' => $orderby,
436 'order' => $order_category,
437 'hide_empty' => $hide_empty,
438 );
439
440 $product_categories = get_terms( 'product_cat', $cat_args );
441 $les_promenades_fantomes = get_terms( 'les-promenades-fantomes', $cat_args );
442 $promas_service = get_terms( 'promas-service', $cat_args );
443 $billing_country = WC()->countries->countries;
444 $arr_payment_methods = array();
445 $payment_methods = WC()->payment_gateways->payment_gateways;
446 foreach ( $payment_methods as $key => $item ) {
447 if ( 'yes' == $item->enabled ) {
448 $arr_payment_methods[] = array(
449 'id' => $item->id,
450 'method_title' => ! empty( $item->method_title ) ? $item->method_title : $item->title,
451 );
452 }
453 }
454
455 $get_shipping_methods = WC()->shipping->get_shipping_methods();
456 $data = array();
457 foreach ( $get_shipping_methods as $shipping_method ) {
458 $item = array(
459 'id' => $shipping_method->id,
460 'method_title' => $shipping_method->method_title,
461 );
462
463 $data[] = $item;
464 }
465
466 $shipping_methods = $data;
467
468 $data_coupon_codes = array();
469 if ( is_plugin_active( 'yaymail-addon-conditional-logic/yaymail-conditional-logic.php' ) ) {
470 global $wpdb;
471 $get_coupon_codes = $wpdb->get_col( "SELECT post_name FROM $wpdb->posts WHERE post_type = 'shop_coupon' AND post_status = 'publish' ORDER BY post_name ASC LIMIT 100" );
472 foreach ( $get_coupon_codes as $coupon_codes ) {
473 $item = array(
474 'id' => $coupon_codes,
475 'coupon_codes' => $coupon_codes,
476 );
477
478 $data_coupon_codes[] = $item;
479 }
480 }
481 $coupon_codes = $data_coupon_codes;
482
483 $arrayShortCode = array();
484 $yaymail_informations = Helper::inforShortcode( '', '', array() );
485 $shortcodeCustom = array_keys( apply_filters( 'yaymail_customs_shortcode', array(), $yaymail_informations, '' ) );
486 if ( ! empty( $shortcodeCustom ) ) {
487 $arrItemShortcodeCus = array();
488 foreach ( $shortcodeCustom as $item ) {
489 $name = __( 'Custom Shortcode For ', 'yaymail' ) . ucfirst( str_replace( array( '[', ']', 'yaymail_custom_shortcode_' ), '', $item ) );
490 array_push( $arrItemShortcodeCus, array( $item, $name ) );
491 }
492 $arrayShortCode[] = array(
493 'plugin' => __( 'Custom Shortcode', 'yaymail' ),
494 'shortcode' => $arrItemShortcodeCus,
495 );
496 }
497
498 $listShortCodeAddon = apply_filters( 'yaymail_list_shortcodes', $arrayShortCode );
499 //WooCommerce for LatePoint
500 if ( class_exists( 'TechXelaLatePointPaymentsWooCommerce' ) ) {
501 $listShortCodeAddon[] = array(
502 'plugin' => 'WooCommerce for LatePoint',
503 'shortcode' => array(
504 array( '[yaymail_woo_latepoint_booking_detail]', 'WooCommerce Latepoint Booking Detail' ),
505
506 array( '[yaymail_woo_latepoint_caption]', 'WooCommerce Latepoint caption' ),
507 array( '[yaymail_woo_latepoint_bg_color]', 'WooCommerce Latepoint Bg Color' ),
508 array( '[yaymail_woo_latepoint_text_color]', 'WooCommerce Latepoint Text Color' ),
509 array( '[yaymail_woo_latepoint_font_size]', 'WooCommerce Latepoint Font Size' ),
510 array( '[yaymail_woo_latepoint_border]', 'WooCommerce Latepoint Border' ),
511 array( '[yaymail_woo_latepoint_border_radius]', 'WooCommerce Latepoint Border Radius' ),
512 array( '[yaymail_woo_latepoint_margin]', 'WooCommerce Latepoint Margin' ),
513 array( '[yaymail_woo_latepoint_padding]', 'WooCommerce Latepoint Padding' ),
514 array( '[yaymail_woo_latepoint_css]', 'WooCommerce Latepoint css' ),
515 array( '[yaymail_woo_latepoint_show_locations]', 'WooCommerce Latepoint Show Locations' ),
516 array( '[yaymail_woo_latepoint_show_agents]', 'WooCommerce Latepoint Show Agents' ),
517 array( '[yaymail_woo_latepoint_show_services]', 'WooCommerce Latepoint Show Services' ),
518 array( '[yaymail_woo_latepoint_show_service_categories]', 'WooCommerce Latepoint Show Service Sategories' ),
519 array( '[yaymail_woo_latepoint_selected_location]', 'WooCommerce Latepoint Selected Location' ),
520 array( '[yaymail_woo_latepoint_selected_agent]', 'WooCommerce Latepoint Selected Agent' ),
521 array( '[yaymail_woo_latepoint_selected_service]', 'WooCommerce Latepoint Selected Service' ),
522 array( '[yaymail_woo_latepoint_selected_service_category]', 'WooCommerce Latepoint Selected Service Category' ),
523 array( '[yaymail_woo_latepoint_selected_duration]', 'WooCommerce Latepoint Selected Duration' ),
524 array( '[yaymail_woo_latepoint_selected_total_attendees]', 'WooCommerce Latepoint Selected Total Attendees' ),
525 array( '[yaymail_woo_latepoint_hide_side_panel]', 'WooCommerce Latepoint Hide Side Panel' ),
526 array( '[yaymail_woo_latepoint_hide_summary]', 'WooCommerce Latepoint Hide Summary' ),
527 array( '[yaymail_woo_latepoint_calendar_start_date]', 'WooCommerce Latepoint Calendar Start Date' ),
528
529 ),
530 );
531 }
532
533 $this->emails = array_map(
534 function( $item ) {
535 $final_item = new stdClass();
536
537 if ( is_array( $item ) ) {
538 $final_item->id = $item['id'];
539 $final_item->title = $item['title'];
540 } else {
541 $final_item->id = $item->id;
542 $final_item->title = $item->title;
543 }
544
545 return $final_item;
546 },
547 $this->emails
548 );
549 wp_localize_script(
550 $scriptId,
551 'yaymail_data',
552 array(
553 'orders' => $order,
554 'imgUrl' => YAYMAIL_PLUGIN_URL . 'assets/dist/images',
555 'nonce' => wp_create_nonce( 'email-nonce' ),
556 'defaultDataElement' => $element->defaultDataElement,
557 'home_url' => home_url(),
558 'settings' => $settings,
559 'admin_url' => get_admin_url(),
560 'yaymail_plugin_url' => YAYMAIL_PLUGIN_URL,
561 'wc_emails' => $this->emails,
562 'default_email_test' => $default_email_test,
563 'template' => $req_template,
564 'set_default_logo' => $setDefaultLogo,
565 'set_default_footer' => $setDefaultFooter,
566 'list_plugin_for_pro' => $list_plugin_for_pro,
567 'plugins' => apply_filters( 'yaymail_plugins', array() ),
568 'list_email_supported' => $list_email_supported,
569 'product_categories' => $product_categories,
570 'les_promenades_fantomes' => $les_promenades_fantomes,
571 'promas_service' => $promas_service,
572 'billing_country' => $billing_country,
573 'payment_methods' => $arr_payment_methods,
574 'link_detail_smtp' => self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=yaysmtp&section=description&TB_iframe=true&width=600&height=800' ),
575 'yaymail_automatewoo_active' => ( is_plugin_active( 'yaymail-addon-for-automatewoo/yaymail-automatewoo.php' ) || is_plugin_active( 'email-customizer-automatewoo/yaymail-automatewoo.php' ) ) ? true : false,
576 'yaymail_dokan_active' => is_plugin_active( 'yaymail-addon-for-dokan/yaymail-premium-addon-dokan.php' ) ? true : false,
577 'yaysmtp_active' => $this->check_plugin_installed( 'yaysmtp/yay-smtp.php' ) || $this->check_plugin_installed( 'yaysmtp-pro/yay-smtp.php' ) ? true : false,
578 'yaysmtp_setting' => admin_url( 'admin.php?page=yaysmtp' ),
579 'list_shortcode_addon' => $listShortCodeAddon,
580 'shipping_methods' => $shipping_methods,
581 'coupon_codes' => $coupon_codes,
582 'i18n' => I18n::jsTranslate(),
583 )
584 );
585 do_action( 'yaymail_enqueue_script_conditional_logic' );
586 do_action( 'yaymail_before_enqueue_dependence' );
587 }
588 wp_enqueue_script( 'yaymail-notice', YAYMAIL_PLUGIN_URL . 'assets/admin/js/notice.js', array( 'jquery' ), YAYMAIL_VERSION, false );
589 wp_localize_script(
590 'yaymail-notice',
591 'yaymail_notice',
592 array(
593 'admin_ajax' => admin_url( 'admin-ajax.php' ),
594 'nonce' => wp_create_nonce( 'yaymail_nonce' ),
595 )
596 );
597 }
598 public function getPageId() {
599 if ( null == $this->pageId ) {
600 $this->pageId = YAYMAIL_PREFIX . '-settings';
601 }
602
603 return $this->pageId;
604 }
605 public function check_plugin_installed( $plugin_slug ) {
606 $installed_plugins = get_plugins();
607 return array_key_exists( $plugin_slug, $installed_plugins ) || in_array( $plugin_slug, $installed_plugins, true );
608 }
609 }
610