PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.5
YayMail – WooCommerce Email Customizer v4.4.5
4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 All 57 releases
← All changes | src/Abstracts/BaseTemplate.php +30 -2 4.4.1 → 4.4.5 View file →
@@ -1,8 +1,10 @@
1 1 <?php
2 2
3 3 namespace YayMail\Abstracts;
4 4
5 +use YayMail\Utils\TemplateHelpers;
6 +
5 7 /**
6 8 * Base class for code-defined email templates in Template Library.
7 9 */
8 10 abstract class BaseTemplate {
@@ -36,8 +38,15 @@
36 38 */
37 39 protected $description;
38 40
39 41 /**
42 + * Categories for filtering templates in the UI.
43 + *
44 + * @var array
45 + */
46 + protected $categories = [];
47 +
48 + /**
40 49 * Optional position for ordering in the UI.
41 50 *
42 51 * @var int
43 52 */
@@ -75,8 +84,15 @@
75 84 * @var array
76 85 */
77 86 protected $template_settings = [];
78 87
88 + /**
89 + * Last updated date of the template.
90 + *
91 + * @var string
92 + */
93 + protected $modified_date = '';
94 +
79 95 public function __construct() {
80 96 }
81 97
82 98 public function get_email_type() {
@@ -94,8 +110,12 @@
94 110 public function get_description() {
95 111 return $this->description;
96 112 }
97 113
114 + public function get_categories() {
115 + return $this->categories;
116 + }
117 +
98 118 public function get_available() {
99 119 return $this->available;
100 120 }
101 121
@@ -114,8 +134,12 @@
114 134 public function get_email_settings() {
115 135 return $this->template_settings;
116 136 }
117 137
138 + public function get_modified_date() {
139 + return $this->modified_date;
140 + }
141 +
118 142 /**
119 143 * Get full template payload including elements.
120 144 *
121 145 * @return array
@@ -123,17 +147,21 @@
123 147 public function get_template_data() {
124 148 // Always recompute availability before exposing data to REST.
125 149 $this->available = $this->determine_availability();
126 150
151 + $elements = TemplateHelpers::normalize_elements_parent_ids( $this->get_elements() );
152 +
127 153 $data = [
128 154 'id' => $this->get_id(),
129 155 'email_type' => $this->get_email_type(),
130 156 'name' => $this->get_name(),
131 157 'description' => $this->get_description(),
158 + 'categories' => $this->get_categories(),
132 159 'position' => $this->get_position(),
160 + 'modified_date' => $this->get_modified_date(),
133 161 'available' => $this->get_available(),
134 162 'access' => $this->get_access(),
135 - 'elements' => $this->get_elements(),
163 + 'elements' => $elements,
136 164 'email_settings' => $this->get_email_settings(),
137 165 ];
138 166
139 167 return $data;
@@ -185,5 +213,5 @@
185 213 || array_key_exists( 'email-customizer-for-woocommerce/yaymail.php', $all_plugins );
186 214
187 215 return (bool) $is_pro_cache;
188 216 }
189 -}
217 +}