Kadence WooCommerce Email Designer - Version 1.5.3

Version Description

  • Update: Add some filters for body content and subtitle WPML support.
Download this release

Release Info

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

Code changes from version 1.5.2 to 1.5.3

kadence-woocommerce-email-designer.php CHANGED
@@ -3,13 +3,13 @@
3
  * Plugin Name: Kadence WooCommerce Email Designer
4
  * Plugin URI: http://kadencewp.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.5.2
7
  * Author: Kadence WP
8
  * Author URI: http://kadencewp.com/
9
  * License: GPLv2 or later
10
  * Text Domain: kadence-woocommerce-email-designer
11
  * WC requires at least: 5.6.0
12
- * WC tested up to: 6.5
13
  *
14
  * @package Kadence Woocommerce Email Designer
15
  */
@@ -59,7 +59,7 @@ class Kadence_Woomail_Designer {
59
 
60
  define( 'KT_WOOMAIL_PATH', realpath( plugin_dir_path( __FILE__ ) ) . DIRECTORY_SEPARATOR );
61
  define( 'KT_WOOMAIL_URL', plugin_dir_url( __FILE__ ) );
62
- define( 'KT_WOOMAIL_VERSION', '1.5.2' );
63
 
64
  if ( ! kadence_woomail_is_woo_active() ) {
65
  add_action( 'admin_notices', array( $this, 'admin_notice_need_woocommerce' ) );
@@ -315,17 +315,21 @@ class Kadence_Woomail_Designer {
315
 
316
  // Get Email ID.
317
  $key = $email->id;
 
318
  if ( 'customer_refunded_order' == $key ) {
319
  if ( $email->partial_refund ) {
 
320
  $body_text = Kadence_Woomail_Customizer::opt( $key . '_body_partial' );
321
  } else {
 
322
  $body_text = Kadence_Woomail_Customizer::opt( $key . '_body_full' );
323
  }
324
  } elseif ( 'customer_partially_refunded_order' == $key ) {
325
- $body_text = Kadence_Woomail_Customizer::opt( 'customer_refunded_order_body_partial' );
 
326
  } elseif ( 'customer_invoice' == $key ) {
327
  if ( $order->has_status( 'pending' ) ) {
328
- $body_text = Kadence_Woomail_Customizer::opt( $key . '_body' );
329
  $btn_switch = Kadence_Woomail_Customizer::opt( $key . '_btn_switch' );
330
  if ( true == $btn_switch ) {
331
  $pay_link = '<p class="btn-container"><a class="btn" href="' . esc_url( $order->get_checkout_payment_url() ) . '">' . esc_html__( 'Pay for this order', 'kadence-woocommerce-email-designer' ) . '</a></p>';
@@ -334,11 +338,12 @@ class Kadence_Woomail_Designer {
334
  }
335
  $body_text = str_replace( '{invoice_pay_link}', $pay_link, $body_text );
336
  } else {
337
- $body_text = Kadence_Woomail_Customizer::opt( $key . '_body_paid' );
 
338
  }
339
  } elseif ( 'customer_renewal_invoice' == $key ) {
340
  if ( $order->has_status( 'pending' ) ) {
341
- $body_text = Kadence_Woomail_Customizer::opt( $key . '_body' );
342
  $btn_switch = Kadence_Woomail_Customizer::opt( $key . '_btn_switch' );
343
  if ( true == $btn_switch ) {
344
  $pay_link = '<p class="btn-container"><a class="btn" href="' . esc_url( $order->get_checkout_payment_url() ) . '">' . esc_html__( 'Pay Now &raquo;', 'kadence-woocommerce-email-designer' ) . '</a></p>';
@@ -347,7 +352,8 @@ class Kadence_Woomail_Designer {
347
  }
348
  $body_text = str_replace( '{invoice_pay_link}', $pay_link, $body_text );
349
  } else {
350
- $body_text = Kadence_Woomail_Customizer::opt( $key . '_body_failed' );
 
351
  $btn_switch = Kadence_Woomail_Customizer::opt( $key . '_btn_switch' );
352
  if ( true == $btn_switch ) {
353
  $pay_link = '<p class="btn-container"><a class="btn" href="' . esc_url( $order->get_checkout_payment_url() ) . '">' . esc_html__( 'Pay Now &raquo;', 'kadence-woocommerce-email-designer' ) . '</a></p>';
@@ -357,7 +363,7 @@ class Kadence_Woomail_Designer {
357
  $body_text = str_replace( '{invoice_pay_link}', $pay_link, $body_text );
358
  }
359
  } elseif ( 'customer_payment_retry' == $key ) {
360
- $body_text = Kadence_Woomail_Customizer::opt( $key . '_body' );
361
  $btn_switch = Kadence_Woomail_Customizer::opt( $key . '_btn_switch' );
362
  if ( true == $btn_switch ) {
363
  $pay_link = '<p class="btn-container"><a class="btn" href="' . esc_url( $order->get_checkout_payment_url() ) . '">' . esc_html__( 'Pay Now &raquo;', 'kadence-woocommerce-email-designer' ) . '</a></p>';
@@ -366,7 +372,7 @@ class Kadence_Woomail_Designer {
366
  }
367
  $body_text = str_replace( '{invoice_pay_link}', $pay_link, $body_text );
368
  } else {
369
- $body_text = Kadence_Woomail_Customizer::opt( $key . '_body' );
370
  }
371
  $body_text = str_replace( '{site_title}', get_bloginfo( 'name', 'display' ), $body_text );
372
  $body_text = str_replace( '{site_address}', wp_parse_url( home_url(), PHP_URL_HOST ), $body_text );
@@ -388,7 +394,6 @@ class Kadence_Woomail_Designer {
388
  }
389
 
390
  $body_text = apply_filters( 'kadence_woomail_order_body_text', $body_text, $order, $sent_to_admin, $plain_text, $email );
391
-
392
  // auto wrap text.
393
  $body_text = wpautop( $body_text );
394
 
@@ -427,6 +432,7 @@ class Kadence_Woomail_Designer {
427
  $subtitle = str_replace( '{site_title}', get_bloginfo( 'name', 'display' ), $subtitle );
428
  $subtitle = str_replace( '{site_address}', wp_parse_url( home_url(), PHP_URL_HOST ), $subtitle );
429
  $subtitle = str_replace( '{site_url}', wp_parse_url( home_url(), PHP_URL_HOST ), $subtitle );
 
430
  if ( is_a( $email->object, 'WP_User' ) ) {
431
  $first_name = get_user_meta( $email->object->ID, 'billing_first_name', true );
432
  if ( empty( $first_name ) ) {
@@ -463,13 +469,44 @@ class Kadence_Woomail_Designer {
463
  $subtitle = str_replace( '{customer_company}', $email->object->get_billing_company(), $subtitle );
464
  $subtitle = str_replace( '{customer_email}', $email->object->get_billing_email(), $subtitle );
465
  $subtitle = str_replace( '{customer_username}', self::get_username_from_id( $user_id ), $subtitle );
 
466
  } elseif ( is_a( $email->object, 'WC_Product' ) ) {
467
  $subtitle = str_replace( '{product_title}', $email->object->get_title(), $subtitle );
468
  }
469
-
 
 
 
 
 
 
 
 
 
 
 
 
 
470
  return $subtitle;
471
 
472
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
473
 
474
  /**
475
  * Hook in main text areas for customized emails.
@@ -482,8 +519,8 @@ class Kadence_Woomail_Designer {
482
 
483
  // Get Email ID.
484
  $key = $email->id;
485
-
486
- $body_text = Kadence_Woomail_Customizer::opt( $key . '_body' );
487
  // Check for placeholders.
488
  $body_text = str_replace( '{site_title}', get_bloginfo( 'name', 'display' ), $body_text );
489
  $body_text = str_replace( '{site_address}', wp_parse_url( home_url(), PHP_URL_HOST ), $body_text );
@@ -524,6 +561,14 @@ class Kadence_Woomail_Designer {
524
  }
525
 
526
  $body_text = apply_filters( 'kadence_woomail_no_order_body_text', $body_text, $email );
 
 
 
 
 
 
 
 
527
 
528
  // auto wrap text.
529
  $body_text = wpautop( $body_text );
3
  * Plugin Name: Kadence WooCommerce Email Designer
4
  * Plugin URI: http://kadencewp.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.5.3
7
  * Author: Kadence WP
8
  * Author URI: http://kadencewp.com/
9
  * License: GPLv2 or later
10
  * Text Domain: kadence-woocommerce-email-designer
11
  * WC requires at least: 5.6.0
12
+ * WC tested up to: 6.8
13
  *
14
  * @package Kadence Woocommerce Email Designer
15
  */
59
 
60
  define( 'KT_WOOMAIL_PATH', realpath( plugin_dir_path( __FILE__ ) ) . DIRECTORY_SEPARATOR );
61
  define( 'KT_WOOMAIL_URL', plugin_dir_url( __FILE__ ) );
62
+ define( 'KT_WOOMAIL_VERSION', '1.5.3' );
63
 
64
  if ( ! kadence_woomail_is_woo_active() ) {
65
  add_action( 'admin_notices', array( $this, 'admin_notice_need_woocommerce' ) );
315
 
316
  // Get Email ID.
317
  $key = $email->id;
318
+ $setting_key = $key . '_body';
319
  if ( 'customer_refunded_order' == $key ) {
320
  if ( $email->partial_refund ) {
321
+ $setting_key = $key . '_body_partial';
322
  $body_text = Kadence_Woomail_Customizer::opt( $key . '_body_partial' );
323
  } else {
324
+ $setting_key = $key . '_body_full';
325
  $body_text = Kadence_Woomail_Customizer::opt( $key . '_body_full' );
326
  }
327
  } elseif ( 'customer_partially_refunded_order' == $key ) {
328
+ $setting_key = 'customer_refunded_order_body_partial';
329
+ $body_text = Kadence_Woomail_Customizer::opt( $setting_key );
330
  } elseif ( 'customer_invoice' == $key ) {
331
  if ( $order->has_status( 'pending' ) ) {
332
+ $body_text = Kadence_Woomail_Customizer::opt( $setting_key );
333
  $btn_switch = Kadence_Woomail_Customizer::opt( $key . '_btn_switch' );
334
  if ( true == $btn_switch ) {
335
  $pay_link = '<p class="btn-container"><a class="btn" href="' . esc_url( $order->get_checkout_payment_url() ) . '">' . esc_html__( 'Pay for this order', 'kadence-woocommerce-email-designer' ) . '</a></p>';
338
  }
339
  $body_text = str_replace( '{invoice_pay_link}', $pay_link, $body_text );
340
  } else {
341
+ $setting_key = $key . '_body_paid';
342
+ $body_text = Kadence_Woomail_Customizer::opt( $setting_key );
343
  }
344
  } elseif ( 'customer_renewal_invoice' == $key ) {
345
  if ( $order->has_status( 'pending' ) ) {
346
+ $body_text = Kadence_Woomail_Customizer::opt( $setting_key );
347
  $btn_switch = Kadence_Woomail_Customizer::opt( $key . '_btn_switch' );
348
  if ( true == $btn_switch ) {
349
  $pay_link = '<p class="btn-container"><a class="btn" href="' . esc_url( $order->get_checkout_payment_url() ) . '">' . esc_html__( 'Pay Now &raquo;', 'kadence-woocommerce-email-designer' ) . '</a></p>';
352
  }
353
  $body_text = str_replace( '{invoice_pay_link}', $pay_link, $body_text );
354
  } else {
355
+ $setting_key = $key . '_body_failed';
356
+ $body_text = Kadence_Woomail_Customizer::opt( $setting_key );
357
  $btn_switch = Kadence_Woomail_Customizer::opt( $key . '_btn_switch' );
358
  if ( true == $btn_switch ) {
359
  $pay_link = '<p class="btn-container"><a class="btn" href="' . esc_url( $order->get_checkout_payment_url() ) . '">' . esc_html__( 'Pay Now &raquo;', 'kadence-woocommerce-email-designer' ) . '</a></p>';
363
  $body_text = str_replace( '{invoice_pay_link}', $pay_link, $body_text );
364
  }
365
  } elseif ( 'customer_payment_retry' == $key ) {
366
+ $body_text = Kadence_Woomail_Customizer::opt( $setting_key );
367
  $btn_switch = Kadence_Woomail_Customizer::opt( $key . '_btn_switch' );
368
  if ( true == $btn_switch ) {
369
  $pay_link = '<p class="btn-container"><a class="btn" href="' . esc_url( $order->get_checkout_payment_url() ) . '">' . esc_html__( 'Pay Now &raquo;', 'kadence-woocommerce-email-designer' ) . '</a></p>';
372
  }
373
  $body_text = str_replace( '{invoice_pay_link}', $pay_link, $body_text );
374
  } else {
375
+ $body_text = Kadence_Woomail_Customizer::opt( $setting_key );
376
  }
377
  $body_text = str_replace( '{site_title}', get_bloginfo( 'name', 'display' ), $body_text );
378
  $body_text = str_replace( '{site_address}', wp_parse_url( home_url(), PHP_URL_HOST ), $body_text );
394
  }
395
 
396
  $body_text = apply_filters( 'kadence_woomail_order_body_text', $body_text, $order, $sent_to_admin, $plain_text, $email );
 
397
  // auto wrap text.
398
  $body_text = wpautop( $body_text );
399
 
432
  $subtitle = str_replace( '{site_title}', get_bloginfo( 'name', 'display' ), $subtitle );
433
  $subtitle = str_replace( '{site_address}', wp_parse_url( home_url(), PHP_URL_HOST ), $subtitle );
434
  $subtitle = str_replace( '{site_url}', wp_parse_url( home_url(), PHP_URL_HOST ), $subtitle );
435
+ $order_language = '';
436
  if ( is_a( $email->object, 'WP_User' ) ) {
437
  $first_name = get_user_meta( $email->object->ID, 'billing_first_name', true );
438
  if ( empty( $first_name ) ) {
469
  $subtitle = str_replace( '{customer_company}', $email->object->get_billing_company(), $subtitle );
470
  $subtitle = str_replace( '{customer_email}', $email->object->get_billing_email(), $subtitle );
471
  $subtitle = str_replace( '{customer_username}', self::get_username_from_id( $user_id ), $subtitle );
472
+
473
  } elseif ( is_a( $email->object, 'WC_Product' ) ) {
474
  $subtitle = str_replace( '{product_title}', $email->object->get_title(), $subtitle );
475
  }
476
+ if ( class_exists( 'WCML_Orders' ) ) {
477
+ $order_id = ( method_exists( $email->object, 'get_id' ) ? $email->object->get_id() : '' );
478
+ if ( empty( $order_id ) ) {
479
+ $order_id = ( is_array( $email->object ) && isset( $email->object['ID'] ) ? $email->object['ID'] : '' );
480
+ }
481
+ $order_language = WCML_Orders::getLanguage( $order_id );
482
+ if ( $order_language ) {
483
+ if ( isset( $email ) && is_object( $email ) && isset( $email->id ) ) {
484
+ $setting_key = $email->id;
485
+ $name = '[kt_woomail]' . $setting_key;
486
+ $subtitle = apply_filters( 'wpml_translate_single_string', $subtitle, 'admin_texts_kt_woomail', $name, $order_language );
487
+ }
488
+ }
489
+ }
490
  return $subtitle;
491
 
492
  }
493
+ /**
494
+ * @param WC_Email $object
495
+ *
496
+ * @return bool|string|int
497
+ */
498
+ private function get_order_id_from_email_object( $object ) {
499
+
500
+ if ( method_exists( $object->object, 'get_id' ) ) {
501
+ return $object->object->get_id();
502
+ }
503
+
504
+ if ( is_array( $object->object ) && isset( $object->object['ID'] ) ) {
505
+ return $object->object['ID'];
506
+ }
507
+
508
+ return false;
509
+ }
510
 
511
  /**
512
  * Hook in main text areas for customized emails.
519
 
520
  // Get Email ID.
521
  $key = $email->id;
522
+ $setting_key = $key . '_body';
523
+ $body_text = Kadence_Woomail_Customizer::opt( $setting_key );
524
  // Check for placeholders.
525
  $body_text = str_replace( '{site_title}', get_bloginfo( 'name', 'display' ), $body_text );
526
  $body_text = str_replace( '{site_address}', wp_parse_url( home_url(), PHP_URL_HOST ), $body_text );
561
  }
562
 
563
  $body_text = apply_filters( 'kadence_woomail_no_order_body_text', $body_text, $email );
564
+ if ( class_exists( 'WCML_Orders' ) ) {
565
+ $order_language = WCML_Orders::getLanguage( $order->get_id() );
566
+ if ( $order_language ) {
567
+ $language_code = $order_language;
568
+ $name = '[kt_woomail]' . $setting_key;
569
+ $body_text = apply_filters( 'wpml_translate_single_string', $body_text, 'admin_texts_kt_woomail', $name, $order_language );
570
+ }
571
+ }
572
 
573
  // auto wrap text.
574
  $body_text = wpautop( $body_text );
readme.txt CHANGED
@@ -5,7 +5,7 @@ Donate link: https://www.kadencewp.com/about-us/
5
  Requires PHP: 5.2.4
6
  Requires at least: 5.3
7
  Tested up to: 6.0
8
- Stable tag: 1.5.2
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -81,6 +81,9 @@ After you create your translations make sure to clear your server cache from any
81
 
82
  == Changelog ==
83
 
 
 
 
84
  = 1.5.2 =
85
  * Update: Template version numbers to prevent confusion.
86
  * Update: Small tweek for outlook styles.
5
  Requires PHP: 5.2.4
6
  Requires at least: 5.3
7
  Tested up to: 6.0
8
+ Stable tag: 1.5.3
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
81
 
82
  == Changelog ==
83
 
84
+ = 1.5.3 =
85
+ * Update: Add some filters for body content and subtitle WPML support.
86
+
87
  = 1.5.2 =
88
  * Update: Template version numbers to prevent confusion.
89
  * Update: Small tweek for outlook styles.