PluginProbe
YayMail – WooCommerce Email Customizer / 1.9.6
YayMail – WooCommerce Email Customizer v1.9.6
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
yaymail / includes / Templates / Templates.php

Templates.php in YayMail – WooCommerce Email Customizer 1.9.6, at includes/Templates/Templates.php

437 lines 15.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace YayMail\Templates;
4
5 use YayMail\Helper\Helper;
6 // Templates Default
7 use YayMail\Templates\DefaultTemplate\CancelledOrder;
8 use YayMail\Templates\DefaultTemplate\CustomerCompletedOrder;
9 use YayMail\Templates\DefaultTemplate\CustomerInvoice;
10 use YayMail\Templates\DefaultTemplate\CustomerNewAccount;
11 use YayMail\Templates\DefaultTemplate\CustomerNote;
12 use YayMail\Templates\DefaultTemplate\CustomerOnHoldOrder;
13 use YayMail\Templates\DefaultTemplate\CustomerProcessingOrder;
14 use YayMail\Templates\DefaultTemplate\CustomerRefundedOrder;
15 use YayMail\Templates\DefaultTemplate\CustomerResetPassword;
16 use YayMail\Templates\DefaultTemplate\FailedOrder;
17 use YayMail\Templates\DefaultTemplate\NewOrder;
18 use YayMail\Templates\DefaultTemplate\CustomOrderStastus;
19 use YayMail\Templates\DefaultTemplate\DefaultSubscription;
20 use YayMail\Templates\DefaultTemplate\YITHSubscription;
21
22 defined( 'ABSPATH' ) || exit;
23 /**
24 * Plugin activate/deactivate logic
25 */
26 class Templates {
27
28 protected static $instance = null;
29
30 public static function getInstance() {
31 if ( null == self::$instance ) {
32 self::$instance = new self();
33 }
34
35 return self::$instance;
36 }
37
38 public static function getList() {
39 $wc_emails = \WC_Emails::instance();
40 $listEmails = (array) $wc_emails::instance()->emails;
41 $listEmailDefaultOfWoo = array(
42 'new_order',
43 'failed_order',
44 'customer_reset_password',
45 'customer_refunded_order',
46 'customer_processing_order',
47 'customer_on_hold_order',
48 'customer_note',
49 'customer_new_account',
50 'customer_invoice',
51 'customer_completed_order',
52 'cancelled_order',
53 );
54 // Get Default Template
55 $newOrderArr = NewOrder::getTemplates();
56 $cancelledOrderArr = CancelledOrder::getTemplates();
57 $cusComdOrderArr = CustomerCompletedOrder::getTemplates();
58 $cusInvoiceArr = CustomerInvoice::getTemplates();
59 $cusNewAccountArr = CustomerNewAccount::getTemplates();
60 $cusNoteArr = CustomerNote::getTemplates();
61 $cusOnHoldOrderArr = CustomerOnHoldOrder::getTemplates();
62 $cusProOrderArr = CustomerProcessingOrder::getTemplates();
63 $cusRefdOrderArr = CustomerRefundedOrder::getTemplates();
64 $cusResPasswordArr = CustomerResetPassword::getTemplates();
65 $faiOrderArr = FailedOrder::getTemplates();
66
67 $listTemplates = array();
68 $listTemplates = array_merge( $listTemplates, $newOrderArr );
69 $listTemplates = array_merge( $listTemplates, $cancelledOrderArr );
70 $listTemplates = array_merge( $listTemplates, $faiOrderArr );
71 $listTemplates = array_merge( $listTemplates, $cusOnHoldOrderArr );
72 $listTemplates = array_merge( $listTemplates, $cusProOrderArr );
73 $listTemplates = array_merge( $listTemplates, $cusComdOrderArr );
74 $listTemplates = array_merge( $listTemplates, $cusRefdOrderArr );
75 $listTemplates = array_merge( $listTemplates, $cusInvoiceArr );
76 $listTemplates = array_merge( $listTemplates, $cusNoteArr );
77 $listTemplates = array_merge( $listTemplates, $cusResPasswordArr );
78 $listTemplates = array_merge( $listTemplates, $cusNewAccountArr );
79
80 foreach ( $listEmails as $key => $value ) {
81 if ( ! in_array( $value->id, $listEmailDefaultOfWoo ) ) {
82 $getHeading = $value->heading;
83 if ( 'WCS_Email_New_Switch_Order' == $key
84 || 'WCS_Email_Completed_Switch_Order' == $key
85 || 'WCS_Email_Cancelled_Subscription' == $key
86 || 'WCS_Email_Expired_Subscription' == $key
87 || 'WCS_Email_On_Hold_Subscription' == $key
88 ) {
89 $defaultSubscription = DefaultSubscription::getTemplates( $value->id, $getHeading );
90 $listTemplates = array_merge( $listTemplates, $defaultSubscription );
91 } elseif ( 'YITH_WC_Subscription_Status' == $key
92 || 'YITH_WC_Customer_Subscription_Cancelled' == $key
93 || 'YITH_WC_Customer_Subscription_Suspended' == $key
94 || 'YITH_WC_Customer_Subscription_Expired' == $key
95 || 'YITH_WC_Customer_Subscription_Before_Expired' == $key
96 || 'YITH_WC_Customer_Subscription_Paused' == $key
97 || 'YITH_WC_Customer_Subscription_Resumed' == $key
98 || 'YITH_WC_Customer_Subscription_Request_Payment' == $key
99 || 'YITH_WC_Customer_Subscription_Renew_Reminder' == $key
100 || 'YITH_WC_Customer_Subscription_Payment_Done' == $key
101 || 'YITH_WC_Customer_Subscription_Payment_Failed' == $key ) {
102 $yithSubscription = YITHSubscription::getTemplates( $value->id, $getHeading );
103 $listTemplates = array_merge( $listTemplates, $yithSubscription );
104 } else {
105 $customOrderStastus = CustomOrderStastus::getTemplates( $value->id, $getHeading );
106 $listTemplates = array_merge( $listTemplates, $customOrderStastus );
107 }
108 }
109 }
110
111 return $listTemplates;
112 }
113
114 public static function getCssFortmat() {
115 $yaymail_settings = get_option( 'yaymail_settings' );
116 $colorTableItems = isset( $yaymail_settings['background_color_table_items'] ) && ! empty( $yaymail_settings['background_color_table_items'] ) ? $yaymail_settings['background_color_table_items'] : '#e5e5e5';
117 $colorTitleTableItems = isset( $yaymail_settings['title_items_color'] ) && ! empty( $yaymail_settings['title_items_color'] ) ? $yaymail_settings['title_items_color'] : '#96588a';
118 $colorContentTableItems = isset( $yaymail_settings['content_items_color'] ) && ! empty( $yaymail_settings['content_items_color'] ) ? $yaymail_settings['content_items_color'] : '#636363';
119 $custom_css = isset( $yaymail_settings['custom_css'] ) && ! empty( $yaymail_settings['custom_css'] ) ? $yaymail_settings['custom_css'] : '';
120 $enableCustomCss = isset( $yaymail_settings['enable_css_custom'] ) && ! empty( $yaymail_settings['enable_css_custom'] ) ? $yaymail_settings['enable_css_custom'] : '';
121 $orderImagePostions = isset( $yaymail_settings['image_position'] ) && ! empty( $yaymail_settings['image_position'] ) ? $yaymail_settings['image_position'] : 'Top';
122 /*
123 ======
124 @@@ Start css for shortcode [yaymail_items_border]
125 @@@ note: use for table has border
126 ====== */
127 $order_dh = '<table></table>';
128 $css = 'table.yaymail_builder_table_items_border {
129 border-collapse: separate !important;
130 width: 100%;
131 border: 1px solid ' . $colorTableItems . ';
132 flex-direction: inherit;
133 }';
134 $css .= 'table.yaymail_builder_table_items_content tbody tr td, table.yaymail_builder_table_items_content tbody tr th {
135 vertical-align:middle;
136 padding:12px;
137 text-align:left;
138 font-size: 14px;
139 border-width: 1px;
140 border-style: solid;
141 border-color: inherit;
142 }';
143 $css .= 'table.yaymail_builder_table_items_content tbody, table.yaymail_builder_table_items_content tbody tr, span[data-shordcode="yaymail_billing_shipping_address_content"] tbody, span[data-shordcode="yaymail_billing_shipping_address_content"] tbody tr {
144 border-color: inherit;
145 }';
146
147 $css .= 'table.yaymail_builder_table_items_border img {
148 max-width: 100%;
149 }';
150
151 $css .= 'table.yaymail_builder_table_items_border thead {
152 border-width: 1px;
153 border-style: solid;
154 border-color: inherit
155 }';
156 $css .= 'table.yaymail_builder_table_items_border thead tr {
157 border-width: 1px;
158 border-style: solid;
159 border-color: inherit
160 }';
161 $css .= 'table.yaymail_builder_table_items_border thead tr th {
162 vertical-align:middle;
163 padding:12px;
164 text-align:left;
165 font-family: inherit;
166 font-size: 14px;
167 border-width: 1px;
168 border-style: solid;
169 border-color: inherit
170 }';
171 $css .= 'table.yaymail_builder_table_items_border tbody {
172 border-width: 1px;
173 border-style: solid;
174 border-color: inherit
175 }';
176 $css .= 'table.yaymail_builder_table_items_border tbody tr {
177 border-width: 1px;
178 border-style: solid;
179 border-color: inherit
180 }';
181 $css .= 'table.yaymail_builder_table_items_border tbody tr td {
182 padding:12px;
183 text-align:left;
184 vertical-align:middle;
185 font-family: inherit;
186 word-break:normal;
187 font-size: 14px;
188 border-width: 1px;
189 border-style: solid;
190 border-color: inherit
191 }';
192 $css .= 'table.yaymail_builder_table_items_border tfoot {
193 border-width: 1px;
194 border-style: solid;
195 border-color: inherit
196 }';
197 $css .= 'table.yaymail_builder_table_items_border tfoot tr {
198 border-width: 1px;
199 border-style: solid;
200 border-color: inherit
201 }';
202 $css .= 'table.yaymail_builder_table_items_border tfoot tr td {
203 vertical-align:middle;
204 padding:12px;
205 text-align:left;
206 font-family: inherit;
207 font-size: 14px;
208 border-width: 1px;
209 border-style: solid;
210 border-color: inherit
211 }';
212 $css .= ' table.yaymail_builder_table_items_border tfoot tr th {
213 vertical-align:middle;
214 padding:12px;
215 text-align:left;
216 font-size: 14px;
217 border-width: 1px;
218 border-style: solid;
219 border-color: inherit
220 }';
221
222 $css .= 'table.yaymail_builder_table_items_border tr.order_item ul {
223 font-size: small;
224 margin: 1em 0 0;
225 padding: 0;
226 list-style: none;
227 }';
228
229 $css .= 'table.yaymail_builder_table_items_border tr.order_item li strong {
230 float:left;
231 margin-right:.25em;
232 clear:both;
233 }';
234
235 $css .= 'table.yaymail_builder_table_items_border tr.order_item li {
236 margin:0.5em 0 0;
237 padding:0;
238 }';
239
240 $css .= 'table.yaymail_builder_table_items_border tr.order_item li p {
241 margin: 0;
242 }';
243
244 /* ====== End ====== */
245
246 /*
247 ======
248 @@@ Start css for shortcode [yaymail_items]
249 @@@ note: use for table not border
250 ====== */
251 $css .= 'table.yaymail_builder_table_items {
252 border-collapse: collapse !important;
253 width: 100%;
254 color:' . $colorContentTableItems . ';
255 }';
256
257 $css .= 'table.yaymail_builder_table_items img {
258 max-width: 100%
259 }';
260
261 $css .= 'table.yaymail_builder_table_items tbody tr,
262 table.yaymail_builder_table_items tbody tr td,
263 table.yaymail_builder_table_items thead tr,
264 table.yaymail_builder_table_items thead tr th,
265 table.yaymail_builder_table_items thead tr td,
266 table.yaymail_builder_table_items tfoot tr,
267 table.yaymail_builder_table_items tfoot tr th,
268 table.yaymail_builder_table_items tfoot tr td {
269 vertical-align:middle;
270 padding:12px;
271 text-align:left;
272 font-size:14px;
273 }';
274
275 $css .= 'table td {
276 font-family: inherit;
277 }';
278
279 $css .= 'table.yaymail_builder_table_items tr {
280 border-bottom: 1px solid ' . $colorTableItems . '
281 }';
282
283 $css .= '.yaymail_builder_bank_details, .yaymail_builder_account_name {
284 color: inherit;
285 display:block;
286 font-family: inherit;
287 font-size:18px;
288 font-weight:bold;
289 line-height:130%;
290 margin:0 0 18px;
291 }';
292
293 $css .= '.yaymail_builder_order {
294 margin-bottom: 0.83em;
295 display:block;
296 font-family: inherit;
297 font-size:18px;
298 font-weight:bold;
299 line-height:130%;
300 margin:0 0 18px;
301 }';
302
303 $css .= 'table.yaymail_builder_table_items tr.order_item ul {
304 font-size: small;
305 margin: 1em 0 0;
306 padding: 0;
307 list-style: none;
308 }';
309
310 $css .= 'table.yaymail_builder_table_items tr.order_item li strong {
311 float:left;
312 margin-right:.25em;
313 clear:both
314 }';
315
316 $css .= 'table.yaymail_builder_table_items tr.order_item li {
317 margin:0.5em 0 0;
318 padding:0;
319 }';
320
321 $css .= 'table.yaymail_builder_table_items tr.order_item li p {
322 margin: 0;
323 }';
324
325 $css .= 'table.yaymail_builder_table_items ul li {
326 list-style: none;
327 margin-left: 0px;
328 }';
329 /* ====== End ====== */
330
331 $css .= 'h3.yaymail_builder_account_name {
332 font-size:16px;
333 }';
334
335 $css .= '.yaymail_builder_order a.yaymail_builder_link {
336 font-weight: normal;
337 text-decoration: underline;
338 }';
339
340 $css .= '.yaymail_builder_order ul {
341 padding-left: 0px
342 }';
343
344 $css .= 'section.yaymail_builder_wrap_account {
345 color: inherit;
346 font-family: inherit;
347 font-size: 14px;
348 line-height: 150%;
349 text-align: left;
350 }';
351
352 $css .= 'section.yaymail_builder_wrap_account ul {
353 color: ' . $colorContentTableItems . ';
354 }';
355
356 $css .= '.yaymail_builder_instructions{
357 color: ' . $colorContentTableItems . ';
358 font-family: inherit;
359 font-size: 14px;
360 line-height: 150%;
361 text-align: left;
362 }';
363
364 // reset css
365 $css .= 'table p {
366 margin: 0px;
367 }';
368
369 $css .= 'table h1, table h2, table h3, table h4, table h5, table h6 {
370 margin: 0px;
371 }';
372
373 $css .= '.yaymail-items-order-border tbody[data-shordcode="yaymail_items_border_content"],
374 .yaymail-items-order-border
375 tbody[data-shordcode="yaymail_items_border_content"]
376 .yaymail_builder_table_items_border {
377 border-color: inherit;
378 flex-direction: inherit;
379 }
380 .yaymail-items-order-border
381 tbody[data-shordcode="yaymail_items_border_content"]
382 .yaymail_builder_table_items_border tbody {
383 flex-direction: inherit;
384 }';
385 // add css for table subcription, item download
386 $css .= 'table.yaymail_builder_table_subcription,
387 table.yaymail_builder_table_tracking_item,
388 table.yaymail_builder_table_item_download,
389 table.yaymail_builder_table_item_subscription {
390 color: inherit;
391 border-width: 1px;
392 border-style: solid;
393 border-color: inherit;
394 }';
395 $css .= '.yaymail-items-order-border span[data-shordcode="yaymail_items_subscription_expired"],
396 .yaymail-items-order-border span[data-shordcode="yaymail_items_subscription_suspended"],
397 .yaymail-items-order-border span[data-shordcode="yaymail_items_subscription_cancelled"],
398 .yaymail-items-order-border span[data-shordcode="yaymail_items_subscription_information"],
399 .yaymail-items-tracking-item div[data-shordcode="yaymail_order_meta:_wc_shipment_tracking_items"],
400 .yaymail-items-item-download span[data-shordcode="yaymail_items_downloadable_product"],
401 .yaymail-items-subscript-border span[data-shordcode="yaymail_subscription_table"]
402 {
403 border-color: inherit;
404 }';
405
406 $css .= '#web-ad422370-f762-4a26-92de-c4cf3821b8eb-order-item .yaymail_items_border_default h2,
407 #web-ad422370-f762-4a26-92de-c4cf3821b8eb-order-item .yaymail_items_border_default h3 {
408 color: #96588a;
409 }';
410 $css .= '.yaymail_items_border_custom h2,.yaymail_items_border_custom h3 {
411 color: inherit !important;
412 }';
413 $css .= '.nta-two-column-items table.web-main-row ,
414 .nta-three-column-items table.web-main-row,
415 .nta-four-column-items table.web-main-row
416 {
417 width: 100% !important;
418 }';
419 if ( 'yes' == $enableCustomCss ) {
420 $css .= $custom_css;
421 }
422
423 if ( 'Left' == $orderImagePostions ) {
424 $css .= '.yaymail-product-image{
425 float: left;
426 }';
427 }
428
429 if ( 'Top' == $orderImagePostions ) {
430 $css .= '.yaymail-product-image{
431 float: unset;
432 }';
433 }
434 return $css;
435 }
436 }
437