PluginProbe
EmailKit – Email Customizer for WooCommerce & WP / 1.6.9
EmailKit – Email Customizer for WooCommerce & WP v1.6.9
1.6.9 1.6.8 1.6.7 trunk 1.0.0 1.2.0 1.4.0 1.4.5 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6
← All changes | includes/Admin/MetaBox.php +36 -19 1.5.21.6.9 View file →
@@ -17,31 +17,47 @@
17 17 public $template_types = [];
18 18
19 19 public function __construct()
20 20 {
21 - $this->template_types = [
21 + add_action('add_meta_boxes', [$this, 'add']);
22 + add_action('save_post', [$this, 'save']);
23 + }
22 24
23 - "New Order" => esc_html__('New Order - WC ', 'emailkit'),
24 - "Cancelled order" => esc_html__('Cancelled order - WC ', 'emailkit'),
25 - "Failed Order" => esc_html__('Failed Order - WC ', 'emailkit'),
26 - "Order On Hold" => esc_html__('Order On Hold - WC ', 'emailkit'),
27 - "Processing Order" => esc_html__('Processing Order - WC ', 'emailkit'),
28 - "Completed Order" => esc_html__('Completed Order - WC ', 'emailkit'),
29 - "Refunded Order" => esc_html__('Refunded Order - WC ', 'emailkit'),
30 - "Customer Invoice" => esc_html__('Customer Invoice - WC ', 'emailkit'),
31 - "Customer Note" => esc_html__('Customer Note - WC ', 'emailkit'),
32 - "Reset Password" => esc_html__('Reset Password - WC ', 'emailkit'),
33 - "New Account" => esc_html__('New Account - WC ', 'emailkit'),
34 - ];
25 + /**
26 + * Get the translated template type labels.
27 + *
28 + * Built on demand because this class is instantiated on `plugins_loaded`,
29 + * and translation functions must not run before `init`.
30 + *
31 + * @return array
32 + */
33 + public function get_template_types()
34 + {
35 + if (empty($this->template_types)) {
35 36
36 - add_action('add_meta_boxes', [$this, 'add']);
37 - add_action('save_post', [$this, 'save']);
37 + $this->template_types = [
38 +
39 + "New Order" => __('New Order - WC', 'emailkit'),
40 + "Cancelled order" => __('Cancelled order - WC', 'emailkit'),
41 + "Failed Order" => __('Failed Order - WC', 'emailkit'),
42 + "Order On Hold" => __('Order On Hold - WC', 'emailkit'),
43 + "Processing Order" => __('Processing Order - WC', 'emailkit'),
44 + "Completed Order" => __('Completed Order - WC', 'emailkit'),
45 + "Refunded Order" => __('Refunded Order - WC', 'emailkit'),
46 + "Customer Invoice" => __('Customer Invoice - WC', 'emailkit'),
47 + "Customer Note" => __('Customer Note - WC', 'emailkit'),
48 + "Reset Password" => __('Reset Password - WC', 'emailkit'),
49 + "New Account" => __('New Account - WC', 'emailkit'),
50 + ];
51 + }
52 +
53 + return $this->template_types;
38 54 }
39 55
40 56 public function add()
41 57 {
42 58
43 - add_meta_box("metaBox_id", "Email Details", [$this, 'emailTemplate'], ["emailkit"], "advanced", "high", null);
59 + add_meta_box("metaBox_id", __('Email Details', 'emailkit'), [$this, 'emailTemplate'], ["emailkit"], "advanced", "high", null);
44 60 }
45 61
46 62 /**
47 63 * MetaBox Template
@@ -64,9 +80,9 @@
64 80 <select name="emailkit_template_type" id="emailkit_template_type" style="width:100% !important;">
65 81 <option value=""><?php esc_html_e('Select Template Types', 'emailkit'); ?></option>
66 82 <?php
67 83
68 - foreach ($this->template_types as $key => $template_type) {
84 + foreach ($this->get_template_types() as $key => $template_type) {
69 85 ?>
70 86 <option value="<?php echo esc_attr($key); ?>" <?php echo esc_html($key == get_post_meta($object->ID, "emailkit_template_type", true) ? 'selected' : ''); ?>>
71 87 <?php echo esc_attr($template_type); ?> </option>
72 88 <?php } ?>
@@ -90,9 +106,9 @@
90 106
91 107 <?php
92 108 $status = esc_html(get_post_meta($object->ID, "emailkit_template_status", 'Active'));
93 109 $checked_on = $status == 'Active' ? "checked" : "";
94 - $toggle_label = $status == 'Active' ? "Active" : "Inactive";
110 + $toggle_label = $status == 'Active' ? __('Active', 'emailkit') : __('Inactive', 'emailkit');
95 111 $status_value = $status == 'Active' ? "active" : "inactive";
96 112 ?>
97 113
98 114 <div class="toggle-switch">
@@ -295,9 +311,10 @@
295 311 update_post_meta($post_id, 'emailkit_template_title', sanitize_text_field(wp_unslash($_POST['emailkit_template_title'])));
296 312 }
297 313
298 314 $emailkit_template_type = isset($_POST['emailkit_template_type']) ? sanitize_text_field(wp_unslash($_POST['emailkit_template_type'])) : '';
299 - if (isset($_POST['emailkit_template_type']) && isset($this->template_types[$emailkit_template_type])) {
315 + $template_types = $this->get_template_types();
316 + if (isset($_POST['emailkit_template_type']) && isset($template_types[$emailkit_template_type])) {
300 317
301 318 update_post_meta($post_id, 'emailkit_template_type', $emailkit_template_type);
302 319 }
303 320