Kadence WooCommerce Email Designer - Version 1.1.3

Version Description

  • Fix: Issue with WP Multilang.
  • Add: {year} for use in the footer.
  • Fix: Force image to refreash email loaded so settings work.
Download this release

Release Info

Developer britner
Plugin Icon 128x128 Kadence WooCommerce Email Designer
Version 1.1.3
Comparing to
See all releases

Code changes from version 1.1.1 to 1.1.3

includes/class-kadence-woomail-customizer.php CHANGED
@@ -32,58 +32,70 @@ class Kadence_Woomail_Customizer {
32
  return self::$instance;
33
  }
34
 
35
- /**
36
- * Class constructor
37
- *
38
- * @access public
39
- * @return void
40
- */
41
- public function __construct() {
42
- // Add settings
43
- add_action('customize_register', array( $this, 'add_settings' ) );
44
 
45
- // Maybe add custom styles to default WooCommerce styles
46
- add_filter( 'woocommerce_email_styles', array( $this, 'maybe_add_custom_styles' ), 99 );
47
 
48
- // Ajax handler
49
- add_action( 'wp_ajax_kt_woomail_reset', array( $this, 'ajax_reset' ) );
50
 
51
- // Ajax handler
52
- add_action( 'wp_ajax_kt_woomail_send_email', array( $this, 'ajax_send_email' ) );
53
 
54
- // Only proceed if this is own request
55
- if ( ! Kadence_Woomail_Designer::is_own_customizer_request() && ! Kadence_Woomail_Designer::is_own_preview_request() ) {
56
- return;
57
- }
58
 
59
- // Add controls, sections and panels
60
- add_action('customize_register', array( $this, 'add_controls'));
61
 
62
- // Add user capability
63
- add_filter('user_has_cap', array( $this, 'add_customize_capability'), 99);
64
 
65
- // Remove unrelated components
66
- add_filter('customize_loaded_components', array( $this, 'remove_unrelated_components'), 99, 2);
67
 
68
- // Remove unrelated sections
69
- add_filter('customize_section_active', array( $this, 'remove_unrelated_sections'), 99, 2);
70
 
71
- // Remove unrelated controls
72
- add_filter('customize_control_active', array( $this, 'remove_unrelated_controls'), 99, 2);
73
 
74
- // Enqueue Customizer scripts
75
- add_filter( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_customizer_scripts' ) );
76
 
77
- // Changes the publish text to save.
78
- add_filter( 'gettext', array( $this, 'change_publish_button' ), 10, 2 );
79
 
80
- // This filters in woocommerce edits that are not saved while the preview refreshes
81
- add_action( 'init', array( $this, 'get_customizer_options_override_ready' ) );
82
 
83
- // Unhook divi front end
84
- add_action( 'woomail_footer', array( $this, 'unhook_divi' ), 10 );
85
 
86
- }
 
 
 
 
 
 
 
 
 
 
 
 
87
  /*
88
  * Unhook Divi front end.
89
  */
@@ -125,39 +137,39 @@ class Kadence_Woomail_Customizer {
125
  return $translation;
126
  }
127
 
128
- /**
129
- * Add customizer capability
130
- *
131
- * @access public
132
- * @param array $capabilities
133
- * @return array
134
- */
135
- public function add_customize_capability( $capabilities ) {
136
- // Remove filter (circular reference)
137
- remove_filter('user_has_cap', array($this, 'add_customize_capability'), 99);
138
-
139
- // Add customize capability for admin user if this is own customizer request
140
- if ( Kadence_Woomail_Designer::is_admin() && Kadence_Woomail_Designer::is_own_customizer_request() ) {
141
- $capabilities['customize'] = true;
142
- }
143
 
144
- // Add filter
145
- add_filter('user_has_cap', array($this, 'add_customize_capability'), 99);
146
 
147
- // Return capabilities
148
- return $capabilities;
149
- }
150
 
151
  /**
152
- * Get Customizer URL
153
- *
154
- */
155
  public static function get_customizer_url() {
156
  if ( is_null( Kadence_Woomail_Customizer::$customizer_url ) ) {
157
  Kadence_Woomail_Customizer::$customizer_url = add_query_arg( array(
158
- 'kt-woomail-customize' => '1',
159
- 'url' => urlencode( add_query_arg( array( 'kt-woomail-preview' => '1' ), home_url('/') ) ),
160
- 'return' => urlencode( Kadence_Woomail_Woo::get_email_settings_page_url() ),
161
  ), admin_url( 'customize.php' ) );
162
  }
163
 
@@ -650,14 +662,14 @@ class Kadence_Woomail_Customizer {
650
  // Only add CSS properties
651
  if (isset($setting['live_method']) && $setting['live_method'] === 'css') {
652
 
653
- // Iterate over selectors
654
- foreach ($setting['selectors'] as $selector => $properties) {
655
 
656
  // Iterate over properties
657
  foreach ($properties as $property) {
658
 
659
  // Add value to styles array
660
- $styles_array[$selector][$property] = Kadence_Woomail_Customizer::opt($setting_key, $selector);
661
  }
662
  }
663
  }
@@ -883,11 +895,11 @@ class Kadence_Woomail_Customizer {
883
  * @return void
884
  */
885
  public static function reset( $wp_customize ) {
886
- update_option( 'kt_woomail', array() );
887
- // Load the export/import option class.
888
  require_once KT_WOOMAIL_PATH . 'includes/class-kadence-woomail-import-option.php';
889
- //Run through the woocommerce settings we are overriding
890
- foreach ( Kadence_Woomail_Settings::get_woo_settings() as $setting_key => $setting ) {
891
  $option = new Kadence_Woomail_Import_Option( $wp_customize, $setting_key, array(
892
  'default' => '',
893
  'type' => 'option',
@@ -904,7 +916,7 @@ class Kadence_Woomail_Customizer {
904
  } else {
905
  $option->import( '' );
906
  }
907
- }
908
  }
909
 
910
  /**
32
  return self::$instance;
33
  }
34
 
35
+ /**
36
+ * Class constructor
37
+ *
38
+ * @access public
39
+ * @return void
40
+ */
41
+ public function __construct() {
42
+ // Add settings.
43
+ add_action('customize_register', array( $this, 'add_settings' ) );
44
 
45
+ // Maybe add custom styles to default WooCommerce styles.
46
+ add_filter( 'woocommerce_email_styles', array( $this, 'maybe_add_custom_styles' ), 99 );
47
 
48
+ // Ajax handler.
49
+ add_action( 'wp_ajax_kt_woomail_reset', array( $this, 'ajax_reset' ) );
50
 
51
+ // Ajax handler.
52
+ add_action( 'wp_ajax_kt_woomail_send_email', array( $this, 'ajax_send_email' ) );
53
 
54
+ // Only proceed if this is own request.
55
+ if ( ! Kadence_Woomail_Designer::is_own_customizer_request() && ! Kadence_Woomail_Designer::is_own_preview_request() ) {
56
+ return;
57
+ }
58
 
59
+ // Add controls, sections and panels.
60
+ add_action( 'customize_register', array( $this, 'add_controls' ) );
61
 
62
+ // Add user capability.
63
+ add_filter( 'user_has_cap', array( $this, 'add_customize_capability' ), 99 );
64
 
65
+ // Remove unrelated components.
66
+ add_filter( 'customize_loaded_components', array( $this, 'remove_unrelated_components' ), 99, 2 );
67
 
68
+ // Remove unrelated sections.
69
+ add_filter( 'customize_section_active', array( $this, 'remove_unrelated_sections' ), 99, 2 );
70
 
71
+ // Remove unrelated controls.
72
+ add_filter( 'customize_control_active', array( $this, 'remove_unrelated_controls' ), 99, 2 );
73
 
74
+ // Enqueue Customizer scripts.
75
+ add_filter( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_customizer_scripts' ) );
76
 
77
+ // Changes the publish text to save.
78
+ add_filter( 'gettext', array( $this, 'change_publish_button' ), 10, 2 );
79
 
80
+ // This filters in woocommerce edits that are not saved while the preview refreshes.
81
+ add_action( 'init', array( $this, 'get_customizer_options_override_ready' ) );
82
 
83
+ // WP-Multilang.
84
+ add_filter( 'wpm_customizer_url', array( $this, 'force_fix_wp_multilang' ), 10 );
85
 
86
+ // Unhook divi front end.
87
+ add_action( 'woomail_footer', array( $this, 'unhook_divi' ), 10 );
88
+
89
+ }
90
+
91
+ /*
92
+ * Unhook Divi front end.
93
+ *
94
+ * @param string $url the customizer url.
95
+ */
96
+ public function force_fix_wp_multilang( $url ) {
97
+ return add_query_arg( array( 'kt-woomail-preview' => '1' ), home_url( '/' ) );
98
+ }
99
  /*
100
  * Unhook Divi front end.
101
  */
137
  return $translation;
138
  }
139
 
140
+ /**
141
+ * Add customizer capability
142
+ *
143
+ * @access public
144
+ * @param array $capabilities
145
+ * @return array
146
+ */
147
+ public function add_customize_capability( $capabilities ) {
148
+ // Remove filter (circular reference)
149
+ remove_filter('user_has_cap', array($this, 'add_customize_capability'), 99);
150
+
151
+ // Add customize capability for admin user if this is own customizer request
152
+ if ( Kadence_Woomail_Designer::is_admin() && Kadence_Woomail_Designer::is_own_customizer_request() ) {
153
+ $capabilities['customize'] = true;
154
+ }
155
 
156
+ // Add filter
157
+ add_filter('user_has_cap', array($this, 'add_customize_capability'), 99);
158
 
159
+ // Return capabilities
160
+ return $capabilities;
161
+ }
162
 
163
  /**
164
+ * Get Customizer URL
165
+ *
166
+ */
167
  public static function get_customizer_url() {
168
  if ( is_null( Kadence_Woomail_Customizer::$customizer_url ) ) {
169
  Kadence_Woomail_Customizer::$customizer_url = add_query_arg( array(
170
+ 'kt-woomail-customize' => '1',
171
+ 'url' => urlencode( add_query_arg( array( 'kt-woomail-preview' => '1' ), home_url( '/' ) ) ),
172
+ 'return' => urlencode( Kadence_Woomail_Woo::get_email_settings_page_url() ),
173
  ), admin_url( 'customize.php' ) );
174
  }
175
 
662
  // Only add CSS properties
663
  if (isset($setting['live_method']) && $setting['live_method'] === 'css') {
664
 
665
+ // Iterate over selectors.
666
+ foreach ( $setting['selectors'] as $selector => $properties ) {
667
 
668
  // Iterate over properties
669
  foreach ($properties as $property) {
670
 
671
  // Add value to styles array
672
+ $styles_array[$selector][$property] = Kadence_Woomail_Customizer::opt( $setting_key, $selector );
673
  }
674
  }
675
  }
895
  * @return void
896
  */
897
  public static function reset( $wp_customize ) {
898
+ update_option( 'kt_woomail', array() );
899
+ // Load the export/import option class.
900
  require_once KT_WOOMAIL_PATH . 'includes/class-kadence-woomail-import-option.php';
901
+ // Run through the woocommerce settings we are overriding.
902
+ foreach ( Kadence_Woomail_Settings::get_woo_settings() as $setting_key => $setting ) {
903
  $option = new Kadence_Woomail_Import_Option( $wp_customize, $setting_key, array(
904
  'default' => '',
905
  'type' => 'option',
916
  } else {
917
  $option->import( '' );
918
  }
919
+ }
920
  }
921
 
922
  /**
includes/class-kadence-woomail-preview.php CHANGED
@@ -1,66 +1,66 @@
1
  <?php
2
 
3
- // Exit if accessed directly
4
- if (!defined('ABSPATH')) {
5
- exit;
6
  }
7
 
8
  /**
9
- * Customizer Setup
10
- * Heavily borrowed from rightpress Decorator
11
  */
12
  if ( ! class_exists( 'Kadence_Woomail_Preview' ) ) {
13
 
14
  class Kadence_Woomail_Preview {
15
  // WooCommerce email classes
16
- public static $current_order = null;
17
- public static $current_product_title = null;
18
- public static $current_recipients = null;
19
- public static $email_types_class_names = array(
20
- 'new_order' => 'WC_Email_New_Order',
21
- 'cancelled_order' => 'WC_Email_Cancelled_Order',
22
- 'customer_processing_order' => 'WC_Email_Customer_Processing_Order',
23
  'customer_completed_order' => 'WC_Email_Customer_Completed_Order',
24
  'customer_refunded_order' => 'WC_Email_Customer_Refunded_Order',
25
  'customer_on_hold_order' => 'WC_Email_Customer_On_Hold_Order',
26
- 'customer_invoice' => 'WC_Email_Customer_Invoice',
27
- 'failed_order' => 'WC_Email_Failed_Order',
28
- 'customer_new_account' => 'WC_Email_Customer_New_Account',
29
- 'customer_note' => 'WC_Email_Customer_Note',
30
  'customer_reset_password' => 'WC_Email_Customer_Reset_Password',
31
  // WooCommerce Subscriptions Plugin
32
- 'new_renewal_order' => 'WCS_Email_New_Renewal_Order',
33
- 'customer_processing_renewal_order' => 'WCS_Email_Processing_Renewal_Order',
34
- 'customer_completed_renewal_order' => 'WCS_Email_Completed_Renewal_Order',
35
- 'customer_completed_switch_order' => 'WCS_Email_Completed_Switch_Order',
36
- 'customer_renewal_invoice' => 'WCS_Email_Customer_Renewal_Invoice',
37
- 'customer_payment_retry' => 'WCS_Email_Customer_Payment_Retry',
38
- 'cancelled_subscription' => 'WCS_Email_Cancelled_Subscription',
39
  // Waitlist Plugin
40
- 'woocommerce_waitlist_mailout' => 'Pie_WCWL_Waitlist_Mailout',
41
  );
42
  public static $email_types_order_status = array(
43
- 'new_order' => 'processing',
44
- 'cancelled_order' => 'cancelled',
45
- 'customer_processing_order' => 'processing',
46
  'customer_completed_order' => 'completed',
47
  'customer_refunded_order' => 'refunded',
48
  'customer_on_hold_order' => 'on-hold',
49
- 'customer_invoice' => 'processing',
50
- 'failed_order' => 'failed',
51
- 'customer_new_account' => null,
52
- 'customer_note' => 'processing',
53
  'customer_reset_password' => null,
54
- // WooCommerce Subscriptions Plugin
55
- 'new_renewal_order' => 'processing',
56
- 'customer_processing_renewal_order' => 'processing',
57
- 'customer_completed_renewal_order' => 'completed',
58
- 'customer_completed_switch_order' => 'completed',
59
- 'customer_renewal_invoice' => 'failed',
60
- 'customer_payment_retry' => 'on-hold',
61
- 'cancelled_subscription' => 'cancelled',
62
  // Waitlist Plugin
63
- 'woocommerce_waitlist_mailout' => null,
64
  );
65
  /**
66
  * @var null
@@ -77,43 +77,43 @@ if ( ! class_exists( 'Kadence_Woomail_Preview' ) ) {
77
  return self::$instance;
78
  }
79
 
80
- /**
81
- * Class constructor
82
- *
83
- * @access public
84
- * @return void
85
- */
86
  public function __construct() {
87
- // Set up preview
88
  add_action( 'parse_request', array( $this, 'set_up_preview' ) );
89
  }
90
 
91
- /**
92
- * Set up preview
93
- *
94
- * @access public
95
- * @return void
96
- */
97
  public function set_up_preview() {
98
- // Make sure this is own preview request
99
  if ( ! Kadence_Woomail_Designer::is_own_preview_request() ) {
100
  return;
101
  }
102
- // Load main view
103
  include KT_WOOMAIL_PATH . 'preview.php';
104
 
105
- // Do not load any further elements
106
  exit;
107
  }
108
 
109
  /**
110
  * Get the email order status
111
- *
112
  */
113
  public static function get_email_order_status( $email_template ) {
114
  $order_status = apply_filters( 'kadence_woomail_email_type_order_status_array', Kadence_Woomail_Preview::$email_types_order_status );
115
- if ( isset( $order_status[$email_template] ) ) {
116
- return $order_status[$email_template];
117
  } else {
118
  return false;
119
  }
@@ -124,8 +124,8 @@ if ( ! class_exists( 'Kadence_Woomail_Preview' ) ) {
124
  */
125
  public static function get_email_class_name( $email_template ) {
126
  $class_names = apply_filters( 'kadence_woomail_email_type_class_name_array', Kadence_Woomail_Preview::$email_types_class_names );
127
- if ( isset( $class_names[$email_template] ) ) {
128
- return $class_names[$email_template];
129
  } else {
130
  return 'processing';
131
  }
@@ -135,29 +135,28 @@ if ( ! class_exists( 'Kadence_Woomail_Preview' ) ) {
135
  *
136
  */
137
  public static function get_preview_email( $send_email = false, $email_addresses = null ) {
138
- // Load WooCommerce emails
139
- $wc_emails = WC_Emails::instance();
140
- $emails = $wc_emails->get_emails();
141
- $email_template = Kadence_Woomail_Customizer::opt('email_type');
142
- $preview_id = Kadence_Woomail_Customizer::opt('preview_order_id');
143
- $email_type = Kadence_Woomail_Preview::get_email_class_name( $email_template );
144
  if ( false === $email_type ) {
145
  return false;
146
  }
147
  $order_status = Kadence_Woomail_Preview::get_email_order_status( $email_template );
148
 
149
-
150
  //$order_status = Kadence_Woomail_Preview::$email_types_order_status[$email_template];
151
 
152
- if ('customer_invoice' == $email_template ) {
153
- $invoice_paid = Kadence_Woomail_Customizer::opt('customer_invoice_switch');
154
- if ( ! $invoice_paid ){
155
  $order_status = 'pending';
156
  }
157
  }
158
- if ('customer_refunded_order' == $email_template ) {
159
- $partial_preview = Kadence_Woomail_Customizer::opt('customer_refunded_order_switch');
160
- if ( ! $partial_preview ){
161
  $partial_status = true;
162
  } else {
163
  $partial_status = false;
@@ -169,13 +168,14 @@ if ( ! class_exists( 'Kadence_Woomail_Preview' ) ) {
169
  };
170
 
171
  // Get an order
172
- $order = Kadence_Woomail_Preview::get_wc_order_for_preview( $order_status, $preview_id );
173
  self::$current_order = $order;
 
174
  if ( is_object( $order ) ) {
175
  // Get user ID from order, if guest get current user ID.
176
- if ( 0 === ( $user_id = (int) get_post_meta( $order->get_id(), '_customer_user', TRUE ) ) ) {
177
  $user_id = get_current_user_id();
178
- }
179
  } else {
180
  $user_id = get_current_user_id();
181
  }
@@ -185,25 +185,25 @@ if ( ! class_exists( 'Kadence_Woomail_Preview' ) ) {
185
  if ( 'woocommerce_waitlist_mailout' == $email_template ) {
186
 
187
  $product_id = -1;
188
-
189
  if ( is_object( $order ) ) {
190
  $items = $order->get_items();
191
  foreach ( $items as $item ) {
192
  $product_id = $item['product_id'];
193
- if ( NULL !== get_post( $product_id ) ){
194
  break;
195
  }
196
  }
197
  }
198
 
199
- if ( NULL === get_post( $product_id ) ) {
200
 
201
- $products_array = get_posts( array(
202
- 'posts_per_page' => 1,
203
- 'orderby' => 'date',
204
- 'post_type' => 'product',
205
- 'post_status' => 'publish',
206
- ) );
 
207
 
208
  if ( isset( $products_array[0]->ID ) ) {
209
  $product_id = $products_array[0]->ID;
@@ -218,11 +218,9 @@ if ( ! class_exists( 'Kadence_Woomail_Preview' ) ) {
218
  WC()->shipping();
219
 
220
  switch ( $email_template ) {
221
-
222
  /**
223
  * WooCommerce (default transactional mails).
224
  */
225
-
226
  case 'new_order':
227
  case 'cancelled_order':
228
  case 'customer_processing_order':
@@ -230,42 +228,39 @@ if ( ! class_exists( 'Kadence_Woomail_Preview' ) ) {
230
  case 'customer_on_hold_order':
231
  case 'customer_invoice':
232
  case 'failed_order':
233
-
234
- $email->object = $order;
235
- $email->find['order-date'] = '{order_date}';
236
- $email->find['order-number'] = '{order_number}';
237
- $email->replace['order-date'] = wc_format_datetime( $email->object->get_date_created() );
238
- $email->replace['order-number'] = $email->object->get_order_number();
239
- // Other properties
240
- $email->recipient = $email->object->get_billing_email();
 
241
  break;
242
-
243
  case 'customer_refunded_order':
244
-
245
- $email->object = $order;
246
- $email->partial_refund = $partial_status;
247
- $email->find['order-date'] = '{order_date}';
248
- $email->find['order-number'] = '{order_number}';
249
- $email->replace['order-date'] = wc_format_datetime( $email->object->get_date_created() );
250
- $email->replace['order-number'] = $email->object->get_order_number();
251
- // Other properties
252
- $email->recipient = $email->object->get_billing_email();
 
253
  break;
254
-
255
  case 'customer_new_account':
256
-
257
  $email->object = $user;
258
  $email->user_pass = '{user_pass}';
259
  $email->user_login = stripslashes( $email->object->user_login );
260
  $email->user_email = stripslashes( $email->object->user_email );
261
  $email->recipient = $email->user_email;
262
- $email->password_generated = TRUE;
263
  break;
264
-
265
  case 'customer_note':
266
-
267
  $email->object = $order;
268
- $email->customer_note = __('Hello! This is an example note', 'kadence-woocommerce-email-designer');
269
  $email->find['order-date'] = '{order_date}';
270
  $email->find['order-number'] = '{order_number}';
271
  $email->replace['order-date'] = wc_format_datetime( $email->object->get_date_created() );
@@ -273,86 +268,69 @@ if ( ! class_exists( 'Kadence_Woomail_Preview' ) ) {
273
  // Other properties
274
  $email->recipient = $email->object->get_billing_email();
275
  break;
276
-
277
  case 'customer_reset_password':
278
-
279
- $email->object = $user;
280
- $email->user_id = $user_id;
281
- $email->user_login = $user->user_login;
282
- $email->user_email = stripslashes( $email->object->user_email );
283
- $email->reset_key = '{{reset-key}}';
284
- $email->recipient = stripslashes( $email->object->user_email );
285
  break;
286
-
287
-
288
  /**
289
  * WooCommerce Subscriptions Plugin (from WooCommerce).
290
  */
291
-
292
  case 'new_renewal_order':
293
  case 'new_switch_order':
294
  case 'customer_processing_renewal_order':
295
  case 'customer_completed_renewal_order':
296
  case 'customer_completed_switch_order':
297
  case 'customer_renewal_invoice':
298
-
299
- $email->object = $order;
300
  $email->find['order-date'] = '{order_date}';
301
  $email->find['order-number'] = '{order_number}';
302
  $email->replace['order-date'] = wc_format_datetime( $email->object->get_date_created() );
303
  $email->replace['order-number'] = $email->object->get_order_number();
304
  // Other properties
305
  $email->recipient = $email->object->get_billing_email();
306
-
307
  break;
308
-
309
  case 'cancelled_subscription':
310
-
311
-
312
  $email->object = false;
313
  break;
314
-
315
  /**
316
  * WooCommerce Wait-list Plugin (from WooCommerce).
317
  */
318
-
319
  case 'woocommerce_waitlist_mailout':
320
-
321
- $email->object = get_product( $product_id );
322
- $email->find[] = '{product_title}';
323
- $email->replace[] = $email->object->get_title();
324
  self::$current_product_title = $email->object->get_title();
325
  break;
326
-
327
  /**
328
  * Everything else.
329
  */
330
-
331
  default:
332
-
333
  $email->object = $order;
334
  // Allow unnamed emails preview to be filtered by plugin
335
- $email = apply_filters('kadence_woomail_preview_email_object', $email );
336
  break;
337
  }
338
 
339
  if ( true === $send_email && ! empty( $email_addresses ) ) {
340
 
341
  self::$current_recipients = $email_addresses;
342
-
343
- add_filter( 'woocommerce_email_recipient_' . $email->id, array('Kadence_Woomail_Preview', 'change_recipient'), 99 );
344
-
345
  if ( $email->get_recipient() ) {
346
  $content = $email->send( $email->get_recipient(), $email->get_subject(), $email->get_content(), $email->get_headers(), $email->get_attachments() );
347
  }
348
 
349
- remove_filter( 'woocommerce_email_recipient_' . $email->id, array('Kadence_Woomail_Preview', 'change_recipient'), 99 );
350
 
351
  } else {
352
- if ( false == $email->object) {
353
- $content = '<div style="padding: 35px 40px; background-color: white;">'.__('This email type can not be previewed because it links with a subscription. We are working on it.', 'kadence-woocommerce-email-designer').'</div>';
354
  } else {
355
-
356
  // Get email content and apply styles
357
  $content = $email->get_content();
358
  $content = $email->style_inline( $content );
@@ -363,7 +341,6 @@ if ( ! class_exists( 'Kadence_Woomail_Preview' ) ) {
363
  }
364
  }
365
  }
366
-
367
  } else {
368
  $content = false;
369
  }
@@ -379,7 +356,7 @@ if ( ! class_exists( 'Kadence_Woomail_Preview' ) ) {
379
  */
380
  public static function change_recipient( $recipient ) {
381
 
382
- if ( ! empty( self::$current_recipients ) ) {
383
  $recipient = self::$current_recipients;
384
  } else {
385
  // Don't send if not set
@@ -396,13 +373,13 @@ if ( ! class_exists( 'Kadence_Woomail_Preview' ) ) {
396
  public static function print_preview_email() {
397
 
398
  $content = Kadence_Woomail_Preview::get_preview_email();
399
- if (false == $content ) {
400
- echo __( 'An error occurred trying to load this email type. Make sure this email type is enabled or please try another type.', 'kadence-woocommerce-email-designer');
401
- } else if( ! empty( $content ) ) {
402
  // Print email content
403
  echo $content;
404
  // Print live preview scripts in footer
405
- add_action('wp_footer', array('Kadence_Woomail_Preview', 'print_live_preview_scripts'), 99);
406
  }
407
  }
408
 
@@ -413,9 +390,8 @@ if ( ! class_exists( 'Kadence_Woomail_Preview' ) ) {
413
  * @return void
414
  */
415
  public static function send_preview_email() {
416
-
417
  $content = Kadence_Woomail_Preview::get_preview_email();
418
- if( ! empty( $content ) ) {
419
  // Print email content
420
  echo $content;
421
  }
@@ -429,7 +405,7 @@ if ( ! class_exists( 'Kadence_Woomail_Preview' ) ) {
429
  * @return object
430
  */
431
  public static function get_wc_order_for_preview( $order_status = null, $order_id = null ) {
432
- if( ! empty( $order_id ) && 'mockup' != $order_id ) {
433
  return wc_get_order( $order_id );
434
  } else {
435
  // Use mockup order (WC 2.7+)
@@ -438,38 +414,38 @@ if ( ! class_exists( 'Kadence_Woomail_Preview' ) ) {
438
  $order = new WC_Order();
439
 
440
  // Other order properties
441
- $order->set_props(array(
442
- 'id' => 1,
443
- 'status' => ($order_status === null ? 'processing' : $order_status),
444
- 'billing_first_name' => 'Sherlock',
445
- 'billing_last_name' => 'Holmes',
446
- 'billing_company' => 'Detectives Ltd.',
447
- 'billing_address_1' => '221B Baker Street',
448
- 'billing_city' => 'London',
449
- 'billing_postcode' => 'NW1 6XE',
450
- 'billing_country' => 'GB',
451
- 'billing_email' => 'sherlock@holmes.co.uk',
452
- 'billing_phone' => '02079304832',
453
- 'date_created' => date('Y-m-d H:i:s'),
454
- 'total' => 24.90,
455
- ));
456
 
457
  // Item #1
458
  $order_item = new WC_Order_Item_Product();
459
- $order_item->set_props(array(
460
- 'name' => 'A Study in Scarlet',
461
- 'subtotal' => '9.95',
462
- 'sku' => 'kwd_ex_1',
463
- ));
464
- $order->add_item($order_item);
465
 
466
  // Item #2
467
  $order_item = new WC_Order_Item_Product();
468
- $order_item->set_props(array(
469
- 'name' => 'The Hound of the Baskervilles',
470
- 'subtotal' => '14.95',
471
- 'sku' => 'kwd_ex_2',
472
- ));
473
  $order->add_item( $order_item );
474
 
475
  // Return mockup order
@@ -492,15 +468,17 @@ if ( ! class_exists( 'Kadence_Woomail_Preview' ) ) {
492
  $scripts .= 'var font_family_mapping = ' . json_encode( Kadence_Woomail_Settings::$font_family_mapping ) . ';';
493
 
494
  // Get information from email to use in placeholders.
495
- $scripts .= 'var pl_site_title = "' . get_bloginfo( 'name', 'display' ).'";';
496
- $scripts .= 'var pl_order_date = "' . wc_format_datetime( self::$current_order->get_date_created() ).'";';
497
- $scripts .= 'var pl_order_number = "' . self::$current_order->get_order_number().'";';
498
- $scripts .= 'var pl_customer_first_name = "' . self::$current_order->get_billing_first_name().'";';
499
- $scripts .= 'var pl_customer_last_name = "' . self::$current_order->get_billing_last_name().'";';
500
- $scripts .= 'var pl_customer_full_name = "' . self::$current_order->get_formatted_billing_full_name().'";';
501
- $scripts .= 'var pl_product_title = "' . self::$current_product_title.'";';
502
-
503
- // Function to handle special cases
 
 
504
  $scripts .= "function prepare(value, key, selector) {
505
  if (key === 'border_radius' && selector === '#template_header') {
506
  value = value.replace('!important', '').trim();
@@ -517,6 +495,9 @@ if ( ! class_exists( 'Kadence_Woomail_Preview' ) ) {
517
  value = '<p style=\"margin-top:0; margin-bottom:0;\"><img src=\"' + value + '\" style=\"border: none; display: inline; font-weight: bold; height: auto; line-height: 100%; outline: none; text-decoration: none; text-transform: capitalize;\" /></p>';
518
  } else if (value && value.includes('{site_title}') ) {
519
  value = value.replace('{site_title}', pl_site_title);
 
 
 
520
  } else if (value && value.includes('{order_date}') ) {
521
  value = value.replace('{order_date}', pl_order_date);
522
  } else if (value && value.includes('{order_number}') ) {
@@ -527,20 +508,21 @@ if ( ! class_exists( 'Kadence_Woomail_Preview' ) ) {
527
  value = value.replace('{customer_last_name}', pl_customer_last_name);
528
  } else if (value && value.includes('{customer_full_name}') ) {
529
  value = value.replace('{customer_full_name}', pl_customer_full_name);
530
- }
531
- else if (value && value.includes('{product_title}') ) {
532
  value = value.replace('{product_title}', pl_product_title);
 
 
533
  }
534
  return value;
535
  }";
536
  // Get CSS suffixes
537
- $scripts .= 'var suffixes = ' . json_encode(Kadence_Woomail_Customizer::get_css_suffix()) . ';';
538
 
539
  // Go through kadence woomail settings
540
  foreach ( Kadence_Woomail_Settings::get_settings() as $setting_key => $setting ) {
541
 
542
  // No live method
543
- if ( ! isset( $setting[ 'live_method' ] ) ) {
544
  continue;
545
  }
546
 
@@ -578,7 +560,7 @@ if ( ! class_exists( 'Kadence_Woomail_Preview' ) ) {
578
 
579
  // HTML Replace
580
  if ( $setting['live_method'] === 'replace' && ! empty( $setting[ 'selectors' ] ) ) {
581
- foreach ( $setting['selectors'] as $selector) {
582
  $original = json_encode( $setting['original'] );
583
  $scripts .= "wp.customize('kt_woomail[$setting_key]', function(value) {
584
  value.bind(function(newval) {
@@ -591,10 +573,10 @@ if ( ! class_exists( 'Kadence_Woomail_Preview' ) ) {
591
  }
592
  }
593
  // Go through woo settings
594
- foreach (Kadence_Woomail_Settings::get_woo_settings() as $setting_key => $setting) {
595
 
596
  // No live method
597
- if ( ! isset( $setting[ 'live_method' ] ) ) {
598
  continue;
599
  }
600
 
@@ -632,7 +614,7 @@ if ( ! class_exists( 'Kadence_Woomail_Preview' ) ) {
632
 
633
  // HTML Replace
634
  if ( $setting['live_method'] === 'replace' && ! empty( $setting[ 'selectors' ] ) ) {
635
- foreach ( $setting['selectors'] as $selector) {
636
  $original = ( ! empty( $setting['original'] ) ? json_encode( $setting['original'] ) : 'placeholder' );
637
  $scripts .= "wp.customize('$setting_key', function(value) {
638
  value.bind(function(newval) {
@@ -648,7 +630,7 @@ if ( ! class_exists( 'Kadence_Woomail_Preview' ) ) {
648
 
649
  // Close container and return
650
  echo $scripts . '});</script>';
651
- }
652
 
653
  }
654
 
1
  <?php
2
 
3
+ // Exit if accessed directly.
4
+ if ( ! defined( 'ABSPATH' ) ) {
5
+ exit;
6
  }
7
 
8
  /**
9
+ * Customizer Setup
10
+ * Heavily borrowed from rightpress Decorator
11
  */
12
  if ( ! class_exists( 'Kadence_Woomail_Preview' ) ) {
13
 
14
  class Kadence_Woomail_Preview {
15
  // WooCommerce email classes
16
+ public static $current_order = null;
17
+ public static $current_product_title = null;
18
+ public static $current_recipients = null;
19
+ public static $email_types_class_names = array(
20
+ 'new_order' => 'WC_Email_New_Order',
21
+ 'cancelled_order' => 'WC_Email_Cancelled_Order',
22
+ 'customer_processing_order' => 'WC_Email_Customer_Processing_Order',
23
  'customer_completed_order' => 'WC_Email_Customer_Completed_Order',
24
  'customer_refunded_order' => 'WC_Email_Customer_Refunded_Order',
25
  'customer_on_hold_order' => 'WC_Email_Customer_On_Hold_Order',
26
+ 'customer_invoice' => 'WC_Email_Customer_Invoice',
27
+ 'failed_order' => 'WC_Email_Failed_Order',
28
+ 'customer_new_account' => 'WC_Email_Customer_New_Account',
29
+ 'customer_note' => 'WC_Email_Customer_Note',
30
  'customer_reset_password' => 'WC_Email_Customer_Reset_Password',
31
  // WooCommerce Subscriptions Plugin
32
+ 'new_renewal_order' => 'WCS_Email_New_Renewal_Order',
33
+ 'customer_processing_renewal_order' => 'WCS_Email_Processing_Renewal_Order',
34
+ 'customer_completed_renewal_order' => 'WCS_Email_Completed_Renewal_Order',
35
+ 'customer_completed_switch_order' => 'WCS_Email_Completed_Switch_Order',
36
+ 'customer_renewal_invoice' => 'WCS_Email_Customer_Renewal_Invoice',
37
+ 'customer_payment_retry' => 'WCS_Email_Customer_Payment_Retry',
38
+ 'cancelled_subscription' => 'WCS_Email_Cancelled_Subscription',
39
  // Waitlist Plugin
40
+ 'woocommerce_waitlist_mailout' => 'Pie_WCWL_Waitlist_Mailout',
41
  );
42
  public static $email_types_order_status = array(
43
+ 'new_order' => 'processing',
44
+ 'cancelled_order' => 'cancelled',
45
+ 'customer_processing_order' => 'processing',
46
  'customer_completed_order' => 'completed',
47
  'customer_refunded_order' => 'refunded',
48
  'customer_on_hold_order' => 'on-hold',
49
+ 'customer_invoice' => 'processing',
50
+ 'failed_order' => 'failed',
51
+ 'customer_new_account' => null,
52
+ 'customer_note' => 'processing',
53
  'customer_reset_password' => null,
54
+ // WooCommerce Subscriptions Plugin.
55
+ 'new_renewal_order' => 'processing',
56
+ 'customer_processing_renewal_order' => 'processing',
57
+ 'customer_completed_renewal_order' => 'completed',
58
+ 'customer_completed_switch_order' => 'completed',
59
+ 'customer_renewal_invoice' => 'failed',
60
+ 'customer_payment_retry' => 'on-hold',
61
+ 'cancelled_subscription' => 'cancelled',
62
  // Waitlist Plugin
63
+ 'woocommerce_waitlist_mailout' => null,
64
  );
65
  /**
66
  * @var null
77
  return self::$instance;
78
  }
79
 
80
+ /**
81
+ * Class constructor
82
+ *
83
+ * @access public
84
+ * @return void
85
+ */
86
  public function __construct() {
87
+ // Set up preview.
88
  add_action( 'parse_request', array( $this, 'set_up_preview' ) );
89
  }
90
 
91
+ /**
92
+ * Set up preview
93
+ *
94
+ * @access public
95
+ * @return void
96
+ */
97
  public function set_up_preview() {
98
+ // Make sure this is own preview request.
99
  if ( ! Kadence_Woomail_Designer::is_own_preview_request() ) {
100
  return;
101
  }
102
+ // Load main view.
103
  include KT_WOOMAIL_PATH . 'preview.php';
104
 
105
+ // Do not load any further elements.
106
  exit;
107
  }
108
 
109
  /**
110
  * Get the email order status
111
+ *
112
  */
113
  public static function get_email_order_status( $email_template ) {
114
  $order_status = apply_filters( 'kadence_woomail_email_type_order_status_array', Kadence_Woomail_Preview::$email_types_order_status );
115
+ if ( isset( $order_status[ $email_template ] ) ) {
116
+ return $order_status[ $email_template ];
117
  } else {
118
  return false;
119
  }
124
  */
125
  public static function get_email_class_name( $email_template ) {
126
  $class_names = apply_filters( 'kadence_woomail_email_type_class_name_array', Kadence_Woomail_Preview::$email_types_class_names );
127
+ if ( isset( $class_names[ $email_template ] ) ) {
128
+ return $class_names[ $email_template ];
129
  } else {
130
  return 'processing';
131
  }
135
  *
136
  */
137
  public static function get_preview_email( $send_email = false, $email_addresses = null ) {
138
+ // Load WooCommerce emails.
139
+ $wc_emails = WC_Emails::instance();
140
+ $emails = $wc_emails->get_emails();
141
+ $email_template = Kadence_Woomail_Customizer::opt( 'email_type' );
142
+ $preview_id = Kadence_Woomail_Customizer::opt( 'preview_order_id' );
143
+ $email_type = Kadence_Woomail_Preview::get_email_class_name( $email_template );
144
  if ( false === $email_type ) {
145
  return false;
146
  }
147
  $order_status = Kadence_Woomail_Preview::get_email_order_status( $email_template );
148
 
 
149
  //$order_status = Kadence_Woomail_Preview::$email_types_order_status[$email_template];
150
 
151
+ if ( 'customer_invoice' == $email_template ) {
152
+ $invoice_paid = Kadence_Woomail_Customizer::opt( 'customer_invoice_switch' );
153
+ if ( ! $invoice_paid ) {
154
  $order_status = 'pending';
155
  }
156
  }
157
+ if ( 'customer_refunded_order' == $email_template ) {
158
+ $partial_preview = Kadence_Woomail_Customizer::opt( 'customer_refunded_order_switch' );
159
+ if ( ! $partial_preview ) {
160
  $partial_status = true;
161
  } else {
162
  $partial_status = false;
168
  };
169
 
170
  // Get an order
171
+ $order = Kadence_Woomail_Preview::get_wc_order_for_preview( $order_status, $preview_id );
172
  self::$current_order = $order;
173
+
174
  if ( is_object( $order ) ) {
175
  // Get user ID from order, if guest get current user ID.
176
+ if ( 0 === ( $user_id = (int) get_post_meta( $order->get_id(), '_customer_user', true ) ) ) {
177
  $user_id = get_current_user_id();
178
+ }
179
  } else {
180
  $user_id = get_current_user_id();
181
  }
185
  if ( 'woocommerce_waitlist_mailout' == $email_template ) {
186
 
187
  $product_id = -1;
 
188
  if ( is_object( $order ) ) {
189
  $items = $order->get_items();
190
  foreach ( $items as $item ) {
191
  $product_id = $item['product_id'];
192
+ if ( null !== get_post( $product_id ) ) {
193
  break;
194
  }
195
  }
196
  }
197
 
198
+ if ( null === get_post( $product_id ) ) {
199
 
200
+ $args = array(
201
+ 'posts_per_page' => 1,
202
+ 'orderby' => 'date',
203
+ 'post_type' => 'product',
204
+ 'post_status' => 'publish',
205
+ );
206
+ $products_array = get_posts( $args );
207
 
208
  if ( isset( $products_array[0]->ID ) ) {
209
  $product_id = $products_array[0]->ID;
218
  WC()->shipping();
219
 
220
  switch ( $email_template ) {
 
221
  /**
222
  * WooCommerce (default transactional mails).
223
  */
 
224
  case 'new_order':
225
  case 'cancelled_order':
226
  case 'customer_processing_order':
228
  case 'customer_on_hold_order':
229
  case 'customer_invoice':
230
  case 'failed_order':
231
+ $email->object = $order;
232
+ $email->find['order-date'] = '{order_date}';
233
+ $email->find['order-number'] = '{order_number}';
234
+ if ( is_object( $order ) ) {
235
+ $email->replace['order-date'] = wc_format_datetime( $email->object->get_date_created() );
236
+ $email->replace['order-number'] = $email->object->get_order_number();
237
+ // Other properties
238
+ $email->recipient = $email->object->get_billing_email();
239
+ }
240
  break;
 
241
  case 'customer_refunded_order':
242
+ $email->object = $order;
243
+ $email->partial_refund = $partial_status;
244
+ $email->find['order-date'] = '{order_date}';
245
+ $email->find['order-number'] = '{order_number}';
246
+ if ( is_object( $order ) ) {
247
+ $email->replace['order-date'] = wc_format_datetime( $email->object->get_date_created() );
248
+ $email->replace['order-number'] = $email->object->get_order_number();
249
+ // Other properties
250
+ $email->recipient = $email->object->get_billing_email();
251
+ }
252
  break;
 
253
  case 'customer_new_account':
 
254
  $email->object = $user;
255
  $email->user_pass = '{user_pass}';
256
  $email->user_login = stripslashes( $email->object->user_login );
257
  $email->user_email = stripslashes( $email->object->user_email );
258
  $email->recipient = $email->user_email;
259
+ $email->password_generated = true;
260
  break;
 
261
  case 'customer_note':
 
262
  $email->object = $order;
263
+ $email->customer_note = __( 'Hello! This is an example note', 'kadence-woocommerce-email-designer' );
264
  $email->find['order-date'] = '{order_date}';
265
  $email->find['order-number'] = '{order_number}';
266
  $email->replace['order-date'] = wc_format_datetime( $email->object->get_date_created() );
268
  // Other properties
269
  $email->recipient = $email->object->get_billing_email();
270
  break;
 
271
  case 'customer_reset_password':
272
+ $email->object = $user;
273
+ $email->user_id = $user_id;
274
+ $email->user_login = $user->user_login;
275
+ $email->user_email = stripslashes( $email->object->user_email );
276
+ $email->reset_key = '{{reset-key}}';
277
+ $email->recipient = stripslashes( $email->object->user_email );
 
278
  break;
 
 
279
  /**
280
  * WooCommerce Subscriptions Plugin (from WooCommerce).
281
  */
 
282
  case 'new_renewal_order':
283
  case 'new_switch_order':
284
  case 'customer_processing_renewal_order':
285
  case 'customer_completed_renewal_order':
286
  case 'customer_completed_switch_order':
287
  case 'customer_renewal_invoice':
288
+ $email->object = $order;
 
289
  $email->find['order-date'] = '{order_date}';
290
  $email->find['order-number'] = '{order_number}';
291
  $email->replace['order-date'] = wc_format_datetime( $email->object->get_date_created() );
292
  $email->replace['order-number'] = $email->object->get_order_number();
293
  // Other properties
294
  $email->recipient = $email->object->get_billing_email();
 
295
  break;
 
296
  case 'cancelled_subscription':
 
 
297
  $email->object = false;
298
  break;
 
299
  /**
300
  * WooCommerce Wait-list Plugin (from WooCommerce).
301
  */
 
302
  case 'woocommerce_waitlist_mailout':
303
+ $email->object = get_product( $product_id );
304
+ $email->find[] = '{product_title}';
305
+ $email->replace[] = $email->object->get_title();
 
306
  self::$current_product_title = $email->object->get_title();
307
  break;
 
308
  /**
309
  * Everything else.
310
  */
 
311
  default:
 
312
  $email->object = $order;
313
  // Allow unnamed emails preview to be filtered by plugin
314
+ $email = apply_filters( 'kadence_woomail_preview_email_object', $email );
315
  break;
316
  }
317
 
318
  if ( true === $send_email && ! empty( $email_addresses ) ) {
319
 
320
  self::$current_recipients = $email_addresses;
321
+
322
+ add_filter( 'woocommerce_email_recipient_' . $email->id, array( 'Kadence_Woomail_Preview', 'change_recipient' ), 99 );
323
+
324
  if ( $email->get_recipient() ) {
325
  $content = $email->send( $email->get_recipient(), $email->get_subject(), $email->get_content(), $email->get_headers(), $email->get_attachments() );
326
  }
327
 
328
+ remove_filter( 'woocommerce_email_recipient_' . $email->id, array( 'Kadence_Woomail_Preview', 'change_recipient' ), 99 );
329
 
330
  } else {
331
+ if ( false == $email->object ) {
332
+ $content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'This email type can not be previewed please try a differnet order or email type.', 'kadence-woocommerce-email-designer' ) . '</div>';
333
  } else {
 
334
  // Get email content and apply styles
335
  $content = $email->get_content();
336
  $content = $email->style_inline( $content );
341
  }
342
  }
343
  }
 
344
  } else {
345
  $content = false;
346
  }
356
  */
357
  public static function change_recipient( $recipient ) {
358
 
359
+ if ( ! empty( self::$current_recipients ) ) {
360
  $recipient = self::$current_recipients;
361
  } else {
362
  // Don't send if not set
373
  public static function print_preview_email() {
374
 
375
  $content = Kadence_Woomail_Preview::get_preview_email();
376
+ if ( false == $content ) {
377
+ echo __( 'An error occurred trying to load this email type. Make sure this email type is enabled or please try another type.', 'kadence-woocommerce-email-designer' );
378
+ } elseif ( ! empty( $content ) ) {
379
  // Print email content
380
  echo $content;
381
  // Print live preview scripts in footer
382
+ add_action( 'wp_footer', array( 'Kadence_Woomail_Preview', 'print_live_preview_scripts' ), 99 );
383
  }
384
  }
385
 
390
  * @return void
391
  */
392
  public static function send_preview_email() {
 
393
  $content = Kadence_Woomail_Preview::get_preview_email();
394
+ if ( ! empty( $content ) ) {
395
  // Print email content
396
  echo $content;
397
  }
405
  * @return object
406
  */
407
  public static function get_wc_order_for_preview( $order_status = null, $order_id = null ) {
408
+ if ( ! empty( $order_id ) && 'mockup' != $order_id ) {
409
  return wc_get_order( $order_id );
410
  } else {
411
  // Use mockup order (WC 2.7+)
414
  $order = new WC_Order();
415
 
416
  // Other order properties
417
+ $order->set_props( array(
418
+ 'id' => 1,
419
+ 'status' => ( null === $order_status ? 'processing' : $order_status ),
420
+ 'billing_first_name' => 'Sherlock',
421
+ 'billing_last_name' => 'Holmes',
422
+ 'billing_company' => 'Detectives Ltd.',
423
+ 'billing_address_1' => '221B Baker Street',
424
+ 'billing_city' => 'London',
425
+ 'billing_postcode' => 'NW1 6XE',
426
+ 'billing_country' => 'GB',
427
+ 'billing_email' => 'sherlock@holmes.co.uk',
428
+ 'billing_phone' => '02079304832',
429
+ 'date_created' => date( 'Y-m-d H:i:s' ),
430
+ 'total' => 24.90,
431
+ ) );
432
 
433
  // Item #1
434
  $order_item = new WC_Order_Item_Product();
435
+ $order_item->set_props( array(
436
+ 'name' => 'A Study in Scarlet',
437
+ 'subtotal' => '9.95',
438
+ 'sku' => 'kwd_ex_1',
439
+ ) );
440
+ $order->add_item( $order_item );
441
 
442
  // Item #2
443
  $order_item = new WC_Order_Item_Product();
444
+ $order_item->set_props( array(
445
+ 'name' => 'The Hound of the Baskervilles',
446
+ 'subtotal' => '14.95',
447
+ 'sku' => 'kwd_ex_2',
448
+ ) );
449
  $order->add_item( $order_item );
450
 
451
  // Return mockup order
468
  $scripts .= 'var font_family_mapping = ' . json_encode( Kadence_Woomail_Settings::$font_family_mapping ) . ';';
469
 
470
  // Get information from email to use in placeholders.
471
+ $scripts .= 'var pl_site_title = "' . get_bloginfo( 'name', 'display' ) . '";';
472
+ $scripts .= 'var pl_year = "' . date( 'Y' ) . '";';
473
+ if ( is_object( self::$current_order ) ) {
474
+ $scripts .= 'var pl_order_date = "' . wc_format_datetime( self::$current_order->get_date_created() ) . '";';
475
+ $scripts .= 'var pl_order_number = "' . self::$current_order->get_order_number() . '";';
476
+ $scripts .= 'var pl_customer_first_name = "' . self::$current_order->get_billing_first_name() . '";';
477
+ $scripts .= 'var pl_customer_last_name = "' . self::$current_order->get_billing_last_name() . '";';
478
+ $scripts .= 'var pl_customer_full_name = "' . self::$current_order->get_formatted_billing_full_name() . '";';
479
+ }
480
+ $scripts .= 'var pl_product_title = "' . self::$current_product_title . '";';
481
+ // Function to handle special cases.
482
  $scripts .= "function prepare(value, key, selector) {
483
  if (key === 'border_radius' && selector === '#template_header') {
484
  value = value.replace('!important', '').trim();
495
  value = '<p style=\"margin-top:0; margin-bottom:0;\"><img src=\"' + value + '\" style=\"border: none; display: inline; font-weight: bold; height: auto; line-height: 100%; outline: none; text-decoration: none; text-transform: capitalize;\" /></p>';
496
  } else if (value && value.includes('{site_title}') ) {
497
  value = value.replace('{site_title}', pl_site_title);
498
+ if (value && value.includes('{year}') ) {
499
+ value = value.replace('{year}', pl_year);
500
+ }
501
  } else if (value && value.includes('{order_date}') ) {
502
  value = value.replace('{order_date}', pl_order_date);
503
  } else if (value && value.includes('{order_number}') ) {
508
  value = value.replace('{customer_last_name}', pl_customer_last_name);
509
  } else if (value && value.includes('{customer_full_name}') ) {
510
  value = value.replace('{customer_full_name}', pl_customer_full_name);
511
+ } else if (value && value.includes('{product_title}') ) {
 
512
  value = value.replace('{product_title}', pl_product_title);
513
+ } else if (value && value.includes('{year}') ) {
514
+ value = value.replace('{year}', pl_year);
515
  }
516
  return value;
517
  }";
518
  // Get CSS suffixes
519
+ $scripts .= 'var suffixes = ' . json_encode( Kadence_Woomail_Customizer::get_css_suffix() ) . ';';
520
 
521
  // Go through kadence woomail settings
522
  foreach ( Kadence_Woomail_Settings::get_settings() as $setting_key => $setting ) {
523
 
524
  // No live method
525
+ if ( ! isset( $setting['live_method'] ) ) {
526
  continue;
527
  }
528
 
560
 
561
  // HTML Replace
562
  if ( $setting['live_method'] === 'replace' && ! empty( $setting[ 'selectors' ] ) ) {
563
+ foreach ( $setting['selectors'] as $selector ) {
564
  $original = json_encode( $setting['original'] );
565
  $scripts .= "wp.customize('kt_woomail[$setting_key]', function(value) {
566
  value.bind(function(newval) {
573
  }
574
  }
575
  // Go through woo settings
576
+ foreach ( Kadence_Woomail_Settings::get_woo_settings() as $setting_key => $setting ) {
577
 
578
  // No live method
579
+ if ( ! isset( $setting['live_method'] ) ) {
580
  continue;
581
  }
582
 
614
 
615
  // HTML Replace
616
  if ( $setting['live_method'] === 'replace' && ! empty( $setting[ 'selectors' ] ) ) {
617
+ foreach ( $setting['selectors'] as $selector ) {
618
  $original = ( ! empty( $setting['original'] ) ? json_encode( $setting['original'] ) : 'placeholder' );
619
  $scripts .= "wp.customize('$setting_key', function(value) {
620
  value.bind(function(newval) {
630
 
631
  // Close container and return
632
  echo $scripts . '});</script>';
633
+ }
634
 
635
  }
636
 
includes/class-kadence-woomail-settings.php CHANGED
@@ -1,8 +1,7 @@
1
  <?php
2
-
3
- // Exit if accessed directly
4
  if ( ! defined( 'ABSPATH' ) ) {
5
- exit;
6
  }
7
 
8
  /**
@@ -13,18 +12,18 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
13
 
14
  class Kadence_Woomail_Settings {
15
  /**
16
- * @var null
17
- */
18
- private static $panels = null;
19
- private static $sections = null;
20
- private static $settings = null;
21
- private static $woo_copy_settings = null;
22
- private static $woo_settings = null;
23
- private static $default_values = null;
24
- private static $order_ids = null;
25
- private static $email_types = null;
26
-
27
- // Font family
28
  public static $font_family_mapping = array(
29
  'helvetica' => '"Helvetica Neue", Helvetica, Roboto, Arial, sans-serif',
30
  'arial' => 'Arial, Helvetica, sans-serif',
@@ -220,10 +219,9 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
220
  ),
221
  );
222
  }
223
-
224
- // Return sections
225
- return self::$sections;
226
- }
227
 
228
  /**
229
  * Get woocommerce settings that the plugin will allow editing of
@@ -233,20 +231,20 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
233
  */
234
  public static function get_woo_settings() {
235
 
236
- if ( is_null( self::$woo_settings ) ) {
237
- $base_options = array();
238
 
239
- // Email header image
240
- $base_options[ 'woocommerce_email_header_image' ] = array(
241
  'title' => __('Header Image', 'kadence-woocommerce-email-designer'),
242
  'control_type' => 'image',
243
  'section' => 'header_image',
244
- 'default' => Kadence_Woomail_Settings::get_default_value( 'header_image' ),
245
  'original' => '',
246
  'priority' => 5,
247
- 'live_method' => 'replace',
248
  'selectors' => array(
249
- '#template_header_image'
250
  ),
251
  );
252
  // Email background color
@@ -255,7 +253,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
255
  'section' => 'container',
256
  'control_type' => 'color',
257
  'priority' => 5,
258
- 'default' => Kadence_Woomail_Settings::get_default_value('body_background_color'),
259
  'live_method' => 'css',
260
  'selectors' => array(
261
  'body' => array('background-color'),
@@ -267,7 +265,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
267
  'title' => __('Content Text color', 'kadence-woocommerce-email-designer'),
268
  'section' => 'text_style',
269
  'control_type' => 'color',
270
- 'default' => Kadence_Woomail_Settings::get_default_value('text_color'),
271
  'live_method' => 'css',
272
  'selectors' => array(
273
  '#body_content_inner' => array('color'),
@@ -282,7 +280,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
282
  'section' => 'content_container',
283
  'control_type' => 'color',
284
  'priority' => 5,
285
- 'default' => Kadence_Woomail_Settings::get_default_value('background_color'),
286
  'live_method' => 'css',
287
  'selectors' => array(
288
  '#body_content' => array('background-color'),
@@ -295,7 +293,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
295
  'title' => __('Footer text', 'kadence-woocommerce-email-designer'),
296
  'type' => 'textarea',
297
  'section' => 'footer_content',
298
- 'default' => Kadence_Woomail_Settings::get_default_value( 'footer_content_text' ),
299
  'original' => '',
300
  'live_method' => 'replace',
301
  'selectors' => array(
@@ -303,7 +301,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
303
  ),
304
  );
305
  $email_text = array();
306
- foreach ( Kadence_Woomail_Settings::get_email_types() as $key => $value ) {
307
  // Email recipients Text
308
  if ( 'cancelled_order' == $key || 'new_order' == $key || 'failed_order' == $key ) {
309
  $email_text['woocommerce_'.$key.'_settings[recipient]'] = array(
@@ -329,7 +327,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
329
  'priority' => 5,
330
  'default' => '',
331
  'input_attrs' => array(
332
- 'placeholder' => Kadence_Woomail_Settings::get_default_value( $key.'_subject_full' ),
333
  ),
334
  'active_callback' => array(
335
  'id' => 'email_type',
@@ -345,7 +343,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
345
  'priority' => 5,
346
  'default' => '',
347
  'input_attrs' => array(
348
- 'placeholder' => Kadence_Woomail_Settings::get_default_value( $key.'_subject_partial' ),
349
  ),
350
  'active_callback' => array(
351
  'id' => 'email_type',
@@ -361,7 +359,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
361
  'priority' => 5,
362
  'default' => '',
363
  'input_attrs' => array(
364
- 'placeholder' => Kadence_Woomail_Settings::get_default_value( $key.'_heading_full' ),
365
  ),
366
  'live_method' => 'replace',
367
  'selectors' => array(
@@ -381,7 +379,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
381
  'priority' => 5,
382
  'default' => '',
383
  'input_attrs' => array(
384
- 'placeholder' => Kadence_Woomail_Settings::get_default_value( $key.'_heading_partial' ),
385
  ),
386
  'active_callback' => array(
387
  'id' => 'email_type',
@@ -398,7 +396,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
398
  'priority' => 5,
399
  'default' => '',
400
  'input_attrs' => array(
401
- 'placeholder' => Kadence_Woomail_Settings::get_default_value( $key.'_subject' ),
402
  ),
403
  'active_callback' => array(
404
  'id' => 'email_type',
@@ -414,7 +412,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
414
  'priority' => 5,
415
  'default' => '',
416
  'input_attrs' => array(
417
- 'placeholder' => Kadence_Woomail_Settings::get_default_value( $key.'_subject_paid' ),
418
  ),
419
  'active_callback' => array(
420
  'id' => 'email_type',
@@ -431,7 +429,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
431
  'priority' => 5,
432
  'default' => '',
433
  'input_attrs' => array(
434
- 'placeholder' => Kadence_Woomail_Settings::get_default_value( $key.'_heading' ),
435
  ),
436
  'live_method' => 'replace',
437
  'selectors' => array(
@@ -451,7 +449,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
451
  'priority' => 5,
452
  'default' => '',
453
  'input_attrs' => array(
454
- 'placeholder' => Kadence_Woomail_Settings::get_default_value( $key.'_heading_paid' ),
455
  ),
456
  'active_callback' => array(
457
  'id' => 'email_type',
@@ -483,7 +481,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
483
  'title' => __('Template_load', 'kadence-woocommerce-email-designer'),
484
  'section' => 'template',
485
  'control_type' => 'kwdtemplateload',
486
- 'choices' => Kadence_Woomail_Settings::get_email_templates(),
487
  'default' => 'kt_full',
488
  'transport' => 'refresh',
489
  ),
@@ -493,8 +491,8 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
493
  'section' => 'mtype',
494
  'type' => 'select',
495
  'priority' => 1,
496
- 'choices' => Kadence_Woomail_Settings::get_order_ids(),
497
- 'default' => Kadence_Woomail_Settings::get_default_value('preview_order_id'),
498
  'transport' => 'refresh',
499
  ),
500
  //Email Type
@@ -503,8 +501,8 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
503
  'section' => 'mtype',
504
  'type' => 'select',
505
  'priority' => 2,
506
- 'choices' => Kadence_Woomail_Settings::get_email_types(),
507
- 'default' => Kadence_Woomail_Settings::get_default_value('email_type'),
508
  'transport' => 'refresh',
509
  ),
510
  //Placeholder Info
@@ -518,7 +516,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
518
  );
519
  $extra_email_text = array();
520
  // Get the Extra Text area settings.
521
- foreach (Kadence_Woomail_Settings::get_customized_email_types() as $key => $value) {
522
  // Email Subtitle Text
523
  $extra_email_text[$key.'_subtitle'] = array(
524
  'title' => __('Subtitle Text', 'kadence-woocommerce-email-designer'),
@@ -543,7 +541,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
543
  'control_type' => 'toggleswitch',
544
  'section' => 'mtype',
545
  'transport' => 'refresh',
546
- 'default' => Kadence_Woomail_Settings::get_default_value( $key.'_switch' ),
547
  'original' => '',
548
  'priority' => 3,
549
  'active_callback' => array(
@@ -557,7 +555,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
557
  'title' => __('Body Full Refund Text', 'kadence-woocommerce-email-designer'),
558
  'type' => 'textarea',
559
  'section' => 'mtype',
560
- 'default' => Kadence_Woomail_Settings::get_default_value( $key.'_body_full' ),
561
  'original' => '',
562
  'transport' => 'refresh',
563
  'active_callback' => array(
@@ -571,7 +569,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
571
  'title' => __('Body Partial Refund Text', 'kadence-woocommerce-email-designer'),
572
  'type' => 'textarea',
573
  'section' => 'mtype',
574
- 'default' => Kadence_Woomail_Settings::get_default_value( $key.'_body_partial' ),
575
  'original' => '',
576
  'transport' => 'refresh',
577
  'active_callback' => array(
@@ -587,7 +585,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
587
  'control_type' => 'toggleswitch',
588
  'section' => 'mtype',
589
  'transport' => 'refresh',
590
- 'default' => Kadence_Woomail_Settings::get_default_value( $key.'_switch' ),
591
  'original' => '',
592
  'priority' => 3,
593
  'active_callback' => array(
@@ -601,7 +599,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
601
  'title' => __('Body Invoice Paid Text', 'kadence-woocommerce-email-designer'),
602
  'type' => 'textarea',
603
  'section' => 'mtype',
604
- 'default' => Kadence_Woomail_Settings::get_default_value( $key.'_body_paid' ),
605
  'original' => '',
606
  'transport' => 'refresh',
607
  'active_callback' => array(
@@ -615,7 +613,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
615
  'title' => __('Body Invoice Pending Payment Text', 'kadence-woocommerce-email-designer'),
616
  'type' => 'textarea',
617
  'section' => 'mtype',
618
- 'default' => Kadence_Woomail_Settings::get_default_value( $key.'_body' ),
619
  'original' => '',
620
  'active_callback' => array(
621
  'id' => 'email_type',
@@ -629,7 +627,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
629
  'title' => __('Body Invoice Failed Text', 'kadence-woocommerce-email-designer'),
630
  'type' => 'textarea',
631
  'section' => 'mtype',
632
- 'default' => Kadence_Woomail_Settings::get_default_value( $key.'_body_failed' ),
633
  'original' => '',
634
  'transport' => 'refresh',
635
  'active_callback' => array(
@@ -643,7 +641,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
643
  'title' => __('Body Invoice Pending Payment Text', 'kadence-woocommerce-email-designer'),
644
  'type' => 'textarea',
645
  'section' => 'mtype',
646
- 'default' => Kadence_Woomail_Settings::get_default_value( $key.'_body' ),
647
  'original' => '',
648
  'active_callback' => array(
649
  'id' => 'email_type',
@@ -657,7 +655,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
657
  'title' => __('Body Text', 'kadence-woocommerce-email-designer'),
658
  'type' => 'textarea',
659
  'section' => 'mtype',
660
- 'default' => Kadence_Woomail_Settings::get_default_value( $key.'_body' ),
661
  'original' => '',
662
  'transport' => 'refresh',
663
  'active_callback' => array(
@@ -675,7 +673,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
675
  'title' => __('Content Width', 'kadence-woocommerce-email-designer'),
676
  'control_type' => 'rangevalue',
677
  'section' => 'container',
678
- 'default' => Kadence_Woomail_Settings::get_default_value('content_width'),
679
  'live_method' => 'css',
680
  'selectors' => array(
681
  '#template_container' => array('width'),
@@ -695,7 +693,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
695
  'title' => __('Border radius', 'kadence-woocommerce-email-designer'),
696
  'control_type' => 'rangevalue',
697
  'section' => 'container',
698
- 'default' => Kadence_Woomail_Settings::get_default_value('border_radius'),
699
  'live_method' => 'css',
700
  'selectors' => array(
701
  '#template_container' => array('border-radius'),
@@ -711,7 +709,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
711
  'title' => __('Border Width', 'kadence-woocommerce-email-designer'),
712
  'control_type' => 'rangevalue',
713
  'section' => 'container',
714
- 'default' => Kadence_Woomail_Settings::get_default_value('border_width'),
715
  'live_method' => 'css',
716
  'selectors' => array(
717
  'body #template_container' => array('border-width'),
@@ -727,7 +725,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
727
  'title' => __('Border color', 'kadence-woocommerce-email-designer'),
728
  'section' => 'container',
729
  'control_type' => 'color',
730
- 'default' => Kadence_Woomail_Settings::get_default_value('border_color'),
731
  'live_method' => 'css',
732
  'selectors' => array(
733
  'body #template_container' => array('border-color'),
@@ -739,7 +737,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
739
  'control_type' => 'rangevalue',
740
  'section' => 'container',
741
  'description' => __('Warning: most email clients do not yet support this', 'kadence-woocommerce-email-designer'),
742
- 'default' => Kadence_Woomail_Settings::get_default_value('shadow'),
743
  'live_method' => 'css',
744
  'selectors' => array(
745
  'body #template_container' => array('box-shadow'),
@@ -755,7 +753,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
755
  'title' => __('Container Top Padding', 'kadence-woocommerce-email-designer'),
756
  'control_type' => 'rangevalue',
757
  'section' => 'container',
758
- 'default' => Kadence_Woomail_Settings::get_default_value('email_padding'),
759
  'live_method' => 'css',
760
  'selectors' => array(
761
  '#wrapper' => array('padding-top'),
@@ -771,7 +769,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
771
  'title' => __('Container Botom Padding', 'kadence-woocommerce-email-designer'),
772
  'control_type' => 'rangevalue',
773
  'section' => 'container',
774
- 'default' => Kadence_Woomail_Settings::get_default_value('email_padding'),
775
  'live_method' => 'css',
776
  'selectors' => array(
777
  '#wrapper' => array('padding-bottom'),
@@ -787,10 +785,10 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
787
  'header_image_align' => array(
788
  'title' => __('Image Align', 'kadence-woocommerce-email-designer'),
789
  'section' => 'header_image',
790
- 'default' => Kadence_Woomail_Settings::get_default_value('header_image_align'),
791
  'live_method' => 'css',
792
  'type' => 'select',
793
- 'choices' => Kadence_Woomail_Settings::get_image_aligns(),
794
  'selectors' => array(
795
  '#template_header_image_table td' => array('text-align'),
796
  ),
@@ -799,7 +797,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
799
  'header_image_maxwidth' => array(
800
  'title' => __('Image Max Width', 'kadence-woocommerce-email-designer'),
801
  'section' => 'header_image',
802
- 'default' => Kadence_Woomail_Settings::get_default_value('header_image_maxwidth'),
803
  'live_method' => 'css',
804
  'control_type' => 'rangevalue',
805
  'selectors' => array(
@@ -815,7 +813,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
815
  'title' => __('Background color', 'kadence-woocommerce-email-designer'),
816
  'section' => 'header_image',
817
  'control_type' => 'color',
818
- 'default' => Kadence_Woomail_Settings::get_default_value('header_image_background_color'),
819
  'live_method' => 'css',
820
  'selectors' => array(
821
  '#template_header_image_container' => array('background-color'),
@@ -826,7 +824,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
826
  'title' => __('Padding top/bottom', 'kadence-woocommerce-email-designer'),
827
  'control_type' => 'rangevalue',
828
  'section' => 'header_image',
829
- 'default' => Kadence_Woomail_Settings::get_default_value('header_image_padding_top_bottom'),
830
  'live_method' => 'css',
831
  'selectors' => array(
832
  '#template_header_image_table td' => array('padding-top', 'padding-bottom'),
@@ -842,7 +840,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
842
  'title' => __('Background color', 'kadence-woocommerce-email-designer'),
843
  'section' => 'header_style',
844
  'control_type' => 'color',
845
- 'default' => Kadence_Woomail_Settings::get_default_value('header_background_color'),
846
  'live_method' => 'css',
847
  'selectors' => array(
848
  '#template_header' => array('background-color'),
@@ -852,10 +850,10 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
852
  'header_text_align' => array(
853
  'title' => __('Text align', 'kadence-woocommerce-email-designer'),
854
  'section' => 'header_style',
855
- 'default' => Kadence_Woomail_Settings::get_default_value('header_text_align'),
856
  'live_method' => 'css',
857
  'type' => 'select',
858
- 'choices' => Kadence_Woomail_Settings::get_text_aligns(),
859
  'selectors' => array(
860
  '#header_wrapper h1' => array('text-align'),
861
  '#header_wrapper' => array('text-align'),
@@ -867,7 +865,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
867
  'title' => __('Padding Top', 'kadence-woocommerce-email-designer'),
868
  'control_type' => 'rangevalue',
869
  'section' => 'header_style',
870
- 'default' => Kadence_Woomail_Settings::get_default_value('header_padding_top_bottom'),
871
  'live_method' => 'css',
872
  'selectors' => array(
873
  '#header_wrapper' => array('padding-top'),
@@ -883,7 +881,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
883
  'title' => __('Padding Bottom', 'kadence-woocommerce-email-designer'),
884
  'control_type' => 'rangevalue',
885
  'section' => 'header_style',
886
- 'default' => Kadence_Woomail_Settings::get_default_value('header_padding_top_bottom'),
887
  'live_method' => 'css',
888
  'selectors' => array(
889
  '#header_wrapper' => array('padding-bottom'),
@@ -900,7 +898,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
900
  'title' => __('Padding left/right', 'kadence-woocommerce-email-designer'),
901
  'control_type' => 'rangevalue',
902
  'section' => 'header_style',
903
- 'default' => Kadence_Woomail_Settings::get_default_value('header_padding_left_right'),
904
  'live_method' => 'css',
905
  'selectors' => array(
906
  '#header_wrapper' => array('padding-left', 'padding-right'),
@@ -916,7 +914,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
916
  'title' => __('Heading Font size', 'kadence-woocommerce-email-designer'),
917
  'control_type' => 'rangevalue',
918
  'section' => 'heading',
919
- 'default' => Kadence_Woomail_Settings::get_default_value('heading_font_size'),
920
  'live_method' => 'css',
921
  'selectors' => array(
922
  '#template_header h1' => array('font-size'),
@@ -932,7 +930,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
932
  'title' => __('Heading Line Height', 'kadence-woocommerce-email-designer'),
933
  'control_type' => 'rangevalue',
934
  'section' => 'heading',
935
- 'default' => Kadence_Woomail_Settings::get_default_value('heading_line_height'),
936
  'live_method' => 'css',
937
  'selectors' => array(
938
  '#template_header h1' => array('line-height'),
@@ -947,10 +945,10 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
947
  'heading_font_family' => array(
948
  'title' => __('Heading Font family', 'kadence-woocommerce-email-designer'),
949
  'section' => 'heading',
950
- 'default' => Kadence_Woomail_Settings::get_default_value('heading_font_family'),
951
  'live_method' => 'css',
952
  'type' => 'select',
953
- 'choices' => Kadence_Woomail_Settings::get_font_families(),
954
  'selectors' => array(
955
  '#template_header h1' => array('font-family'),
956
  ),
@@ -959,7 +957,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
959
  'heading_font_style' => array(
960
  'title' => __('Heading Font Style', 'kadence-woocommerce-email-designer'),
961
  'section' => 'heading',
962
- 'default' => Kadence_Woomail_Settings::get_default_value('heading_font_style'),
963
  'live_method' => 'css',
964
  'type' => 'select',
965
  'choices' => array(
@@ -975,7 +973,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
975
  'title' => __('Heading Font weight', 'kadence-woocommerce-email-designer'),
976
  'control_type' => 'rangevalue',
977
  'section' => 'heading',
978
- 'default' => Kadence_Woomail_Settings::get_default_value('heading_font_weight'),
979
  'live_method' => 'css',
980
  'selectors' => array(
981
  '#template_header h1' => array('font-weight'),
@@ -991,7 +989,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
991
  'title' => __('Heading Text color', 'kadence-woocommerce-email-designer'),
992
  'section' => 'heading',
993
  'control_type' => 'color',
994
- 'default' => Kadence_Woomail_Settings::get_default_value('heading_color'),
995
  'live_method' => 'css',
996
  'selectors' => array(
997
  '#template_header' => array('color'),
@@ -1009,7 +1007,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1009
  'subtitle_placement' => array(
1010
  'title' => __('Subtitle Placement', 'kadence-woocommerce-email-designer'),
1011
  'section' => 'heading',
1012
- 'default' => Kadence_Woomail_Settings::get_default_value('subtitle_placement'),
1013
  'transport' => 'refresh',
1014
  'type' => 'select',
1015
  'choices' => array(
@@ -1023,7 +1021,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1023
  'title' => __('Subtitle Font Size', 'kadence-woocommerce-email-designer'),
1024
  'control_type' => 'rangevalue',
1025
  'section' => 'heading',
1026
- 'default' => Kadence_Woomail_Settings::get_default_value('subtitle_font_size'),
1027
  'live_method' => 'css',
1028
  'selectors' => array(
1029
  '#template_header .subtitle' => array('font-size'),
@@ -1039,7 +1037,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1039
  'title' => __('Subtitle Line Height', 'kadence-woocommerce-email-designer'),
1040
  'control_type' => 'rangevalue',
1041
  'section' => 'heading',
1042
- 'default' => Kadence_Woomail_Settings::get_default_value('subtitle_line_height'),
1043
  'live_method' => 'css',
1044
  'selectors' => array(
1045
  '#template_header .subtitle' => array('line-height'),
@@ -1054,10 +1052,10 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1054
  'subtitle_font_family' => array(
1055
  'title' => __('Subtitle Font Family', 'kadence-woocommerce-email-designer'),
1056
  'section' => 'heading',
1057
- 'default' => Kadence_Woomail_Settings::get_default_value('subtitle_font_family'),
1058
  'live_method' => 'css',
1059
  'type' => 'select',
1060
- 'choices' => Kadence_Woomail_Settings::get_font_families(),
1061
  'selectors' => array(
1062
  '#template_header .subtitle' => array('font-family'),
1063
  ),
@@ -1066,7 +1064,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1066
  'subtitle_font_style' => array(
1067
  'title' => __('Subtitle Font Style', 'kadence-woocommerce-email-designer'),
1068
  'section' => 'heading',
1069
- 'default' => Kadence_Woomail_Settings::get_default_value('subtitle_font_style'),
1070
  'live_method' => 'css',
1071
  'type' => 'select',
1072
  'choices' => array(
@@ -1083,7 +1081,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1083
  'title' => __('Subtitle Font weight', 'kadence-woocommerce-email-designer'),
1084
  'control_type' => 'rangevalue',
1085
  'section' => 'heading',
1086
- 'default' => Kadence_Woomail_Settings::get_default_value('subtitle_font_weight'),
1087
  'live_method' => 'css',
1088
  'selectors' => array(
1089
  '#template_header .subtitle' => array('font-weight'),
@@ -1100,7 +1098,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1100
  'title' => __('Subtitle Text color', 'kadence-woocommerce-email-designer'),
1101
  'section' => 'heading',
1102
  'control_type' => 'color',
1103
- 'default' => Kadence_Woomail_Settings::get_default_value('subtitle_color'),
1104
  'live_method' => 'css',
1105
  'selectors' => array(
1106
  '#template_header .subtitle' => array('color'),
@@ -1112,7 +1110,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1112
  'title' => __('Padding Top', 'kadence-woocommerce-email-designer'),
1113
  'control_type' => 'rangevalue',
1114
  'section' => 'content_container',
1115
- 'default' => Kadence_Woomail_Settings::get_default_value('content_padding'),
1116
  'live_method' => 'css',
1117
  'selectors' => array(
1118
  '#body_content' => array('padding-top'),
@@ -1128,7 +1126,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1128
  'title' => __('Padding Bottom', 'kadence-woocommerce-email-designer'),
1129
  'control_type' => 'rangevalue',
1130
  'section' => 'content_container',
1131
- 'default' => Kadence_Woomail_Settings::get_default_value('content_padding_bottom'),
1132
  'live_method' => 'css',
1133
  'selectors' => array(
1134
  '#body_content' => array('padding-bottom'),
@@ -1144,7 +1142,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1144
  'title' => __('Padding Left/Right', 'kadence-woocommerce-email-designer'),
1145
  'control_type' => 'rangevalue',
1146
  'section' => 'content_container',
1147
- 'default' => Kadence_Woomail_Settings::get_default_value('content_padding'),
1148
  'live_method' => 'css',
1149
  'selectors' => array(
1150
  '#body_content > table > tbody > tr > td' => array('padding-left', 'padding-right'),
@@ -1162,7 +1160,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1162
  'title' => __('Font Size', 'kadence-woocommerce-email-designer'),
1163
  'control_type' => 'rangevalue',
1164
  'section' => 'text_style',
1165
- 'default' => Kadence_Woomail_Settings::get_default_value('font_size'),
1166
  'live_method' => 'css',
1167
  'selectors' => array(
1168
  '#body_content_inner' => array('font-size'),
@@ -1179,7 +1177,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1179
  'title' => __('Line Height', 'kadence-woocommerce-email-designer'),
1180
  'control_type' => 'rangevalue',
1181
  'section' => 'text_style',
1182
- 'default' => Kadence_Woomail_Settings::get_default_value('line_height'),
1183
  'live_method' => 'css',
1184
  'selectors' => array(
1185
  '#body_content_inner' => array('line-height'),
@@ -1195,10 +1193,10 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1195
  'font_family' => array(
1196
  'title' => __('Font Family', 'kadence-woocommerce-email-designer'),
1197
  'section' => 'text_style',
1198
- 'default' => Kadence_Woomail_Settings::get_default_value('font_family'),
1199
  'live_method' => 'css',
1200
  'type' => 'select',
1201
- 'choices' => Kadence_Woomail_Settings::get_font_families(),
1202
  'selectors' => array(
1203
  '#body_content_inner' => array('font-family'),
1204
  '.td' => array('font-family'),
@@ -1210,7 +1208,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1210
  'title' => __('Font weight', 'kadence-woocommerce-email-designer'),
1211
  'control_type' => 'rangevalue',
1212
  'section' => 'text_style',
1213
- 'default' => Kadence_Woomail_Settings::get_default_value('font_weight'),
1214
  'live_method' => 'css',
1215
  'selectors' => array(
1216
  '#body_content_inner' => array('font-weight'),
@@ -1226,7 +1224,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1226
  'title' => __('Link Color', 'kadence-woocommerce-email-designer'),
1227
  'section' => 'text_style',
1228
  'control_type' => 'color',
1229
- 'default' => Kadence_Woomail_Settings::get_default_value('link_color'),
1230
  'live_method' => 'css',
1231
  'selectors' => array(
1232
  'a' => array('color'),
@@ -1240,7 +1238,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1240
  'title' => __('H2 Font Size', 'kadence-woocommerce-email-designer'),
1241
  'control_type' => 'rangevalue',
1242
  'section' => 'headings_style',
1243
- 'default' => Kadence_Woomail_Settings::get_default_value('h2_font_size'),
1244
  'live_method' => 'css',
1245
  'selectors' => array(
1246
  '#template_body h2' => array('font-size'),
@@ -1256,7 +1254,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1256
  'title' => __('H2 Line Height', 'kadence-woocommerce-email-designer'),
1257
  'control_type' => 'rangevalue',
1258
  'section' => 'headings_style',
1259
- 'default' => Kadence_Woomail_Settings::get_default_value('h2_line_height'),
1260
  'live_method' => 'css',
1261
  'selectors' => array(
1262
  '#template_body h2' => array('line-height'),
@@ -1272,7 +1270,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1272
  'title' => __('H2 Padding Top', 'kadence-woocommerce-email-designer'),
1273
  'control_type' => 'rangevalue',
1274
  'section' => 'headings_style',
1275
- 'default' => Kadence_Woomail_Settings::get_default_value('h2_padding_top'),
1276
  'live_method' => 'css',
1277
  'selectors' => array(
1278
  '#template_body h2' => array('padding-top'),
@@ -1288,7 +1286,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1288
  'title' => __('H2 Padding Bottom', 'kadence-woocommerce-email-designer'),
1289
  'control_type' => 'rangevalue',
1290
  'section' => 'headings_style',
1291
- 'default' => Kadence_Woomail_Settings::get_default_value('h2_padding_bottom'),
1292
  'live_method' => 'css',
1293
  'selectors' => array(
1294
  '#template_body h2' => array('padding-bottom'),
@@ -1304,7 +1302,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1304
  'title' => __('H2 Margin Top', 'kadence-woocommerce-email-designer'),
1305
  'control_type' => 'rangevalue',
1306
  'section' => 'headings_style',
1307
- 'default' => Kadence_Woomail_Settings::get_default_value('h2_margin_top'),
1308
  'live_method' => 'css',
1309
  'selectors' => array(
1310
  '#template_body h2' => array('margin-top'),
@@ -1320,7 +1318,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1320
  'title' => __('H2 Margin Bottom', 'kadence-woocommerce-email-designer'),
1321
  'control_type' => 'rangevalue',
1322
  'section' => 'headings_style',
1323
- 'default' => Kadence_Woomail_Settings::get_default_value('h2_margin_bottom'),
1324
  'live_method' => 'css',
1325
  'selectors' => array(
1326
  '#template_body h2' => array('margin-bottom'),
@@ -1335,10 +1333,10 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1335
  'h2_font_family' => array(
1336
  'title' => __('H2 Font Family', 'kadence-woocommerce-email-designer'),
1337
  'section' => 'headings_style',
1338
- 'default' => Kadence_Woomail_Settings::get_default_value('h2_font_family'),
1339
  'live_method' => 'css',
1340
  'type' => 'select',
1341
- 'choices' => Kadence_Woomail_Settings::get_font_families(),
1342
  'selectors' => array(
1343
  '#template_body h2' => array('font-family'),
1344
  '#template_body h2 a' => array('font-family'),
@@ -1348,7 +1346,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1348
  'h2_font_style' => array(
1349
  'title' => __('H2 Font Style', 'kadence-woocommerce-email-designer'),
1350
  'section' => 'headings_style',
1351
- 'default' => Kadence_Woomail_Settings::get_default_value('h2_font_style'),
1352
  'live_method' => 'css',
1353
  'type' => 'select',
1354
  'choices' => array(
@@ -1365,7 +1363,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1365
  'title' => __('H2 Font weight', 'kadence-woocommerce-email-designer'),
1366
  'control_type' => 'rangevalue',
1367
  'section' => 'headings_style',
1368
- 'default' => Kadence_Woomail_Settings::get_default_value('h2_font_weight'),
1369
  'live_method' => 'css',
1370
  'selectors' => array(
1371
  '#template_body h2' => array('font-weight'),
@@ -1381,7 +1379,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1381
  'h2_text_transform' => array(
1382
  'title' => __('H2 Text Transform', 'kadence-woocommerce-email-designer'),
1383
  'section' => 'headings_style',
1384
- 'default' => Kadence_Woomail_Settings::get_default_value('h2_text_transform'),
1385
  'live_method' => 'css',
1386
  'type' => 'select',
1387
  'choices' => array(
@@ -1399,7 +1397,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1399
  'title' => __('H2 Color', 'kadence-woocommerce-email-designer'),
1400
  'section' => 'headings_style',
1401
  'control_type' => 'color',
1402
- 'default' => Kadence_Woomail_Settings::get_default_value('h2_color'),
1403
  'live_method' => 'css',
1404
  'selectors' => array(
1405
  '#template_body h2' => array('color'),
@@ -1410,10 +1408,10 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1410
  'h2_text_align' => array(
1411
  'title' => __('H2 Text Align', 'kadence-woocommerce-email-designer'),
1412
  'section' => 'headings_style',
1413
- 'default' => Kadence_Woomail_Settings::get_default_value('h2_text_align'),
1414
  'live_method' => 'css',
1415
  'type' => 'select',
1416
- 'choices' => Kadence_Woomail_Settings::get_text_aligns(),
1417
  'selectors' => array(
1418
  '#template_body h2' => array('text-align'),
1419
  ),
@@ -1422,7 +1420,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1422
  'h2_style' => array(
1423
  'title' => __('H2 Separator', 'kadence-woocommerce-email-designer'),
1424
  'section' => 'headings_style',
1425
- 'default' => Kadence_Woomail_Settings::get_default_value('h2_style'),
1426
  'transport' => 'refresh',
1427
  'type' => 'select',
1428
  'choices' => array(
@@ -1436,7 +1434,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1436
  'title' => __('H2 Separator height', 'kadence-woocommerce-email-designer'),
1437
  'section' => 'headings_style',
1438
  'control_type' => 'rangevalue',
1439
- 'default' => Kadence_Woomail_Settings::get_default_value('h2_style'),
1440
  'live_method' => 'css',
1441
  'type' => 'select',
1442
  'input_attrs' => array(
@@ -1453,7 +1451,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1453
  'h2_separator_style' => array(
1454
  'title' => __('H2 Separator Style', 'kadence-woocommerce-email-designer'),
1455
  'section' => 'headings_style',
1456
- 'default' => Kadence_Woomail_Settings::get_default_value('h2_style'),
1457
  'live_method' => 'css',
1458
  'type' => 'select',
1459
  'choices' => array(
@@ -1474,7 +1472,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1474
  'title' => __('H2 Separator Color', 'kadence-woocommerce-email-designer'),
1475
  'section' => 'headings_style',
1476
  'control_type' => 'color',
1477
- 'default' => Kadence_Woomail_Settings::get_default_value('h2_separator_color'),
1478
  'live_method' => 'css',
1479
  'selectors' => array(
1480
  '.title-style-below #template_body h2' => array('border-bottom-color'),
@@ -1494,7 +1492,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1494
  'title' => __('H3 Font Size', 'kadence-woocommerce-email-designer'),
1495
  'control_type' => 'rangevalue',
1496
  'section' => 'headings_style',
1497
- 'default' => Kadence_Woomail_Settings::get_default_value('h3_font_size'),
1498
  'live_method' => 'css',
1499
  'selectors' => array(
1500
  '#template_body h3' => array('font-size'),
@@ -1510,7 +1508,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1510
  'title' => __('H3 Line Height', 'kadence-woocommerce-email-designer'),
1511
  'control_type' => 'rangevalue',
1512
  'section' => 'headings_style',
1513
- 'default' => Kadence_Woomail_Settings::get_default_value('h2_line_height'),
1514
  'live_method' => 'css',
1515
  'selectors' => array(
1516
  '#template_body h3' => array('line-height'),
@@ -1525,10 +1523,10 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1525
  'h3_font_family' => array(
1526
  'title' => __('H3 Font Family', 'kadence-woocommerce-email-designer'),
1527
  'section' => 'headings_style',
1528
- 'default' => Kadence_Woomail_Settings::get_default_value('h2_font_family'),
1529
  'live_method' => 'css',
1530
  'type' => 'select',
1531
- 'choices' => Kadence_Woomail_Settings::get_font_families(),
1532
  'selectors' => array(
1533
  '#template_body h3' => array('font-family'),
1534
  ),
@@ -1537,7 +1535,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1537
  'h3_font_style' => array(
1538
  'title' => __('H3 Font Style', 'kadence-woocommerce-email-designer'),
1539
  'section' => 'headings_style',
1540
- 'default' => Kadence_Woomail_Settings::get_default_value('h3_font_style'),
1541
  'live_method' => 'css',
1542
  'type' => 'select',
1543
  'choices' => array(
@@ -1553,7 +1551,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1553
  'title' => __('H3 Font weight', 'kadence-woocommerce-email-designer'),
1554
  'control_type' => 'rangevalue',
1555
  'section' => 'headings_style',
1556
- 'default' => Kadence_Woomail_Settings::get_default_value('h3_font_weight'),
1557
  'live_method' => 'css',
1558
  'selectors' => array(
1559
  '#template_body h3' => array('font-weight'),
@@ -1569,7 +1567,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1569
  'title' => __('H3 Color', 'kadence-woocommerce-email-designer'),
1570
  'section' => 'headings_style',
1571
  'control_type' => 'color',
1572
- 'default' => Kadence_Woomail_Settings::get_default_value('h3_color'),
1573
  'live_method' => 'css',
1574
  'selectors' => array(
1575
  '#template_body h3' => array('color'),
@@ -1579,7 +1577,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1579
  'order_items_style' => array(
1580
  'title' => __('Order Table Style', 'kadence-woocommerce-email-designer'),
1581
  'section' => 'items_table',
1582
- 'default' => Kadence_Woomail_Settings::get_default_value('order_items_style'),
1583
  'transport' => 'refresh',
1584
  'type' => 'select',
1585
  'choices' => array(
@@ -1591,7 +1589,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1591
  'order_items_image' => array(
1592
  'title' => __('Product Image Option', 'kadence-woocommerce-email-designer'),
1593
  'section' => 'items_table',
1594
- 'default' => Kadence_Woomail_Settings::get_default_value( 'order_items_image' ),
1595
  'transport' => 'refresh',
1596
  'type' => 'select',
1597
  'choices' => array(
@@ -1604,7 +1602,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1604
  'title' => __('Order Table Background color', 'kadence-woocommerce-email-designer'),
1605
  'section' => 'items_table',
1606
  'control_type' => 'color',
1607
- 'default' => Kadence_Woomail_Settings::get_default_value('items_table_background_color'),
1608
  'live_method' => 'css',
1609
  'selectors' => array(
1610
  '#body_content_inner table.td' => array('background-color'),
@@ -1616,7 +1614,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1616
  'title' => __('Padding', 'kadence-woocommerce-email-designer'),
1617
  'control_type' => 'rangevalue',
1618
  'section' => 'items_table',
1619
- 'default' => Kadence_Woomail_Settings::get_default_value('items_table_padding'),
1620
  'live_method' => 'css',
1621
  'selectors' => array(
1622
  '.order-items-normal #body_content_inner table.td th' => array('padding'),
@@ -1636,7 +1634,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1636
  'title' => __('Border Width', 'kadence-woocommerce-email-designer'),
1637
  'control_type' => 'rangevalue',
1638
  'section' => 'items_table',
1639
- 'default' => Kadence_Woomail_Settings::get_default_value('items_table_border_width'),
1640
  'live_method' => 'css',
1641
  'selectors' => array(
1642
  '.order-items-normal #body_content_inner .td' => array('border-width'),
@@ -1655,7 +1653,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1655
  'title' => __('Border Color', 'kadence-woocommerce-email-designer'),
1656
  'section' => 'items_table',
1657
  'control_type' => 'color',
1658
- 'default' => Kadence_Woomail_Settings::get_default_value('items_table_border_color'),
1659
  'live_method' => 'css',
1660
  'selectors' => array(
1661
  '#body_content_inner .td' => array('border-color'),
@@ -1665,7 +1663,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1665
  'items_table_border_style' => array(
1666
  'title' => __('Border Style', 'kadence-woocommerce-email-designer'),
1667
  'section' => 'items_table',
1668
- 'default' => Kadence_Woomail_Settings::get_default_value('items_table_border_style'),
1669
  'live_method' => 'css',
1670
  'type' => 'select',
1671
  'choices' => array(
@@ -1686,7 +1684,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1686
  'order_heading_style' => array(
1687
  'title' => __('Order Table Heading Style', 'kadence-woocommerce-email-designer'),
1688
  'section' => 'items_table',
1689
- 'default' => Kadence_Woomail_Settings::get_default_value('order_heading_style'),
1690
  'transport' => 'refresh',
1691
  'type' => 'select',
1692
  'choices' => array(
@@ -1699,7 +1697,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1699
  'title' => __('Address Box Background color', 'kadence-woocommerce-email-designer'),
1700
  'section' => 'addresses',
1701
  'control_type' => 'color',
1702
- 'default' => Kadence_Woomail_Settings::get_default_value('addresses_background_color'),
1703
  'live_method' => 'css',
1704
  'selectors' => array(
1705
  '#body_content_inner address' => array('background-color'),
@@ -1710,7 +1708,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1710
  'title' => __('Address Box Border Width', 'kadence-woocommerce-email-designer'),
1711
  'control_type' => 'rangevalue',
1712
  'section' => 'addresses',
1713
- 'default' => Kadence_Woomail_Settings::get_default_value('addresses_border_width'),
1714
  'live_method' => 'css',
1715
  'selectors' => array(
1716
  '#body_content_inner address' => array('border-width'),
@@ -1726,7 +1724,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1726
  'title' => __('Address Box Border Color', 'kadence-woocommerce-email-designer'),
1727
  'section' => 'addresses',
1728
  'control_type' => 'color',
1729
- 'default' => Kadence_Woomail_Settings::get_default_value('addresses_border_color'),
1730
  'live_method' => 'css',
1731
  'selectors' => array(
1732
  '#body_content_inner address' => array('border-color'),
@@ -1736,7 +1734,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1736
  'addresses_border_style' => array(
1737
  'title' => __('Address Box Border Style', 'kadence-woocommerce-email-designer'),
1738
  'section' => 'addresses',
1739
- 'default' => Kadence_Woomail_Settings::get_default_value('addresses_border_style'),
1740
  'live_method' => 'css',
1741
  'type' => 'select',
1742
  'choices' => array(
@@ -1756,7 +1754,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1756
  'title' => __('Address Box Text Color', 'kadence-woocommerce-email-designer'),
1757
  'section' => 'addresses',
1758
  'control_type' => 'color',
1759
- 'default' => Kadence_Woomail_Settings::get_default_value('addresses_text_color'),
1760
  'live_method' => 'css',
1761
  'selectors' => array(
1762
  '#body_content_inner address' => array('color'),
@@ -1766,10 +1764,10 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1766
  'addresses_text_align' => array(
1767
  'title' => __('Address Box Text Align', 'kadence-woocommerce-email-designer'),
1768
  'section' => 'addresses',
1769
- 'default' => Kadence_Woomail_Settings::get_default_value('addresses_text_align'),
1770
  'live_method' => 'css',
1771
  'type' => 'select',
1772
- 'choices' => Kadence_Woomail_Settings::get_text_aligns(),
1773
  'selectors' => array(
1774
  '#body_content_inner address' => array('text-align'),
1775
  ),
@@ -1778,7 +1776,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1778
  'footer_background_placement' => array(
1779
  'title' => __('Footer Background Placement', 'kadence-woocommerce-email-designer'),
1780
  'section' => 'footer_style',
1781
- 'default' => Kadence_Woomail_Settings::get_default_value('footer_background_placement'),
1782
  'transport' => 'refresh',
1783
  'type' => 'select',
1784
  'choices' => array(
@@ -1791,7 +1789,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1791
  'title' => __('Footer Background Color', 'kadence-woocommerce-email-designer'),
1792
  'section' => 'footer_style',
1793
  'control_type' => 'color',
1794
- 'default' => Kadence_Woomail_Settings::get_default_value('footer_background_color'),
1795
  'live_method' => 'css',
1796
  'selectors' => array(
1797
  '#template_footer_container' => array('background-color'),
@@ -1802,7 +1800,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1802
  'title' => __('Top Padding', 'kadence-woocommerce-email-designer'),
1803
  'control_type' => 'rangevalue',
1804
  'section' => 'footer_style',
1805
- 'default' => Kadence_Woomail_Settings::get_default_value('footer_top_padding'),
1806
  'live_method' => 'css',
1807
  'selectors' => array(
1808
  '#template_footer #template_footer_inside' => array('padding-top'),
@@ -1818,7 +1816,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1818
  'title' => __('Bottom Padding', 'kadence-woocommerce-email-designer'),
1819
  'control_type' => 'rangevalue',
1820
  'section' => 'footer_style',
1821
- 'default' => Kadence_Woomail_Settings::get_default_value('footer_bottom_padding'),
1822
  'live_method' => 'css',
1823
  'selectors' => array(
1824
  '#template_footer #template_footer_inside' => array('padding-bottom'),
@@ -1834,7 +1832,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1834
  'title' => __('Left/Right Padding', 'kadence-woocommerce-email-designer'),
1835
  'control_type' => 'rangevalue',
1836
  'section' => 'footer_style',
1837
- 'default' => Kadence_Woomail_Settings::get_default_value('footer_left_right_padding'),
1838
  'live_method' => 'css',
1839
  'selectors' => array(
1840
  '#template_footer #template_footer_inside' => array('padding-left', 'padding-right'),
@@ -1851,7 +1849,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1851
  'control_type' => 'repeater',
1852
  'transport' => 'refresh',
1853
  'section' => 'footer_social',
1854
- 'default' => Kadence_Woomail_Settings::get_default_value( 'social_options' ),
1855
  'customizer_repeater_image_control' => true,
1856
  'customizer_repeater_icon_control' => true,
1857
  'customizer_repeater_icon_color' => true,
@@ -1863,7 +1861,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1863
  'footer_social_title_color' => array(
1864
  'title' => __('Footer Social Title Color', 'kadence-woocommerce-email-designer'),
1865
  'section' => 'footer_social',
1866
- 'default' => Kadence_Woomail_Settings::get_default_value('footer_social_title_color'),
1867
  'live_method' => 'css',
1868
  'selectors' => array(
1869
  '#template_footer a.ft-social-link' => array('color'),
@@ -1875,7 +1873,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1875
  'title' => __('Footer Social Title Font Size', 'kadence-woocommerce-email-designer'),
1876
  'control_type' => 'rangevalue',
1877
  'section' => 'footer_social',
1878
- 'default' => Kadence_Woomail_Settings::get_default_value('footer_social_title_font_size'),
1879
  'live_method' => 'css',
1880
  'selectors' => array(
1881
  '#template_footer .ft-social-title' => array('font-size'),
@@ -1890,10 +1888,10 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1890
  'footer_social_title_font_family' => array(
1891
  'title' => __('Footer Social Title Font Family', 'kadence-woocommerce-email-designer'),
1892
  'section' => 'footer_social',
1893
- 'default' => Kadence_Woomail_Settings::get_default_value('footer_social_title_font_family'),
1894
  'live_method' => 'css',
1895
  'type' => 'select',
1896
- 'choices' => Kadence_Woomail_Settings::get_font_families(),
1897
  'selectors' => array(
1898
  '#template_footer a.ft-social-link' => array('font-family'),
1899
  ),
@@ -1903,7 +1901,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1903
  'title' => __('Footer Social Title Font Weight', 'kadence-woocommerce-email-designer'),
1904
  'control_type' => 'rangevalue',
1905
  'section' => 'footer_social',
1906
- 'default' => Kadence_Woomail_Settings::get_default_value('footer_social_title_font_weight'),
1907
  'live_method' => 'css',
1908
  'selectors' => array(
1909
  '#template_footer .ft-social-title' => array('font-weight'),
@@ -1919,7 +1917,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1919
  'title' => __('Top Padding', 'kadence-woocommerce-email-designer'),
1920
  'control_type' => 'rangevalue',
1921
  'section' => 'footer_social',
1922
- 'default' => Kadence_Woomail_Settings::get_default_value('footer_social_top_padding'),
1923
  'live_method' => 'css',
1924
  'selectors' => array(
1925
  '#template_footer #footersocial td' => array('padding-top'),
@@ -1935,7 +1933,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1935
  'title' => __('Bottom Padding', 'kadence-woocommerce-email-designer'),
1936
  'control_type' => 'rangevalue',
1937
  'section' => 'footer_social',
1938
- 'default' => Kadence_Woomail_Settings::get_default_value('footer_social_bottom_padding'),
1939
  'live_method' => 'css',
1940
  'selectors' => array(
1941
  '#template_footer #footersocial td' => array('padding-bottom'),
@@ -1951,7 +1949,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1951
  'title' => __('Footer Social Bottom Border Width', 'kadence-woocommerce-email-designer'),
1952
  'control_type' => 'rangevalue',
1953
  'section' => 'footer_social',
1954
- 'default' => Kadence_Woomail_Settings::get_default_value('footer_social_border_width'),
1955
  'live_method' => 'css',
1956
  'selectors' => array(
1957
  '#footersocial' => array('border-bottom-width'),
@@ -1967,7 +1965,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1967
  'title' => __('Footer Social Bottom Border Color', 'kadence-woocommerce-email-designer'),
1968
  'section' => 'footer_social',
1969
  'control_type' => 'color',
1970
- 'default' => Kadence_Woomail_Settings::get_default_value('footer_social_border_color'),
1971
  'live_method' => 'css',
1972
  'selectors' => array(
1973
  '#footersocial' => array('border-bottom-color'),
@@ -1977,7 +1975,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1977
  'footer_social_border_style' => array(
1978
  'title' => __('Footer Social Bottom Border Style', 'kadence-woocommerce-email-designer'),
1979
  'section' => 'footer_social',
1980
- 'default' => Kadence_Woomail_Settings::get_default_value('footer_social_border_style'),
1981
  'live_method' => 'css',
1982
  'type' => 'select',
1983
  'choices' => array(
@@ -1996,10 +1994,10 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
1996
  'footer_text_align' => array(
1997
  'title' => __('Text Align', 'kadence-woocommerce-email-designer'),
1998
  'section' => 'footer_content',
1999
- 'default' => Kadence_Woomail_Settings::get_default_value('footer_text_align'),
2000
  'live_method' => 'css',
2001
  'type' => 'select',
2002
- 'choices' => Kadence_Woomail_Settings::get_text_aligns(),
2003
  'selectors' => array(
2004
  '#template_footer #credit' => array('text-align'),
2005
  ),
@@ -2010,7 +2008,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
2010
  'title' => __('Font Size', 'kadence-woocommerce-email-designer'),
2011
  'control_type' => 'rangevalue',
2012
  'section' => 'footer_content',
2013
- 'default' => Kadence_Woomail_Settings::get_default_value('footer_font_size'),
2014
  'live_method' => 'css',
2015
  'selectors' => array(
2016
  '#template_footer #credit' => array('font-size'),
@@ -2025,10 +2023,10 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
2025
  'footer_font_family' => array(
2026
  'title' => __('Font Family', 'kadence-woocommerce-email-designer'),
2027
  'section' => 'footer_content',
2028
- 'default' => Kadence_Woomail_Settings::get_default_value('footer_font_family'),
2029
  'live_method' => 'css',
2030
  'type' => 'select',
2031
- 'choices' => Kadence_Woomail_Settings::get_font_families(),
2032
  'selectors' => array(
2033
  '#template_footer #credit' => array('font-family'),
2034
  ),
@@ -2039,7 +2037,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
2039
  'title' => __('Font weight', 'kadence-woocommerce-email-designer'),
2040
  'control_type' => 'rangevalue',
2041
  'section' => 'footer_content',
2042
- 'default' => Kadence_Woomail_Settings::get_default_value('footer_font_weight'),
2043
  'live_method' => 'css',
2044
  'selectors' => array(
2045
  '#template_footer #credit' => array('font-weight'),
@@ -2056,7 +2054,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
2056
  'title' => __('Text Color', 'kadence-woocommerce-email-designer'),
2057
  'section' => 'footer_content',
2058
  'control_type' => 'color',
2059
- 'default' => Kadence_Woomail_Settings::get_default_value('footer_color'),
2060
  'live_method' => 'css',
2061
  'selectors' => array(
2062
  '#template_footer #credit' => array('color'),
@@ -2067,7 +2065,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
2067
  'title' => __('Top Padding', 'kadence-woocommerce-email-designer'),
2068
  'control_type' => 'rangevalue',
2069
  'section' => 'footer_content',
2070
- 'default' => Kadence_Woomail_Settings::get_default_value('footer_credit_top_padding'),
2071
  'live_method' => 'css',
2072
  'selectors' => array(
2073
  '#template_footer #credit' => array('padding-top'),
@@ -2083,7 +2081,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
2083
  'title' => __('Bottom Padding', 'kadence-woocommerce-email-designer'),
2084
  'control_type' => 'rangevalue',
2085
  'section' => 'footer_content',
2086
- 'default' => Kadence_Woomail_Settings::get_default_value('footer_credit_bottom_padding'),
2087
  'live_method' => 'css',
2088
  'selectors' => array(
2089
  '#template_footer #credit' => array('padding-bottom'),
@@ -2115,7 +2113,7 @@ if ( ! class_exists( 'Kadence_Woomail_Settings' ) ) {
2115
  'title' => __('Preview Email Recipient', 'kadence-woocommerce-email-designer'),
2116
  'description' => __( 'Enter recipients (comma separated) for preview emails', 'kadence-woocommerce-email-designer' ),
2117
  'section' => 'send_email',
2118
- 'default' => Kadence_Woomail_Settings::get_default_value('email_recipient'),
2119
  'control_type' => 'kwdsendemail',
2120
  ),
2121
  );
@@ -2357,7 +2355,7 @@ To reset your password, visit the following address:', 'kadence-woocommerce-emai
2357
  */
2358
  public static function get_default_value( $key ) {
2359
  // Get default values
2360
- $default_values = Kadence_Woomail_Settings::get_default_values();
2361
 
2362
  // Check if such key exists and return default value
2363
  return isset($default_values[$key]) ? $default_values[$key] : '';
@@ -2439,7 +2437,7 @@ To reset your password, visit the following address:', 'kadence-woocommerce-emai
2439
  * @return array
2440
  */
2441
  public static function get_font_families() {
2442
- return apply_filters( 'kadence_woomail_email_font_families', Kadence_Woomail_Settings::$font_family_mapping );
2443
  }
2444
  /**
2445
  * Get Email Types
@@ -2449,12 +2447,12 @@ To reset your password, visit the following address:', 'kadence-woocommerce-emai
2449
  */
2450
  public static function get_email_types() {
2451
  if ( is_null( self::$email_types ) ) {
2452
- $types = Kadence_Woomail_Settings::$email_types_mapping;
2453
  if ( class_exists( 'WC_Subscriptions' ) ) {
2454
- $types = array_merge($types, Kadence_Woomail_Settings::$subscription_email_types_mapping );
2455
  }
2456
  if ( class_exists( 'WooCommerce_Waitlist_Plugin' ) ) {
2457
- $types = array_merge($types, Kadence_Woomail_Settings::$waitlist_email_types_mapping );
2458
  }
2459
 
2460
  self::$email_types = apply_filters( 'kadence_woomail_email_types', $types );
@@ -2464,19 +2462,19 @@ To reset your password, visit the following address:', 'kadence-woocommerce-emai
2464
  }
2465
 
2466
  /**
2467
- * Get Email Types
2468
- *
2469
- * @access public
2470
- * @return array
2471
- */
2472
  public static function get_customized_email_types() {
2473
  if ( is_null( self::$email_types ) ) {
2474
- $types = Kadence_Woomail_Settings::$email_types_mapping;
2475
  if ( class_exists( 'WC_Subscriptions' ) ) {
2476
- $types = array_merge($types, Kadence_Woomail_Settings::$subscription_email_types_mapping );
2477
  }
2478
  if ( class_exists( 'WooCommerce_Waitlist_Plugin' ) ) {
2479
- $types = array_merge($types, Kadence_Woomail_Settings::$waitlist_email_types_mapping );
2480
  }
2481
 
2482
  self::$email_types = apply_filters( 'kadence_woomail_customized_email_types', $types );
@@ -2486,13 +2484,13 @@ To reset your password, visit the following address:', 'kadence-woocommerce-emai
2486
  }
2487
 
2488
  /**
2489
- * Get Email Templates
2490
- *
2491
- * @access public
2492
- * @return array
2493
- */
2494
  public static function get_email_templates() {
2495
- return apply_filters( 'kadence_woomail_prebuilt_email_templates_settings', Kadence_Woomail_Settings::$prebuilt_templates_mapping );
2496
  }
2497
 
2498
 
1
  <?php
2
+ // Exit if accessed directly.
 
3
  if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
  }
6
 
7
  /**
12
 
13
  class Kadence_Woomail_Settings {
14
  /**
15
+ * @var null
16
+ */
17
+ private static $panels = null;
18
+ private static $sections = null;
19
+ private static $settings = null;
20
+ private static $woo_copy_settings = null;
21
+ private static $woo_settings = null;
22
+ private static $default_values = null;
23
+ private static $order_ids = null;
24
+ private static $email_types = null;
25
+
26
+ // Font family.
27
  public static $font_family_mapping = array(
28
  'helvetica' => '"Helvetica Neue", Helvetica, Roboto, Arial, sans-serif',
29
  'arial' => 'Arial, Helvetica, sans-serif',
219
  ),
220
  );
221
  }
222
+ // Return sections.
223
+ return self::$sections;
224
+ }
 
225
 
226
  /**
227
  * Get woocommerce settings that the plugin will allow editing of
231
  */
232
  public static function get_woo_settings() {
233
 
234
+ if ( is_null( self::$woo_settings ) ) {
235
+ $base_options = array();
236
 
237
+ // Email header image.
238
+ $base_options[ 'woocommerce_email_header_image' ] = array(
239
  'title' => __('Header Image', 'kadence-woocommerce-email-designer'),
240
  'control_type' => 'image',
241
  'section' => 'header_image',
242
+ 'default' => self::get_default_value( 'header_image' ),
243
  'original' => '',
244
  'priority' => 5,
245
+ 'transport' => 'refresh',
246
  'selectors' => array(
247
+ '#template_header_image img'
248
  ),
249
  );
250
  // Email background color
253
  'section' => 'container',
254
  'control_type' => 'color',
255
  'priority' => 5,
256
+ 'default' => self::get_default_value('body_background_color'),
257
  'live_method' => 'css',
258
  'selectors' => array(
259
  'body' => array('background-color'),
265
  'title' => __('Content Text color', 'kadence-woocommerce-email-designer'),
266
  'section' => 'text_style',
267
  'control_type' => 'color',
268
+ 'default' => self::get_default_value('text_color'),
269
  'live_method' => 'css',
270
  'selectors' => array(
271
  '#body_content_inner' => array('color'),
280
  'section' => 'content_container',
281
  'control_type' => 'color',
282
  'priority' => 5,
283
+ 'default' => self::get_default_value('background_color'),
284
  'live_method' => 'css',
285
  'selectors' => array(
286
  '#body_content' => array('background-color'),
293
  'title' => __('Footer text', 'kadence-woocommerce-email-designer'),
294
  'type' => 'textarea',
295
  'section' => 'footer_content',
296
+ 'default' => self::get_default_value( 'footer_content_text' ),
297
  'original' => '',
298
  'live_method' => 'replace',
299
  'selectors' => array(
301
  ),
302
  );
303
  $email_text = array();
304
+ foreach ( self::get_email_types() as $key => $value ) {
305
  // Email recipients Text
306
  if ( 'cancelled_order' == $key || 'new_order' == $key || 'failed_order' == $key ) {
307
  $email_text['woocommerce_'.$key.'_settings[recipient]'] = array(
327
  'priority' => 5,
328
  'default' => '',
329
  'input_attrs' => array(
330
+ 'placeholder' => self::get_default_value( $key.'_subject_full' ),
331
  ),
332
  'active_callback' => array(
333
  'id' => 'email_type',
343
  'priority' => 5,
344
  'default' => '',
345
  'input_attrs' => array(
346
+ 'placeholder' => self::get_default_value( $key.'_subject_partial' ),
347
  ),
348
  'active_callback' => array(
349
  'id' => 'email_type',
359
  'priority' => 5,
360
  'default' => '',
361
  'input_attrs' => array(
362
+ 'placeholder' => self::get_default_value( $key.'_heading_full' ),
363
  ),
364
  'live_method' => 'replace',
365
  'selectors' => array(
379
  'priority' => 5,
380
  'default' => '',
381
  'input_attrs' => array(
382
+ 'placeholder' => self::get_default_value( $key.'_heading_partial' ),
383
  ),
384
  'active_callback' => array(
385
  'id' => 'email_type',
396
  'priority' => 5,
397
  'default' => '',
398
  'input_attrs' => array(
399
+ 'placeholder' => self::get_default_value( $key.'_subject' ),
400
  ),
401
  'active_callback' => array(
402
  'id' => 'email_type',
412
  'priority' => 5,
413
  'default' => '',
414
  'input_attrs' => array(
415
+ 'placeholder' => self::get_default_value( $key.'_subject_paid' ),
416
  ),
417
  'active_callback' => array(
418
  'id' => 'email_type',
429
  'priority' => 5,
430
  'default' => '',
431
  'input_attrs' => array(
432
+ 'placeholder' => self::get_default_value( $key.'_heading' ),
433
  ),
434
  'live_method' => 'replace',
435
  'selectors' => array(
449
  'priority' => 5,
450
  'default' => '',
451
  'input_attrs' => array(
452
+ 'placeholder' => self::get_default_value( $key.'_heading_paid' ),
453
  ),
454
  'active_callback' => array(
455
  'id' => 'email_type',
481
  'title' => __('Template_load', 'kadence-woocommerce-email-designer'),
482
  'section' => 'template',
483
  'control_type' => 'kwdtemplateload',
484
+ 'choices' => self::get_email_templates(),
485
  'default' => 'kt_full',
486
  'transport' => 'refresh',
487
  ),
491
  'section' => 'mtype',
492
  'type' => 'select',
493
  'priority' => 1,
494
+ 'choices' => self::get_order_ids(),
495
+ 'default' => self::get_default_value('preview_order_id'),
496
  'transport' => 'refresh',
497
  ),
498
  //Email Type
501
  'section' => 'mtype',
502
  'type' => 'select',
503
  'priority' => 2,
504
+ 'choices' => self::get_email_types(),
505
+ 'default' => self::get_default_value('email_type'),
506
  'transport' => 'refresh',
507
  ),
508
  //Placeholder Info
516
  );
517
  $extra_email_text = array();
518
  // Get the Extra Text area settings.
519
+ foreach (self::get_customized_email_types() as $key => $value) {
520
  // Email Subtitle Text
521
  $extra_email_text[$key.'_subtitle'] = array(
522
  'title' => __('Subtitle Text', 'kadence-woocommerce-email-designer'),
541
  'control_type' => 'toggleswitch',
542
  'section' => 'mtype',
543
  'transport' => 'refresh',
544
+ 'default' => self::get_default_value( $key.'_switch' ),
545
  'original' => '',
546
  'priority' => 3,
547
  'active_callback' => array(
555
  'title' => __('Body Full Refund Text', 'kadence-woocommerce-email-designer'),
556
  'type' => 'textarea',
557
  'section' => 'mtype',
558
+ 'default' => self::get_default_value( $key.'_body_full' ),
559
  'original' => '',
560
  'transport' => 'refresh',
561
  'active_callback' => array(
569
  'title' => __('Body Partial Refund Text', 'kadence-woocommerce-email-designer'),
570
  'type' => 'textarea',
571
  'section' => 'mtype',
572
+ 'default' => self::get_default_value( $key.'_body_partial' ),
573
  'original' => '',
574
  'transport' => 'refresh',
575
  'active_callback' => array(
585
  'control_type' => 'toggleswitch',
586
  'section' => 'mtype',
587
  'transport' => 'refresh',
588
+ 'default' => self::get_default_value( $key.'_switch' ),
589
  'original' => '',
590
  'priority' => 3,
591
  'active_callback' => array(
599
  'title' => __('Body Invoice Paid Text', 'kadence-woocommerce-email-designer'),
600
  'type' => 'textarea',
601
  'section' => 'mtype',
602
+ 'default' => self::get_default_value( $key.'_body_paid' ),
603
  'original' => '',
604
  'transport' => 'refresh',
605
  'active_callback' => array(
613
  'title' => __('Body Invoice Pending Payment Text', 'kadence-woocommerce-email-designer'),
614
  'type' => 'textarea',
615
  'section' => 'mtype',
616
+ 'default' => self::get_default_value( $key.'_body' ),
617
  'original' => '',
618
  'active_callback' => array(
619
  'id' => 'email_type',
627
  'title' => __('Body Invoice Failed Text', 'kadence-woocommerce-email-designer'),
628
  'type' => 'textarea',
629
  'section' => 'mtype',
630
+ 'default' => self::get_default_value( $key.'_body_failed' ),
631
  'original' => '',
632
  'transport' => 'refresh',
633
  'active_callback' => array(
641
  'title' => __('Body Invoice Pending Payment Text', 'kadence-woocommerce-email-designer'),
642
  'type' => 'textarea',
643
  'section' => 'mtype',
644
+ 'default' => self::get_default_value( $key.'_body' ),
645
  'original' => '',
646
  'active_callback' => array(
647
  'id' => 'email_type',
655
  'title' => __('Body Text', 'kadence-woocommerce-email-designer'),
656
  'type' => 'textarea',
657
  'section' => 'mtype',
658
+ 'default' => self::get_default_value( $key.'_body' ),
659
  'original' => '',
660
  'transport' => 'refresh',
661
  'active_callback' => array(
673
  'title' => __('Content Width', 'kadence-woocommerce-email-designer'),
674
  'control_type' => 'rangevalue',
675
  'section' => 'container',
676
+ 'default' => self::get_default_value('content_width'),
677
  'live_method' => 'css',
678
  'selectors' => array(
679
  '#template_container' => array('width'),
693
  'title' => __('Border radius', 'kadence-woocommerce-email-designer'),
694
  'control_type' => 'rangevalue',
695
  'section' => 'container',
696
+ 'default' => self::get_default_value('border_radius'),
697
  'live_method' => 'css',
698
  'selectors' => array(
699
  '#template_container' => array('border-radius'),
709
  'title' => __('Border Width', 'kadence-woocommerce-email-designer'),
710
  'control_type' => 'rangevalue',
711
  'section' => 'container',
712
+ 'default' => self::get_default_value('border_width'),
713
  'live_method' => 'css',
714
  'selectors' => array(
715
  'body #template_container' => array('border-width'),
725
  'title' => __('Border color', 'kadence-woocommerce-email-designer'),
726
  'section' => 'container',
727
  'control_type' => 'color',
728
+ 'default' => self::get_default_value('border_color'),
729
  'live_method' => 'css',
730
  'selectors' => array(
731
  'body #template_container' => array('border-color'),
737
  'control_type' => 'rangevalue',
738
  'section' => 'container',
739
  'description' => __('Warning: most email clients do not yet support this', 'kadence-woocommerce-email-designer'),
740
+ 'default' => self::get_default_value('shadow'),
741
  'live_method' => 'css',
742
  'selectors' => array(
743
  'body #template_container' => array('box-shadow'),
753
  'title' => __('Container Top Padding', 'kadence-woocommerce-email-designer'),
754
  'control_type' => 'rangevalue',
755
  'section' => 'container',
756
+ 'default' => self::get_default_value('email_padding'),
757
  'live_method' => 'css',
758
  'selectors' => array(
759
  '#wrapper' => array('padding-top'),
769
  'title' => __('Container Botom Padding', 'kadence-woocommerce-email-designer'),
770
  'control_type' => 'rangevalue',
771
  'section' => 'container',
772
+ 'default' => self::get_default_value('email_padding'),
773
  'live_method' => 'css',
774
  'selectors' => array(
775
  '#wrapper' => array('padding-bottom'),
785
  'header_image_align' => array(
786
  'title' => __('Image Align', 'kadence-woocommerce-email-designer'),
787
  'section' => 'header_image',
788
+ 'default' => self::get_default_value('header_image_align'),
789
  'live_method' => 'css',
790
  'type' => 'select',
791
+ 'choices' => self::get_image_aligns(),
792
  'selectors' => array(
793
  '#template_header_image_table td' => array('text-align'),
794
  ),
797
  'header_image_maxwidth' => array(
798
  'title' => __('Image Max Width', 'kadence-woocommerce-email-designer'),
799
  'section' => 'header_image',
800
+ 'default' => self::get_default_value('header_image_maxwidth'),
801
  'live_method' => 'css',
802
  'control_type' => 'rangevalue',
803
  'selectors' => array(
813
  'title' => __('Background color', 'kadence-woocommerce-email-designer'),
814
  'section' => 'header_image',
815
  'control_type' => 'color',
816
+ 'default' => self::get_default_value('header_image_background_color'),
817
  'live_method' => 'css',
818
  'selectors' => array(
819
  '#template_header_image_container' => array('background-color'),
824
  'title' => __('Padding top/bottom', 'kadence-woocommerce-email-designer'),
825
  'control_type' => 'rangevalue',
826
  'section' => 'header_image',
827
+ 'default' => self::get_default_value('header_image_padding_top_bottom'),
828
  'live_method' => 'css',
829
  'selectors' => array(
830
  '#template_header_image_table td' => array('padding-top', 'padding-bottom'),
840
  'title' => __('Background color', 'kadence-woocommerce-email-designer'),
841
  'section' => 'header_style',
842
  'control_type' => 'color',
843
+ 'default' => self::get_default_value('header_background_color'),
844
  'live_method' => 'css',
845
  'selectors' => array(
846
  '#template_header' => array('background-color'),
850
  'header_text_align' => array(
851
  'title' => __('Text align', 'kadence-woocommerce-email-designer'),
852
  'section' => 'header_style',
853
+ 'default' => self::get_default_value('header_text_align'),
854
  'live_method' => 'css',
855
  'type' => 'select',
856
+ 'choices' => self::get_text_aligns(),
857
  'selectors' => array(
858
  '#header_wrapper h1' => array('text-align'),
859
  '#header_wrapper' => array('text-align'),
865
  'title' => __('Padding Top', 'kadence-woocommerce-email-designer'),
866
  'control_type' => 'rangevalue',
867
  'section' => 'header_style',
868
+ 'default' => self::get_default_value('header_padding_top_bottom'),
869
  'live_method' => 'css',
870
  'selectors' => array(
871
  '#header_wrapper' => array('padding-top'),
881
  'title' => __('Padding Bottom', 'kadence-woocommerce-email-designer'),
882
  'control_type' => 'rangevalue',
883
  'section' => 'header_style',
884
+ 'default' => self::get_default_value('header_padding_top_bottom'),
885
  'live_method' => 'css',
886
  'selectors' => array(
887
  '#header_wrapper' => array('padding-bottom'),
898
  'title' => __('Padding left/right', 'kadence-woocommerce-email-designer'),
899
  'control_type' => 'rangevalue',
900
  'section' => 'header_style',
901
+ 'default' => self::get_default_value('header_padding_left_right'),
902
  'live_method' => 'css',
903
  'selectors' => array(
904
  '#header_wrapper' => array('padding-left', 'padding-right'),
914
  'title' => __('Heading Font size', 'kadence-woocommerce-email-designer'),
915
  'control_type' => 'rangevalue',
916
  'section' => 'heading',
917
+ 'default' => self::get_default_value('heading_font_size'),
918
  'live_method' => 'css',
919
  'selectors' => array(
920
  '#template_header h1' => array('font-size'),
930
  'title' => __('Heading Line Height', 'kadence-woocommerce-email-designer'),
931
  'control_type' => 'rangevalue',
932
  'section' => 'heading',
933
+ 'default' => self::get_default_value('heading_line_height'),
934
  'live_method' => 'css',
935
  'selectors' => array(
936
  '#template_header h1' => array('line-height'),
945
  'heading_font_family' => array(
946
  'title' => __('Heading Font family', 'kadence-woocommerce-email-designer'),
947
  'section' => 'heading',
948
+ 'default' => self::get_default_value('heading_font_family'),
949
  'live_method' => 'css',
950
  'type' => 'select',
951
+ 'choices' => self::get_font_families(),
952
  'selectors' => array(
953
  '#template_header h1' => array('font-family'),
954
  ),
957
  'heading_font_style' => array(
958
  'title' => __('Heading Font Style', 'kadence-woocommerce-email-designer'),
959
  'section' => 'heading',
960
+ 'default' => self::get_default_value('heading_font_style'),
961
  'live_method' => 'css',
962
  'type' => 'select',
963
  'choices' => array(
973
  'title' => __('Heading Font weight', 'kadence-woocommerce-email-designer'),
974
  'control_type' => 'rangevalue',
975
  'section' => 'heading',
976
+ 'default' => self::get_default_value('heading_font_weight'),
977
  'live_method' => 'css',
978
  'selectors' => array(
979
  '#template_header h1' => array('font-weight'),
989
  'title' => __('Heading Text color', 'kadence-woocommerce-email-designer'),
990
  'section' => 'heading',
991
  'control_type' => 'color',
992
+ 'default' => self::get_default_value('heading_color'),
993
  'live_method' => 'css',
994
  'selectors' => array(
995
  '#template_header' => array('color'),
1007
  'subtitle_placement' => array(
1008
  'title' => __('Subtitle Placement', 'kadence-woocommerce-email-designer'),
1009
  'section' => 'heading',
1010
+ 'default' => self::get_default_value('subtitle_placement'),
1011
  'transport' => 'refresh',
1012
  'type' => 'select',
1013
  'choices' => array(
1021
  'title' => __('Subtitle Font Size', 'kadence-woocommerce-email-designer'),
1022
  'control_type' => 'rangevalue',
1023
  'section' => 'heading',
1024
+ 'default' => self::get_default_value('subtitle_font_size'),
1025
  'live_method' => 'css',
1026
  'selectors' => array(
1027
  '#template_header .subtitle' => array('font-size'),
1037
  'title' => __('Subtitle Line Height', 'kadence-woocommerce-email-designer'),
1038
  'control_type' => 'rangevalue',
1039
  'section' => 'heading',
1040
+ 'default' => self::get_default_value('subtitle_line_height'),
1041
  'live_method' => 'css',
1042
  'selectors' => array(
1043
  '#template_header .subtitle' => array('line-height'),
1052
  'subtitle_font_family' => array(
1053
  'title' => __('Subtitle Font Family', 'kadence-woocommerce-email-designer'),
1054
  'section' => 'heading',
1055
+ 'default' => self::get_default_value('subtitle_font_family'),
1056
  'live_method' => 'css',
1057
  'type' => 'select',
1058
+ 'choices' => self::get_font_families(),
1059
  'selectors' => array(
1060
  '#template_header .subtitle' => array('font-family'),
1061
  ),
1064
  'subtitle_font_style' => array(
1065
  'title' => __('Subtitle Font Style', 'kadence-woocommerce-email-designer'),
1066
  'section' => 'heading',
1067
+ 'default' => self::get_default_value('subtitle_font_style'),
1068
  'live_method' => 'css',
1069
  'type' => 'select',
1070
  'choices' => array(
1081
  'title' => __('Subtitle Font weight', 'kadence-woocommerce-email-designer'),
1082
  'control_type' => 'rangevalue',
1083
  'section' => 'heading',
1084
+ 'default' => self::get_default_value('subtitle_font_weight'),
1085
  'live_method' => 'css',
1086
  'selectors' => array(
1087
  '#template_header .subtitle' => array('font-weight'),
1098
  'title' => __('Subtitle Text color', 'kadence-woocommerce-email-designer'),
1099
  'section' => 'heading',
1100
  'control_type' => 'color',
1101
+ 'default' => self::get_default_value('subtitle_color'),
1102
  'live_method' => 'css',
1103
  'selectors' => array(
1104
  '#template_header .subtitle' => array('color'),
1110
  'title' => __('Padding Top', 'kadence-woocommerce-email-designer'),
1111
  'control_type' => 'rangevalue',
1112
  'section' => 'content_container',
1113
+ 'default' => self::get_default_value('content_padding'),
1114
  'live_method' => 'css',
1115
  'selectors' => array(
1116
  '#body_content' => array('padding-top'),
1126
  'title' => __('Padding Bottom', 'kadence-woocommerce-email-designer'),
1127
  'control_type' => 'rangevalue',
1128
  'section' => 'content_container',
1129
+ 'default' => self::get_default_value('content_padding_bottom'),
1130
  'live_method' => 'css',
1131
  'selectors' => array(
1132
  '#body_content' => array('padding-bottom'),
1142
  'title' => __('Padding Left/Right', 'kadence-woocommerce-email-designer'),
1143
  'control_type' => 'rangevalue',
1144
  'section' => 'content_container',
1145
+ 'default' => self::get_default_value('content_padding'),
1146
  'live_method' => 'css',
1147
  'selectors' => array(
1148
  '#body_content > table > tbody > tr > td' => array('padding-left', 'padding-right'),
1160
  'title' => __('Font Size', 'kadence-woocommerce-email-designer'),
1161
  'control_type' => 'rangevalue',
1162
  'section' => 'text_style',
1163
+ 'default' => self::get_default_value('font_size'),
1164
  'live_method' => 'css',
1165
  'selectors' => array(
1166
  '#body_content_inner' => array('font-size'),
1177
  'title' => __('Line Height', 'kadence-woocommerce-email-designer'),
1178
  'control_type' => 'rangevalue',
1179
  'section' => 'text_style',
1180
+ 'default' => self::get_default_value('line_height'),
1181
  'live_method' => 'css',
1182
  'selectors' => array(
1183
  '#body_content_inner' => array('line-height'),
1193
  'font_family' => array(
1194
  'title' => __('Font Family', 'kadence-woocommerce-email-designer'),
1195
  'section' => 'text_style',
1196
+ 'default' => self::get_default_value('font_family'),
1197
  'live_method' => 'css',
1198
  'type' => 'select',
1199
+ 'choices' => self::get_font_families(),
1200
  'selectors' => array(
1201
  '#body_content_inner' => array('font-family'),
1202
  '.td' => array('font-family'),
1208
  'title' => __('Font weight', 'kadence-woocommerce-email-designer'),
1209
  'control_type' => 'rangevalue',
1210
  'section' => 'text_style',
1211
+ 'default' => self::get_default_value('font_weight'),
1212
  'live_method' => 'css',
1213
  'selectors' => array(
1214
  '#body_content_inner' => array('font-weight'),
1224
  'title' => __('Link Color', 'kadence-woocommerce-email-designer'),
1225
  'section' => 'text_style',
1226
  'control_type' => 'color',
1227
+ 'default' => self::get_default_value('link_color'),
1228
  'live_method' => 'css',
1229
  'selectors' => array(
1230
  'a' => array('color'),
1238
  'title' => __('H2 Font Size', 'kadence-woocommerce-email-designer'),
1239
  'control_type' => 'rangevalue',
1240
  'section' => 'headings_style',
1241
+ 'default' => self::get_default_value('h2_font_size'),
1242
  'live_method' => 'css',
1243
  'selectors' => array(
1244
  '#template_body h2' => array('font-size'),
1254
  'title' => __('H2 Line Height', 'kadence-woocommerce-email-designer'),
1255
  'control_type' => 'rangevalue',
1256
  'section' => 'headings_style',
1257
+ 'default' => self::get_default_value('h2_line_height'),
1258
  'live_method' => 'css',
1259
  'selectors' => array(
1260
  '#template_body h2' => array('line-height'),
1270
  'title' => __('H2 Padding Top', 'kadence-woocommerce-email-designer'),
1271
  'control_type' => 'rangevalue',
1272
  'section' => 'headings_style',
1273
+ 'default' => self::get_default_value('h2_padding_top'),
1274
  'live_method' => 'css',
1275
  'selectors' => array(
1276
  '#template_body h2' => array('padding-top'),
1286
  'title' => __('H2 Padding Bottom', 'kadence-woocommerce-email-designer'),
1287
  'control_type' => 'rangevalue',
1288
  'section' => 'headings_style',
1289
+ 'default' => self::get_default_value('h2_padding_bottom'),
1290
  'live_method' => 'css',
1291
  'selectors' => array(
1292
  '#template_body h2' => array('padding-bottom'),
1302
  'title' => __('H2 Margin Top', 'kadence-woocommerce-email-designer'),
1303
  'control_type' => 'rangevalue',
1304
  'section' => 'headings_style',
1305
+ 'default' => self::get_default_value('h2_margin_top'),
1306
  'live_method' => 'css',
1307
  'selectors' => array(
1308
  '#template_body h2' => array('margin-top'),
1318
  'title' => __('H2 Margin Bottom', 'kadence-woocommerce-email-designer'),
1319
  'control_type' => 'rangevalue',
1320
  'section' => 'headings_style',
1321
+ 'default' => self::get_default_value('h2_margin_bottom'),
1322
  'live_method' => 'css',
1323
  'selectors' => array(
1324
  '#template_body h2' => array('margin-bottom'),
1333
  'h2_font_family' => array(
1334
  'title' => __('H2 Font Family', 'kadence-woocommerce-email-designer'),
1335
  'section' => 'headings_style',
1336
+ 'default' => self::get_default_value('h2_font_family'),
1337
  'live_method' => 'css',
1338
  'type' => 'select',
1339
+ 'choices' => self::get_font_families(),
1340
  'selectors' => array(
1341
  '#template_body h2' => array('font-family'),
1342
  '#template_body h2 a' => array('font-family'),
1346
  'h2_font_style' => array(
1347
  'title' => __('H2 Font Style', 'kadence-woocommerce-email-designer'),
1348
  'section' => 'headings_style',
1349
+ 'default' => self::get_default_value('h2_font_style'),
1350
  'live_method' => 'css',
1351
  'type' => 'select',
1352
  'choices' => array(
1363
  'title' => __('H2 Font weight', 'kadence-woocommerce-email-designer'),
1364
  'control_type' => 'rangevalue',
1365
  'section' => 'headings_style',
1366
+ 'default' => self::get_default_value('h2_font_weight'),
1367
  'live_method' => 'css',
1368
  'selectors' => array(
1369
  '#template_body h2' => array('font-weight'),
1379
  'h2_text_transform' => array(
1380
  'title' => __('H2 Text Transform', 'kadence-woocommerce-email-designer'),
1381
  'section' => 'headings_style',
1382
+ 'default' => self::get_default_value('h2_text_transform'),
1383
  'live_method' => 'css',
1384
  'type' => 'select',
1385
  'choices' => array(
1397
  'title' => __('H2 Color', 'kadence-woocommerce-email-designer'),
1398
  'section' => 'headings_style',
1399
  'control_type' => 'color',
1400
+ 'default' => self::get_default_value('h2_color'),
1401
  'live_method' => 'css',
1402
  'selectors' => array(
1403
  '#template_body h2' => array('color'),
1408
  'h2_text_align' => array(
1409
  'title' => __('H2 Text Align', 'kadence-woocommerce-email-designer'),
1410
  'section' => 'headings_style',
1411
+ 'default' => self::get_default_value('h2_text_align'),
1412
  'live_method' => 'css',
1413
  'type' => 'select',
1414
+ 'choices' => self::get_text_aligns(),
1415
  'selectors' => array(
1416
  '#template_body h2' => array('text-align'),
1417
  ),
1420
  'h2_style' => array(
1421
  'title' => __('H2 Separator', 'kadence-woocommerce-email-designer'),
1422
  'section' => 'headings_style',
1423
+ 'default' => self::get_default_value('h2_style'),
1424
  'transport' => 'refresh',
1425
  'type' => 'select',
1426
  'choices' => array(
1434
  'title' => __('H2 Separator height', 'kadence-woocommerce-email-designer'),
1435
  'section' => 'headings_style',
1436
  'control_type' => 'rangevalue',
1437
+ 'default' => self::get_default_value('h2_style'),
1438
  'live_method' => 'css',
1439
  'type' => 'select',
1440
  'input_attrs' => array(
1451
  'h2_separator_style' => array(
1452
  'title' => __('H2 Separator Style', 'kadence-woocommerce-email-designer'),
1453
  'section' => 'headings_style',
1454
+ 'default' => self::get_default_value('h2_style'),
1455
  'live_method' => 'css',
1456
  'type' => 'select',
1457
  'choices' => array(
1472
  'title' => __('H2 Separator Color', 'kadence-woocommerce-email-designer'),
1473
  'section' => 'headings_style',
1474
  'control_type' => 'color',
1475
+ 'default' => self::get_default_value('h2_separator_color'),
1476
  'live_method' => 'css',
1477
  'selectors' => array(
1478
  '.title-style-below #template_body h2' => array('border-bottom-color'),
1492
  'title' => __('H3 Font Size', 'kadence-woocommerce-email-designer'),
1493
  'control_type' => 'rangevalue',
1494
  'section' => 'headings_style',
1495
+ 'default' => self::get_default_value('h3_font_size'),
1496
  'live_method' => 'css',
1497
  'selectors' => array(
1498
  '#template_body h3' => array('font-size'),
1508
  'title' => __('H3 Line Height', 'kadence-woocommerce-email-designer'),
1509
  'control_type' => 'rangevalue',
1510
  'section' => 'headings_style',
1511
+ 'default' => self::get_default_value('h2_line_height'),
1512
  'live_method' => 'css',
1513
  'selectors' => array(
1514
  '#template_body h3' => array('line-height'),
1523
  'h3_font_family' => array(
1524
  'title' => __('H3 Font Family', 'kadence-woocommerce-email-designer'),
1525
  'section' => 'headings_style',
1526
+ 'default' => self::get_default_value('h2_font_family'),
1527
  'live_method' => 'css',
1528
  'type' => 'select',
1529
+ 'choices' => self::get_font_families(),
1530
  'selectors' => array(
1531
  '#template_body h3' => array('font-family'),
1532
  ),
1535
  'h3_font_style' => array(
1536
  'title' => __('H3 Font Style', 'kadence-woocommerce-email-designer'),
1537
  'section' => 'headings_style',
1538
+ 'default' => self::get_default_value('h3_font_style'),
1539
  'live_method' => 'css',
1540
  'type' => 'select',
1541
  'choices' => array(
1551
  'title' => __('H3 Font weight', 'kadence-woocommerce-email-designer'),
1552
  'control_type' => 'rangevalue',
1553
  'section' => 'headings_style',
1554
+ 'default' => self::get_default_value('h3_font_weight'),
1555
  'live_method' => 'css',
1556
  'selectors' => array(
1557
  '#template_body h3' => array('font-weight'),
1567
  'title' => __('H3 Color', 'kadence-woocommerce-email-designer'),
1568
  'section' => 'headings_style',
1569
  'control_type' => 'color',
1570
+ 'default' => self::get_default_value('h3_color'),
1571
  'live_method' => 'css',
1572
  'selectors' => array(
1573
  '#template_body h3' => array('color'),
1577
  'order_items_style' => array(
1578
  'title' => __('Order Table Style', 'kadence-woocommerce-email-designer'),
1579
  'section' => 'items_table',
1580
+ 'default' => self::get_default_value('order_items_style'),
1581
  'transport' => 'refresh',
1582
  'type' => 'select',
1583
  'choices' => array(
1589
  'order_items_image' => array(
1590
  'title' => __('Product Image Option', 'kadence-woocommerce-email-designer'),
1591
  'section' => 'items_table',
1592
+ 'default' => self::get_default_value( 'order_items_image' ),
1593
  'transport' => 'refresh',
1594
  'type' => 'select',
1595
  'choices' => array(
1602
  'title' => __('Order Table Background color', 'kadence-woocommerce-email-designer'),
1603
  'section' => 'items_table',
1604
  'control_type' => 'color',
1605
+ 'default' => self::get_default_value('items_table_background_color'),
1606
  'live_method' => 'css',
1607
  'selectors' => array(
1608
  '#body_content_inner table.td' => array('background-color'),
1614
  'title' => __('Padding', 'kadence-woocommerce-email-designer'),
1615
  'control_type' => 'rangevalue',
1616
  'section' => 'items_table',
1617
+ 'default' => self::get_default_value('items_table_padding'),
1618
  'live_method' => 'css',
1619
  'selectors' => array(
1620
  '.order-items-normal #body_content_inner table.td th' => array('padding'),
1634
  'title' => __('Border Width', 'kadence-woocommerce-email-designer'),
1635
  'control_type' => 'rangevalue',
1636
  'section' => 'items_table',
1637
+ 'default' => self::get_default_value('items_table_border_width'),
1638
  'live_method' => 'css',
1639
  'selectors' => array(
1640
  '.order-items-normal #body_content_inner .td' => array('border-width'),
1653
  'title' => __('Border Color', 'kadence-woocommerce-email-designer'),
1654
  'section' => 'items_table',
1655
  'control_type' => 'color',
1656
+ 'default' => self::get_default_value('items_table_border_color'),
1657
  'live_method' => 'css',
1658
  'selectors' => array(
1659
  '#body_content_inner .td' => array('border-color'),
1663
  'items_table_border_style' => array(
1664
  'title' => __('Border Style', 'kadence-woocommerce-email-designer'),
1665
  'section' => 'items_table',
1666
+ 'default' => self::get_default_value('items_table_border_style'),
1667
  'live_method' => 'css',
1668
  'type' => 'select',
1669
  'choices' => array(
1684
  'order_heading_style' => array(
1685
  'title' => __('Order Table Heading Style', 'kadence-woocommerce-email-designer'),
1686
  'section' => 'items_table',
1687
+ 'default' => self::get_default_value('order_heading_style'),
1688
  'transport' => 'refresh',
1689
  'type' => 'select',
1690
  'choices' => array(
1697
  'title' => __('Address Box Background color', 'kadence-woocommerce-email-designer'),
1698
  'section' => 'addresses',
1699
  'control_type' => 'color',
1700
+ 'default' => self::get_default_value('addresses_background_color'),
1701
  'live_method' => 'css',
1702
  'selectors' => array(
1703
  '#body_content_inner address' => array('background-color'),
1708
  'title' => __('Address Box Border Width', 'kadence-woocommerce-email-designer'),
1709
  'control_type' => 'rangevalue',
1710
  'section' => 'addresses',
1711
+ 'default' => self::get_default_value('addresses_border_width'),
1712
  'live_method' => 'css',
1713
  'selectors' => array(
1714
  '#body_content_inner address' => array('border-width'),
1724
  'title' => __('Address Box Border Color', 'kadence-woocommerce-email-designer'),
1725
  'section' => 'addresses',
1726
  'control_type' => 'color',
1727
+ 'default' => self::get_default_value('addresses_border_color'),
1728
  'live_method' => 'css',
1729
  'selectors' => array(
1730
  '#body_content_inner address' => array('border-color'),
1734
  'addresses_border_style' => array(
1735
  'title' => __('Address Box Border Style', 'kadence-woocommerce-email-designer'),
1736
  'section' => 'addresses',
1737
+ 'default' => self::get_default_value('addresses_border_style'),
1738
  'live_method' => 'css',
1739
  'type' => 'select',
1740
  'choices' => array(
1754
  'title' => __('Address Box Text Color', 'kadence-woocommerce-email-designer'),
1755
  'section' => 'addresses',
1756
  'control_type' => 'color',
1757
+ 'default' => self::get_default_value('addresses_text_color'),
1758
  'live_method' => 'css',
1759
  'selectors' => array(
1760
  '#body_content_inner address' => array('color'),
1764
  'addresses_text_align' => array(
1765
  'title' => __('Address Box Text Align', 'kadence-woocommerce-email-designer'),
1766
  'section' => 'addresses',
1767
+ 'default' => self::get_default_value('addresses_text_align'),
1768
  'live_method' => 'css',
1769
  'type' => 'select',
1770
+ 'choices' => self::get_text_aligns(),
1771
  'selectors' => array(
1772
  '#body_content_inner address' => array('text-align'),
1773
  ),
1776
  'footer_background_placement' => array(
1777
  'title' => __('Footer Background Placement', 'kadence-woocommerce-email-designer'),
1778
  'section' => 'footer_style',
1779
+ 'default' => self::get_default_value('footer_background_placement'),
1780
  'transport' => 'refresh',
1781
  'type' => 'select',
1782
  'choices' => array(
1789
  'title' => __('Footer Background Color', 'kadence-woocommerce-email-designer'),
1790
  'section' => 'footer_style',
1791
  'control_type' => 'color',
1792
+ 'default' => self::get_default_value('footer_background_color'),
1793
  'live_method' => 'css',
1794
  'selectors' => array(
1795
  '#template_footer_container' => array('background-color'),
1800
  'title' => __('Top Padding', 'kadence-woocommerce-email-designer'),
1801
  'control_type' => 'rangevalue',
1802
  'section' => 'footer_style',
1803
+ 'default' => self::get_default_value('footer_top_padding'),
1804
  'live_method' => 'css',
1805
  'selectors' => array(
1806
  '#template_footer #template_footer_inside' => array('padding-top'),
1816
  'title' => __('Bottom Padding', 'kadence-woocommerce-email-designer'),
1817
  'control_type' => 'rangevalue',
1818
  'section' => 'footer_style',
1819
+ 'default' => self::get_default_value('footer_bottom_padding'),
1820
  'live_method' => 'css',
1821
  'selectors' => array(
1822
  '#template_footer #template_footer_inside' => array('padding-bottom'),
1832
  'title' => __('Left/Right Padding', 'kadence-woocommerce-email-designer'),
1833
  'control_type' => 'rangevalue',
1834
  'section' => 'footer_style',
1835
+ 'default' => self::get_default_value('footer_left_right_padding'),
1836
  'live_method' => 'css',
1837
  'selectors' => array(
1838
  '#template_footer #template_footer_inside' => array('padding-left', 'padding-right'),
1849
  'control_type' => 'repeater',
1850
  'transport' => 'refresh',
1851
  'section' => 'footer_social',
1852
+ 'default' => self::get_default_value( 'social_options' ),
1853
  'customizer_repeater_image_control' => true,
1854
  'customizer_repeater_icon_control' => true,
1855
  'customizer_repeater_icon_color' => true,
1861
  'footer_social_title_color' => array(
1862
  'title' => __('Footer Social Title Color', 'kadence-woocommerce-email-designer'),
1863
  'section' => 'footer_social',
1864
+ 'default' => self::get_default_value('footer_social_title_color'),
1865
  'live_method' => 'css',
1866
  'selectors' => array(
1867
  '#template_footer a.ft-social-link' => array('color'),
1873
  'title' => __('Footer Social Title Font Size', 'kadence-woocommerce-email-designer'),
1874
  'control_type' => 'rangevalue',
1875
  'section' => 'footer_social',
1876
+ 'default' => self::get_default_value('footer_social_title_font_size'),
1877
  'live_method' => 'css',
1878
  'selectors' => array(
1879
  '#template_footer .ft-social-title' => array('font-size'),
1888
  'footer_social_title_font_family' => array(
1889
  'title' => __('Footer Social Title Font Family', 'kadence-woocommerce-email-designer'),
1890
  'section' => 'footer_social',
1891
+ 'default' => self::get_default_value('footer_social_title_font_family'),
1892
  'live_method' => 'css',
1893
  'type' => 'select',
1894
+ 'choices' => self::get_font_families(),
1895
  'selectors' => array(
1896
  '#template_footer a.ft-social-link' => array('font-family'),
1897
  ),
1901
  'title' => __('Footer Social Title Font Weight', 'kadence-woocommerce-email-designer'),
1902
  'control_type' => 'rangevalue',
1903
  'section' => 'footer_social',
1904
+ 'default' => self::get_default_value('footer_social_title_font_weight'),
1905
  'live_method' => 'css',
1906
  'selectors' => array(
1907
  '#template_footer .ft-social-title' => array('font-weight'),
1917
  'title' => __('Top Padding', 'kadence-woocommerce-email-designer'),
1918
  'control_type' => 'rangevalue',
1919
  'section' => 'footer_social',
1920
+ 'default' => self::get_default_value('footer_social_top_padding'),
1921
  'live_method' => 'css',
1922
  'selectors' => array(
1923
  '#template_footer #footersocial td' => array('padding-top'),
1933
  'title' => __('Bottom Padding', 'kadence-woocommerce-email-designer'),
1934
  'control_type' => 'rangevalue',
1935
  'section' => 'footer_social',
1936
+ 'default' => self::get_default_value('footer_social_bottom_padding'),
1937
  'live_method' => 'css',
1938
  'selectors' => array(
1939
  '#template_footer #footersocial td' => array('padding-bottom'),
1949
  'title' => __('Footer Social Bottom Border Width', 'kadence-woocommerce-email-designer'),
1950
  'control_type' => 'rangevalue',
1951
  'section' => 'footer_social',
1952
+ 'default' => self::get_default_value('footer_social_border_width'),
1953
  'live_method' => 'css',
1954
  'selectors' => array(
1955
  '#footersocial' => array('border-bottom-width'),
1965
  'title' => __('Footer Social Bottom Border Color', 'kadence-woocommerce-email-designer'),
1966
  'section' => 'footer_social',
1967
  'control_type' => 'color',
1968
+ 'default' => self::get_default_value('footer_social_border_color'),
1969
  'live_method' => 'css',
1970
  'selectors' => array(
1971
  '#footersocial' => array('border-bottom-color'),
1975
  'footer_social_border_style' => array(
1976
  'title' => __('Footer Social Bottom Border Style', 'kadence-woocommerce-email-designer'),
1977
  'section' => 'footer_social',
1978
+ 'default' => self::get_default_value('footer_social_border_style'),
1979
  'live_method' => 'css',
1980
  'type' => 'select',
1981
  'choices' => array(
1994
  'footer_text_align' => array(
1995
  'title' => __('Text Align', 'kadence-woocommerce-email-designer'),
1996
  'section' => 'footer_content',
1997
+ 'default' => self::get_default_value('footer_text_align'),
1998
  'live_method' => 'css',
1999
  'type' => 'select',
2000
+ 'choices' => self::get_text_aligns(),
2001
  'selectors' => array(
2002
  '#template_footer #credit' => array('text-align'),
2003
  ),
2008
  'title' => __('Font Size', 'kadence-woocommerce-email-designer'),
2009
  'control_type' => 'rangevalue',
2010
  'section' => 'footer_content',
2011
+ 'default' => self::get_default_value('footer_font_size'),
2012
  'live_method' => 'css',
2013
  'selectors' => array(
2014
  '#template_footer #credit' => array('font-size'),
2023
  'footer_font_family' => array(
2024
  'title' => __('Font Family', 'kadence-woocommerce-email-designer'),
2025
  'section' => 'footer_content',
2026
+ 'default' => self::get_default_value('footer_font_family'),
2027
  'live_method' => 'css',
2028
  'type' => 'select',
2029
+ 'choices' => self::get_font_families(),
2030
  'selectors' => array(
2031
  '#template_footer #credit' => array('font-family'),
2032
  ),
2037
  'title' => __('Font weight', 'kadence-woocommerce-email-designer'),
2038
  'control_type' => 'rangevalue',
2039
  'section' => 'footer_content',
2040
+ 'default' => self::get_default_value('footer_font_weight'),
2041
  'live_method' => 'css',
2042
  'selectors' => array(
2043
  '#template_footer #credit' => array('font-weight'),
2054
  'title' => __('Text Color', 'kadence-woocommerce-email-designer'),
2055
  'section' => 'footer_content',
2056
  'control_type' => 'color',
2057
+ 'default' => self::get_default_value('footer_color'),
2058
  'live_method' => 'css',
2059
  'selectors' => array(
2060
  '#template_footer #credit' => array('color'),
2065
  'title' => __('Top Padding', 'kadence-woocommerce-email-designer'),
2066
  'control_type' => 'rangevalue',
2067
  'section' => 'footer_content',
2068
+ 'default' => self::get_default_value('footer_credit_top_padding'),
2069
  'live_method' => 'css',
2070
  'selectors' => array(
2071
  '#template_footer #credit' => array('padding-top'),
2081
  'title' => __('Bottom Padding', 'kadence-woocommerce-email-designer'),
2082
  'control_type' => 'rangevalue',
2083
  'section' => 'footer_content',
2084
+ 'default' => self::get_default_value('footer_credit_bottom_padding'),
2085
  'live_method' => 'css',
2086
  'selectors' => array(
2087
  '#template_footer #credit' => array('padding-bottom'),
2113
  'title' => __('Preview Email Recipient', 'kadence-woocommerce-email-designer'),
2114
  'description' => __( 'Enter recipients (comma separated) for preview emails', 'kadence-woocommerce-email-designer' ),
2115
  'section' => 'send_email',
2116
+ 'default' => self::get_default_value('email_recipient'),
2117
  'control_type' => 'kwdsendemail',
2118
  ),
2119
  );
2355
  */
2356
  public static function get_default_value( $key ) {
2357
  // Get default values
2358
+ $default_values = self::get_default_values();
2359
 
2360
  // Check if such key exists and return default value
2361
  return isset($default_values[$key]) ? $default_values[$key] : '';
2437
  * @return array
2438
  */
2439
  public static function get_font_families() {
2440
+ return apply_filters( 'kadence_woomail_email_font_families', self::$font_family_mapping );
2441
  }
2442
  /**
2443
  * Get Email Types
2447
  */
2448
  public static function get_email_types() {
2449
  if ( is_null( self::$email_types ) ) {
2450
+ $types = self::$email_types_mapping;
2451
  if ( class_exists( 'WC_Subscriptions' ) ) {
2452
+ $types = array_merge($types, self::$subscription_email_types_mapping );
2453
  }
2454
  if ( class_exists( 'WooCommerce_Waitlist_Plugin' ) ) {
2455
+ $types = array_merge($types, self::$waitlist_email_types_mapping );
2456
  }
2457
 
2458
  self::$email_types = apply_filters( 'kadence_woomail_email_types', $types );
2462
  }
2463
 
2464
  /**
2465
+ * Get Email Types
2466
+ *
2467
+ * @access public
2468
+ * @return array
2469
+ */
2470
  public static function get_customized_email_types() {
2471
  if ( is_null( self::$email_types ) ) {
2472
+ $types = self::$email_types_mapping;
2473
  if ( class_exists( 'WC_Subscriptions' ) ) {
2474
+ $types = array_merge($types, self::$subscription_email_types_mapping );
2475
  }
2476
  if ( class_exists( 'WooCommerce_Waitlist_Plugin' ) ) {
2477
+ $types = array_merge($types, self::$waitlist_email_types_mapping );
2478
  }
2479
 
2480
  self::$email_types = apply_filters( 'kadence_woomail_customized_email_types', $types );
2484
  }
2485
 
2486
  /**
2487
+ * Get Email Templates
2488
+ *
2489
+ * @access public
2490
+ * @return array
2491
+ */
2492
  public static function get_email_templates() {
2493
+ return apply_filters( 'kadence_woomail_prebuilt_email_templates_settings', self::$prebuilt_templates_mapping );
2494
  }
2495
 
2496
 
kadence-woocommerce-email-designer.php CHANGED
@@ -3,13 +3,13 @@
3
  * Plugin Name: Kadence WooCommerce Email Designer
4
  * Plugin URI: http://kadencethemes.com/products/woocommerce-email-designer/
5
  * Description: Customize the default woocommerce email templates design and text through the native WordPress customizer. Preview emails and send test emails.
6
- * Version: 1.1.1
7
  * Author: Kadence Themes
8
  * Author URI: http://kadencethemes.com/
9
  * License: GPLv2 or later
10
  * Text Domain: kadence-woocommerce-email-designer
11
  * WC requires at least: 3.4.0
12
- * WC tested up to: 3.5.1
13
  *
14
  * @package Kadence Woocommerce Email Designer
15
  */
@@ -41,77 +41,94 @@ class Kadence_Woomail_Designer {
41
  * Instance Control
42
  */
43
  public static function get_instance() {
44
- if ( is_null( self::$instance ) ) {
45
  self::$instance = new self();
46
  }
47
  return self::$instance;
48
  }
49
  public function __construct() {
50
- add_action('plugins_loaded', array( $this, 'on_plugins_loaded' ) );
51
  }
52
  public function on_plugins_loaded() {
53
 
54
- define( 'KT_WOOMAIL_PATH' , realpath( plugin_dir_path(__FILE__) ) . DIRECTORY_SEPARATOR );
55
- define( 'KT_WOOMAIL_URL' , plugin_dir_url(__FILE__) );
56
- define( 'KT_WOOMAIL_VERSION' , '1.1.1' );
57
 
58
- if( ! kadence_woomail_is_woo_active() ) {
59
  add_action( 'admin_notices', array( $this, 'admin_notice_need_woocommerce' ) );
60
  return;
61
  }
62
- require_once( KT_WOOMAIL_PATH . 'includes/class-kadence-woomail-settings.php'); //Gets all settings
63
- require_once( KT_WOOMAIL_PATH . 'includes/class-kadence-woomail-customizer.php'); // Gets custom customzier set up
64
- require_once( KT_WOOMAIL_PATH . 'includes/class-kadence-woomail-import-export.php'); // Adds Customizer control
65
- require_once( KT_WOOMAIL_PATH . 'includes/class-customizer-range-value-control.php'); // Adds Customizer control
66
- require_once( KT_WOOMAIL_PATH . 'includes/class-customizer-kwdtemplateload-control.php'); // Adds Customizer control
67
- require_once( KT_WOOMAIL_PATH . 'includes/class-customizer-kwdsendemail-control.php'); // Adds Customizer control
68
- require_once( KT_WOOMAIL_PATH . 'includes/class-customizer-repeater-control.php'); // Adds Customizer control
69
- require_once( KT_WOOMAIL_PATH . 'includes/class-customizer-kwdinfoblock-control.php'); // Adds Customizer control
70
- require_once( KT_WOOMAIL_PATH . 'includes/class-customizer-kwdimportexport-control.php'); // Adds Customizer control
71
- require_once( KT_WOOMAIL_PATH . 'includes/class-customizer-toggle-control.php'); // Adds customzier control
72
- require_once( KT_WOOMAIL_PATH . 'includes/class-kadence-woomail-preview.php'); // Builds the email preview for customzier
73
- require_once( KT_WOOMAIL_PATH . 'includes/class-kadence-woomail-woo.php'); // Add settings to woocommerce email settings page.
74
-
75
-
76
- add_action( 'init', array( $this, 'on_init' ) );
77
- // Add admin menu
78
- add_action( 'admin_menu', array( $this, 'admin_menu') );
79
- // Get translation set up
80
  load_plugin_textdomain( 'kadence-woocommerce-email-designer', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
81
- // Add link for plugin page
82
- add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array( $this, 'plugins_page_links' ) );
83
  }
 
 
 
 
84
  public function on_init() {
85
- // Remove the woocommerce call for email header
86
- remove_action( 'woocommerce_email_header', array( WC()->mailer(), 'email_header' ) );
 
 
87
 
88
- // Add our custom call for email header
89
- add_action( 'woocommerce_email_header', array( $this, 'add_email_header' ), 20, 2 );
90
 
91
  // Use our templates instead of woocommerce.
92
  add_filter( 'woocommerce_locate_template', array( $this, 'filter_locate_template' ), 10, 3 );
93
 
94
  // Add extra placeholder support for subject and title fields.
95
- add_filter( 'woocommerce_email_format_string', array( $this, 'add_extra_placeholders' ), 20, 2);
96
 
97
- // Hook in main text areas for customized emails
98
- add_action( 'kadence_woomail_designer_email_details', array( $this, 'email_main_text_area' ), 10, 4);
99
 
100
- // Hook in main text areas for customized emails
101
- add_action( 'kadence_woomail_designer_email_text', array( $this, 'email_main_text_area_no_order' ), 10, 1);
102
 
103
- // Hook in footer container
104
  add_action( 'kadence_woomail_designer_email_footer', array( $this, 'email_footer_content' ), 10 );
105
 
106
  // hook in email photo option.
107
  add_filter( 'woocommerce_email_order_items_args', array( $this, 'add_wc_order_email_args_images' ), 10 );
108
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  }
110
 
111
  /**
112
  * Add a notice about woocommerce being needed.
113
  *
114
- * @param $args the order detials args.
115
  */
116
  public function add_wc_order_email_args_images( $args ) {
117
  $product_photo = Kadence_Woomail_Customizer::opt( 'order_items_image' );
@@ -121,13 +138,17 @@ class Kadence_Woomail_Designer {
121
  }
122
  return $args;
123
  }
124
- // Add a notice about woocommerce being needed.
 
 
125
  public function admin_notice_need_woocommerce() {
126
  echo '<div class="notice notice-error is-dismissible">';
127
- echo '<p>'.__( 'Kadence Woocommerce Email Designer requires WooCommerce to be active to work', 'kadence-woocommerce-email-designer' ).'</p>';
128
  echo '</div>';
129
  }
130
- // set up the footer content
 
 
131
  public function email_footer_content() {
132
  $social_links = Kadence_Woomail_Customizer::opt( 'footer_social_repeater' );
133
  $social_links = json_decode( $social_links );
@@ -139,28 +160,29 @@ class Kadence_Woomail_Designer {
139
  <tr>
140
  <td valign="top" id="template_footer_inside">
141
  <table border="0" cellpadding="10" cellspacing="0" width="100%">
142
- <?php if( !empty( $social_links ) && is_array( $social_links ) ) { ?>
143
  <tr>
144
  <td valign="top">
145
  <table id="footersocial" border="0" cellpadding="10" cellspacing="0" width="100%">
146
  <tr>
147
- <?php $items = count($social_links);
148
- foreach( $social_links as $social_link ) {
149
- echo '<td valign="middle" style="text-align:center; width:'.round( 100/$items, 2 ).'%">';
150
- echo '<a href="'.esc_url( $social_link->link ).'" class="ft-social-link" style="display:block; text-decoration: none;">';
151
- if ( 'customizer_repeater_image' == $social_link->choice ) {
152
- echo '<img src="'.esc_attr( $social_link->image_url ).'" width="24" style="vertical-align: bottom;">';
153
- } else if ( 'customizer_repeater_icon' == $social_link->choice ) {
154
- $img_string = str_replace('kt-woomail-', '', $social_link->icon_value );
155
- if ( isset( $social_link->icon_color ) && ! empty( $social_link->icon_color ) ) {
156
- $color = $social_link->icon_color;
157
- } else {
158
- $color = 'black';
159
- }
160
- echo '<img src="' . esc_attr( KT_WOOMAIL_URL . 'assets/images/' . $color . '/' . $img_string ) . '.png" width="24" style="vertical-align: bottom;">';
161
- }
162
- echo '<span class="ft-social-title">' . esc_html( $social_link->title ) . '</span>';
163
- echo '</a>';
 
164
  echo '</td>';
165
  }
166
  ?>
@@ -190,21 +212,22 @@ class Kadence_Woomail_Designer {
190
  <?php
191
  }
192
  /**
193
- * Check if WooCommerce settings need to be overwritten and custom styles applied
194
- * This is true when plugin is active and at least one custom option is stored in the database
195
- *
196
- * @access public
197
- * @return bool
198
- */
199
  public static function overwrite_options() {
200
 
201
- // Check if any settings were saved
202
- if ( self::$overwrite_options === null ) {
203
  $option = get_option( 'kt_woomail', array() );
 
204
  self::$overwrite_options = ! empty( $option );
205
  }
206
 
207
- // Return result
208
  return self::$overwrite_options;
209
  }
210
 
@@ -219,14 +242,14 @@ class Kadence_Woomail_Designer {
219
  // Get Email ID
220
  $key = $email->id;
221
  if ( 'customer_refunded_order' == $key ) {
222
- if( $email->partial_refund ) {
223
  $body_text = Kadence_Woomail_Customizer::opt( $key . '_body_partial' );
224
  } else {
225
  $body_text = Kadence_Woomail_Customizer::opt( $key . '_body_full' );
226
  }
227
- } else if ( 'customer_partially_refunded_order' == $key ) {
228
  $body_text = Kadence_Woomail_Customizer::opt( 'customer_refunded_order_body_partial' );
229
- } else if ( 'customer_invoice' == $key ) {
230
  if( $order->has_status( 'pending' ) ) {
231
  $body_text = Kadence_Woomail_Customizer::opt( $key.'_body' );
232
  $pay_link = '<a href="' . esc_url( $order->get_checkout_payment_url() ) . '">' . esc_html__( 'Pay for this order', 'kadence-woocommerce-email-designer' ) . '</a>';
@@ -234,7 +257,7 @@ class Kadence_Woomail_Designer {
234
  } else {
235
  $body_text = Kadence_Woomail_Customizer::opt( $key.'_body_paid' );
236
  }
237
- } else if ( 'customer_renewal_invoice' == $key ) {
238
  if( $order->has_status( 'pending' ) ) {
239
  $body_text = Kadence_Woomail_Customizer::opt( $key.'_body' );
240
  $pay_link = '<a href="' . esc_url( $order->get_checkout_payment_url() ) . '">' . esc_html__( 'Pay Now &raquo;', 'kadence-woocommerce-email-designer' ) . '</a>';
@@ -273,25 +296,24 @@ class Kadence_Woomail_Designer {
273
  * @return void
274
  */
275
  public static function filter_subtitle( $subtitle, $email ) {
276
-
277
- // Check for placeholders
278
  $subtitle = str_replace( '{site_title}', get_bloginfo( 'name', 'display' ), $subtitle );
279
  if ( is_a( $email->object, 'WP_User' ) ) {
280
  $first_name = get_user_meta( $email->object->ID, 'billing_first_name', true );
281
- if( empty( $first_name ) ) {
282
- // Fall back to user display name
283
  $first_name = $email->object->display_name;
284
  }
285
 
286
  $last_name = get_user_meta( $email->object->ID, 'billing_last_name', true );
287
- if( empty( $last_name ) ) {
288
- // Fall back to user display name
289
  $last_name = $email->object->display_name;
290
  }
291
 
292
  $full_name = get_user_meta( $email->object->ID, 'formatted_billing_full_name', true );
293
- if( empty( $full_name ) ) {
294
- // Fall back to user display name
295
  $full_name = $email->object->display_name;
296
  }
297
  $subtitle = str_replace( '{customer_first_name}', $first_name, $subtitle );
@@ -309,17 +331,16 @@ class Kadence_Woomail_Designer {
309
  $subtitle = str_replace( '{product_title}', $email->object->get_title(), $subtitle );
310
  }
311
 
312
-
313
  return $subtitle;
314
 
315
  }
316
 
317
  /**
318
- * Hook in main text areas for customized emails
319
- *
320
- * @access public
321
- * @return void
322
- */
323
  public function email_main_text_area_no_order( $email ) {
324
 
325
  // Get Email ID
@@ -357,7 +378,7 @@ class Kadence_Woomail_Designer {
357
 
358
  $body_text = apply_filters( 'kadence_woomail_no_order_body_text', $body_text, $email );
359
 
360
- // auto wrap text
361
  $body_text = wpautop( $body_text );
362
 
363
  echo wp_kses_post( $body_text );
@@ -382,60 +403,61 @@ class Kadence_Woomail_Designer {
382
  }
383
 
384
  /**
385
- * Add submenu under woocommerce for email customizer
386
- *
387
- * @access public
388
- * @return void
389
- */
390
  public function admin_menu() {
391
  add_submenu_page(
392
  'woocommerce',
393
  __( 'Email Customizer', 'kadence-woocommerce-email-designer' ),
394
  __( 'Email Customizer', 'kadence-woocommerce-email-designer' ),
395
  'manage_woocommerce',
396
- 'customize.php?kt-woomail-customize=1&url='.urlencode( add_query_arg( array( 'kt-woomail-preview' => '1' ), home_url('/') ) )
397
  );
398
  }
399
 
400
  /**
401
- * Add submenu under woocommerce for email customizer
402
- *
403
- * @access public
404
- * @return array
405
- */
 
406
  public function plugins_page_links( $links ) {
407
- $settings_link = '<a href="' . Kadence_Woomail_Customizer::get_customizer_url() .'">'.__('Open Email Designer', 'kadence-woocommerce-email-designer').'</a>';
408
- array_unshift($links, $settings_link);
409
 
410
  return $links;
411
  }
412
 
413
  /**
414
- * Checks to see if we are opening our custom customizer preview
415
- *
416
- * @access public
417
- * @return bool
418
- */
419
- public static function is_own_preview_request(){
420
- return isset( $_REQUEST['kt-woomail-preview'] ) && $_REQUEST[ 'kt-woomail-preview' ] === '1';
421
  }
422
 
423
  /**
424
- * Checks to see if we are opening our custom customizer controls
425
- *
426
- * @access public
427
- * @return bool
428
- */
429
  public static function is_own_customizer_request() {
430
  return isset( $_REQUEST['kt-woomail-customize'] ) && $_REQUEST['kt-woomail-customize'] === '1';
431
  }
432
 
433
  /**
434
- * Gets the capability setting needed to edit in the email customizer
435
- *
436
- * @access public
437
- * @return string
438
- */
439
  public static function get_admin_capability() {
440
  // Get capability
441
  if ( is_null( self::$admin_capability ) ) {
@@ -485,7 +507,7 @@ class Kadence_Woomail_Designer {
485
  global $woocommerce;
486
  $template_path = $woocommerce->template_url;
487
  }
488
-
489
  // Get our template path
490
  $plugin_path = KT_WOOMAIL_PATH . 'templates/woo/';
491
 
@@ -497,7 +519,6 @@ class Kadence_Woomail_Designer {
497
  $template = $plugin_path . $template_name;
498
  }
499
 
500
-
501
  // else if we still don't have a template use default
502
  if ( ! $template ) {
503
  $template = $_template;
@@ -519,10 +540,11 @@ class Kadence_Woomail_Plugin_Check {
519
 
520
  public static function init() {
521
 
522
- self::$active_plugins = (array) get_option( 'active_plugins', array() );
523
 
524
- if ( is_multisite() )
525
- self::$active_plugins = array_merge( self::$active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
 
526
  }
527
 
528
  public static function active_check_woo() {
3
  * Plugin Name: Kadence WooCommerce Email Designer
4
  * Plugin URI: http://kadencethemes.com/products/woocommerce-email-designer/
5
  * Description: Customize the default woocommerce email templates design and text through the native WordPress customizer. Preview emails and send test emails.
6
+ * Version: 1.1.3
7
  * Author: Kadence Themes
8
  * Author URI: http://kadencethemes.com/
9
  * License: GPLv2 or later
10
  * Text Domain: kadence-woocommerce-email-designer
11
  * WC requires at least: 3.4.0
12
+ * WC tested up to: 3.5.2
13
  *
14
  * @package Kadence Woocommerce Email Designer
15
  */
41
  * Instance Control
42
  */
43
  public static function get_instance() {
44
+ if ( is_null( self::$instance ) ) {
45
  self::$instance = new self();
46
  }
47
  return self::$instance;
48
  }
49
  public function __construct() {
50
+ add_action( 'plugins_loaded', array( $this, 'on_plugins_loaded' ) );
51
  }
52
  public function on_plugins_loaded() {
53
 
54
+ define( 'KT_WOOMAIL_PATH', realpath( plugin_dir_path( __FILE__ ) ) . DIRECTORY_SEPARATOR );
55
+ define( 'KT_WOOMAIL_URL', plugin_dir_url( __FILE__ ) );
56
+ define( 'KT_WOOMAIL_VERSION', '1.1.3' );
57
 
58
+ if ( ! kadence_woomail_is_woo_active() ) {
59
  add_action( 'admin_notices', array( $this, 'admin_notice_need_woocommerce' ) );
60
  return;
61
  }
62
+ require_once KT_WOOMAIL_PATH . 'includes/class-kadence-woomail-settings.php'; //Gets all settings
63
+ require_once KT_WOOMAIL_PATH . 'includes/class-kadence-woomail-customizer.php'; // Gets custom customzier set up
64
+ require_once KT_WOOMAIL_PATH . 'includes/class-kadence-woomail-import-export.php'; // Adds Customizer control
65
+ require_once KT_WOOMAIL_PATH . 'includes/class-customizer-range-value-control.php'; // Adds Customizer control
66
+ require_once KT_WOOMAIL_PATH . 'includes/class-customizer-kwdtemplateload-control.php'; // Adds Customizer control
67
+ require_once KT_WOOMAIL_PATH . 'includes/class-customizer-kwdsendemail-control.php'; // Adds Customizer control
68
+ require_once KT_WOOMAIL_PATH . 'includes/class-customizer-repeater-control.php'; // Adds Customizer control
69
+ require_once KT_WOOMAIL_PATH . 'includes/class-customizer-kwdinfoblock-control.php'; // Adds Customizer control
70
+ require_once KT_WOOMAIL_PATH . 'includes/class-customizer-kwdimportexport-control.php'; // Adds Customizer control
71
+ require_once KT_WOOMAIL_PATH . 'includes/class-customizer-toggle-control.php'; // Adds customzier control
72
+ require_once KT_WOOMAIL_PATH . 'includes/class-kadence-woomail-preview.php'; // Builds the email preview for customzier
73
+ require_once KT_WOOMAIL_PATH . 'includes/class-kadence-woomail-woo.php'; // Add settings to woocommerce email settings page.
74
+
75
+ add_action( 'init', array( $this, 'on_init' ), 80 );
76
+ // Add admin menu.
77
+ add_action( 'admin_menu', array( $this, 'admin_menu' ) );
78
+ // Get translation set up.
 
79
  load_plugin_textdomain( 'kadence-woocommerce-email-designer', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
80
+ // Add link for plugin page.
81
+ add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugins_page_links' ) );
82
  }
83
+
84
+ /**
85
+ * Trigger Load on init.
86
+ */
87
  public function on_init() {
88
+ // Remove the woocommerce call for email header.
89
+ if ( function_exists( 'WC' ) ) {
90
+ remove_action( 'woocommerce_email_header', array( WC()->mailer(), 'email_header' ) );
91
+ }
92
 
93
+ // Add our custom call for email header.
94
+ add_action( 'woocommerce_email_header', array( $this, 'add_email_header' ), 20, 2 );
95
 
96
  // Use our templates instead of woocommerce.
97
  add_filter( 'woocommerce_locate_template', array( $this, 'filter_locate_template' ), 10, 3 );
98
 
99
  // Add extra placeholder support for subject and title fields.
100
+ add_filter( 'woocommerce_email_format_string', array( $this, 'add_extra_placeholders' ), 20, 2 );
101
 
102
+ // Hook in main text areas for customized emails.
103
+ add_action( 'kadence_woomail_designer_email_details', array( $this, 'email_main_text_area' ), 10, 4 );
104
 
105
+ // Hook in main text areas for customized emails.
106
+ add_action( 'kadence_woomail_designer_email_text', array( $this, 'email_main_text_area_no_order' ), 10, 1 );
107
 
108
+ // Hook in footer container.
109
  add_action( 'kadence_woomail_designer_email_footer', array( $this, 'email_footer_content' ), 10 );
110
 
111
  // hook in email photo option.
112
  add_filter( 'woocommerce_email_order_items_args', array( $this, 'add_wc_order_email_args_images' ), 10 );
113
 
114
+ // Hook for replacing {year} in email-footer.
115
+ add_filter( 'woocommerce_email_footer_text', array( $this, 'email_footer_replace_year' ) );
116
+
117
+ }
118
+ /**
119
+ * Filter callback to replace {year} in email footer
120
+ *
121
+ * @param string $string Email footer text.
122
+ * @return string Email footer text with any replacements done.
123
+ */
124
+ public function email_footer_replace_year( $string ) {
125
+ return str_replace( '{year}', date( 'Y' ), $string );
126
  }
127
 
128
  /**
129
  * Add a notice about woocommerce being needed.
130
  *
131
+ * @param array $args the order detials args.
132
  */
133
  public function add_wc_order_email_args_images( $args ) {
134
  $product_photo = Kadence_Woomail_Customizer::opt( 'order_items_image' );
138
  }
139
  return $args;
140
  }
141
+ /**
142
+ * Add a notice about woocommerce being needed.
143
+ */
144
  public function admin_notice_need_woocommerce() {
145
  echo '<div class="notice notice-error is-dismissible">';
146
+ echo '<p>' . __( 'Kadence Woocommerce Email Designer requires WooCommerce to be active to work', 'kadence-woocommerce-email-designer' ) . '</p>';
147
  echo '</div>';
148
  }
149
+ /**
150
+ * Set up the footer content
151
+ */
152
  public function email_footer_content() {
153
  $social_links = Kadence_Woomail_Customizer::opt( 'footer_social_repeater' );
154
  $social_links = json_decode( $social_links );
160
  <tr>
161
  <td valign="top" id="template_footer_inside">
162
  <table border="0" cellpadding="10" cellspacing="0" width="100%">
163
+ <?php if ( ! empty( $social_links ) && is_array( $social_links ) ) { ?>
164
  <tr>
165
  <td valign="top">
166
  <table id="footersocial" border="0" cellpadding="10" cellspacing="0" width="100%">
167
  <tr>
168
+ <?php
169
+ $items = count( $social_links );
170
+ foreach ( $social_links as $social_link ) {
171
+ echo '<td valign="middle" style="text-align:center; width:' . round( 100 / $items, 2 ) . '%">';
172
+ echo '<a href="' . esc_url( $social_link->link ) . '" class="ft-social-link" style="display:block; text-decoration: none;">';
173
+ if ( 'customizer_repeater_image' == $social_link->choice ) {
174
+ echo '<img src="' . esc_attr( $social_link->image_url ) . '" width="24" style="vertical-align: bottom;">';
175
+ } else if ( 'customizer_repeater_icon' == $social_link->choice ) {
176
+ $img_string = str_replace( 'kt-woomail-', '', $social_link->icon_value );
177
+ if ( isset( $social_link->icon_color ) && ! empty( $social_link->icon_color ) ) {
178
+ $color = $social_link->icon_color;
179
+ } else {
180
+ $color = 'black';
181
+ }
182
+ echo '<img src="' . esc_attr( KT_WOOMAIL_URL . 'assets/images/' . $color . '/' . $img_string ) . '.png" width="24" style="vertical-align: bottom;">';
183
+ }
184
+ echo '<span class="ft-social-title">' . esc_html( $social_link->title ) . '</span>';
185
+ echo '</a>';
186
  echo '</td>';
187
  }
188
  ?>
212
  <?php
213
  }
214
  /**
215
+ * Check if WooCommerce settings need to be overwritten and custom styles applied
216
+ * This is true when plugin is active and at least one custom option is stored in the database
217
+ *
218
+ * @access public
219
+ * @return bool
220
+ */
221
  public static function overwrite_options() {
222
 
223
+ // Check if any settings were saved.
224
+ if ( null === self::$overwrite_options ) {
225
  $option = get_option( 'kt_woomail', array() );
226
+
227
  self::$overwrite_options = ! empty( $option );
228
  }
229
 
230
+ // Return result.
231
  return self::$overwrite_options;
232
  }
233
 
242
  // Get Email ID
243
  $key = $email->id;
244
  if ( 'customer_refunded_order' == $key ) {
245
+ if ( $email->partial_refund ) {
246
  $body_text = Kadence_Woomail_Customizer::opt( $key . '_body_partial' );
247
  } else {
248
  $body_text = Kadence_Woomail_Customizer::opt( $key . '_body_full' );
249
  }
250
+ } elseif ( 'customer_partially_refunded_order' == $key ) {
251
  $body_text = Kadence_Woomail_Customizer::opt( 'customer_refunded_order_body_partial' );
252
+ } elseif ( 'customer_invoice' == $key ) {
253
  if( $order->has_status( 'pending' ) ) {
254
  $body_text = Kadence_Woomail_Customizer::opt( $key.'_body' );
255
  $pay_link = '<a href="' . esc_url( $order->get_checkout_payment_url() ) . '">' . esc_html__( 'Pay for this order', 'kadence-woocommerce-email-designer' ) . '</a>';
257
  } else {
258
  $body_text = Kadence_Woomail_Customizer::opt( $key.'_body_paid' );
259
  }
260
+ } elseif ( 'customer_renewal_invoice' == $key ) {
261
  if( $order->has_status( 'pending' ) ) {
262
  $body_text = Kadence_Woomail_Customizer::opt( $key.'_body' );
263
  $pay_link = '<a href="' . esc_url( $order->get_checkout_payment_url() ) . '">' . esc_html__( 'Pay Now &raquo;', 'kadence-woocommerce-email-designer' ) . '</a>';
296
  * @return void
297
  */
298
  public static function filter_subtitle( $subtitle, $email ) {
299
+ // Check for placeholders.
 
300
  $subtitle = str_replace( '{site_title}', get_bloginfo( 'name', 'display' ), $subtitle );
301
  if ( is_a( $email->object, 'WP_User' ) ) {
302
  $first_name = get_user_meta( $email->object->ID, 'billing_first_name', true );
303
+ if ( empty( $first_name ) ) {
304
+ // Fall back to user display name.
305
  $first_name = $email->object->display_name;
306
  }
307
 
308
  $last_name = get_user_meta( $email->object->ID, 'billing_last_name', true );
309
+ if ( empty( $last_name ) ) {
310
+ // Fall back to user display name.
311
  $last_name = $email->object->display_name;
312
  }
313
 
314
  $full_name = get_user_meta( $email->object->ID, 'formatted_billing_full_name', true );
315
+ if ( empty( $full_name ) ) {
316
+ // Fall back to user display name.
317
  $full_name = $email->object->display_name;
318
  }
319
  $subtitle = str_replace( '{customer_first_name}', $first_name, $subtitle );
331
  $subtitle = str_replace( '{product_title}', $email->object->get_title(), $subtitle );
332
  }
333
 
 
334
  return $subtitle;
335
 
336
  }
337
 
338
  /**
339
+ * Hook in main text areas for customized emails.
340
+ *
341
+ * @access public
342
+ * @return void
343
+ */
344
  public function email_main_text_area_no_order( $email ) {
345
 
346
  // Get Email ID
378
 
379
  $body_text = apply_filters( 'kadence_woomail_no_order_body_text', $body_text, $email );
380
 
381
+ // auto wrap text.
382
  $body_text = wpautop( $body_text );
383
 
384
  echo wp_kses_post( $body_text );
403
  }
404
 
405
  /**
406
+ * Add submenu under woocommerce for email customizer
407
+ *
408
+ * @access public
409
+ * @return void
410
+ */
411
  public function admin_menu() {
412
  add_submenu_page(
413
  'woocommerce',
414
  __( 'Email Customizer', 'kadence-woocommerce-email-designer' ),
415
  __( 'Email Customizer', 'kadence-woocommerce-email-designer' ),
416
  'manage_woocommerce',
417
+ 'customize.php?kt-woomail-customize=1&url=' . urlencode( add_query_arg( array( 'kt-woomail-preview' => '1' ), home_url( '/' ) ) )
418
  );
419
  }
420
 
421
  /**
422
+ * Add submenu under woocommerce for email customizer
423
+ *
424
+ * @param array $links plugin links.
425
+ * @access public
426
+ * @return array
427
+ */
428
  public function plugins_page_links( $links ) {
429
+ $settings_link = '<a href="' . Kadence_Woomail_Customizer::get_customizer_url() . '">' . __( 'Open Email Designer', 'kadence-woocommerce-email-designer' ) . '</a>';
430
+ array_unshift( $links, $settings_link );
431
 
432
  return $links;
433
  }
434
 
435
  /**
436
+ * Checks to see if we are opening our custom customizer preview
437
+ *
438
+ * @access public
439
+ * @return bool
440
+ */
441
+ public static function is_own_preview_request() {
442
+ return isset( $_REQUEST['kt-woomail-preview'] ) && '1' === $_REQUEST['kt-woomail-preview'];
443
  }
444
 
445
  /**
446
+ * Checks to see if we are opening our custom customizer controls
447
+ *
448
+ * @access public
449
+ * @return bool
450
+ */
451
  public static function is_own_customizer_request() {
452
  return isset( $_REQUEST['kt-woomail-customize'] ) && $_REQUEST['kt-woomail-customize'] === '1';
453
  }
454
 
455
  /**
456
+ * Gets the capability setting needed to edit in the email customizer
457
+ *
458
+ * @access public
459
+ * @return string
460
+ */
461
  public static function get_admin_capability() {
462
  // Get capability
463
  if ( is_null( self::$admin_capability ) ) {
507
  global $woocommerce;
508
  $template_path = $woocommerce->template_url;
509
  }
510
+
511
  // Get our template path
512
  $plugin_path = KT_WOOMAIL_PATH . 'templates/woo/';
513
 
519
  $template = $plugin_path . $template_name;
520
  }
521
 
 
522
  // else if we still don't have a template use default
523
  if ( ! $template ) {
524
  $template = $_template;
540
 
541
  public static function init() {
542
 
543
+ self::$active_plugins = (array) get_option( 'active_plugins', array() );
544
 
545
+ if ( is_multisite() ) {
546
+ self::$active_plugins = array_merge( self::$active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
547
+ }
548
  }
549
 
550
  public static function active_check_woo() {
readme.txt CHANGED
@@ -4,8 +4,8 @@ Tags: woocommerce, mail, email, email template, email templates, email design, p
4
  Donate link: https://www.kadencethemes.com/about-us/
5
  Requires PHP: 5.2.4
6
  Requires at least: 4.4
7
- Tested up to: 4.9.8
8
- Stable tag: 1.1.1
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -55,6 +55,15 @@ Install the plugin into the `/wp-content/plugins/` folder, and activate it.
55
 
56
  == Changelog ==
57
 
 
 
 
 
 
 
 
 
 
58
  = 1.1.1 =
59
  * Fix: Divi theme issue in email customizer.
60
  * Fix: Issue with Themeisle theme.
4
  Donate link: https://www.kadencethemes.com/about-us/
5
  Requires PHP: 5.2.4
6
  Requires at least: 4.4
7
+ Tested up to: 5.0.2
8
+ Stable tag: 1.1.3
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
55
 
56
  == Changelog ==
57
 
58
+ = 1.1.3 =
59
+ * Fix: Issue with WP Multilang.
60
+ * Add: {year} for use in the footer.
61
+ * Fix: Force image to refreash email loaded so settings work.
62
+
63
+ = 1.1.2 =
64
+ * Fix: Issue with WooCommerce Order Status Manager.
65
+ * Update: Better fallback if Order is Deleted.
66
+
67
  = 1.1.1 =
68
  * Fix: Divi theme issue in email customizer.
69
  * Fix: Issue with Themeisle theme.