PluginProbe
YayMail – WooCommerce Email Customizer / 3.4
YayMail – WooCommerce Email Customizer v3.4
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 3.4.2 3.4.3 All 55 releases
yaymail / includes / Templates / Templates.php

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

495 lines 17.2 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 stdClass;
6 use YayMail\Helper\Helper;
7 // Templates Default
8 use YayMail\Templates\DefaultTemplate\CancelledOrder;
9 use YayMail\Templates\DefaultTemplate\CustomerCompletedOrder;
10 use YayMail\Templates\DefaultTemplate\CustomerInvoice;
11 use YayMail\Templates\DefaultTemplate\CustomerNewAccount;
12 use YayMail\Templates\DefaultTemplate\CustomerNote;
13 use YayMail\Templates\DefaultTemplate\CustomerOnHoldOrder;
14 use YayMail\Templates\DefaultTemplate\CustomerProcessingOrder;
15 use YayMail\Templates\DefaultTemplate\CustomerRefundedOrder;
16 use YayMail\Templates\DefaultTemplate\CustomerResetPassword;
17 use YayMail\Templates\DefaultTemplate\FailedOrder;
18 use YayMail\Templates\DefaultTemplate\NewOrder;
19 use YayMail\Templates\DefaultTemplate\CustomOrderStastus;
20 use YayMail\Templates\DefaultTemplate\YITHSubscription;
21 use YayMail\Templates\DefaultTemplate\YITHMultiVendor\YITHMultiVendorDefault;
22 use YayMail\Templates\DefaultTemplate\YITHMultiVendor\YITHMultiVendorNewOrder;
23 use YayMail\Templates\DefaultTemplate\YITHMultiVendor\YITHMultiVendorCommissionsBulk;
24 use YayMail\Templates\DefaultTemplate\YITHMultiVendor\YITHMultiVendorRegistration;
25 use YayMail\Templates\DefaultTemplate\YITHMultiVendor\YITHMultiCommissions;
26 use YayMail\Templates\DefaultTemplate\GermanizedForWoo\SimpleInvoice;
27 use YayMail\Templates\DefaultTemplate\YITHWishlist\EstimateMail;
28 use YayMail\Templates\DefaultTemplate\WooBookings\BookingsDefault;
29
30 defined( 'ABSPATH' ) || exit;
31 /**
32 * Plugin activate/deactivate logic
33 */
34 class Templates {
35
36 protected static $instance = null;
37
38 public static function getInstance() {
39 if ( null == self::$instance ) {
40 self::$instance = new self();
41 }
42
43 return self::$instance;
44 }
45
46 public static function getList() {
47 $wc_emails = \WC_Emails::instance();
48 $listEmails = (array) $wc_emails::instance()->emails;
49 if ( isset( $listEmails['WC_GZD_Email_Customer_Shipment'] ) ) {
50 $partial_email = new stdClass();
51 $partial_email->id = 'customer_partial_shipment';
52 $partial_email->title = 'Order partial shipped';
53 $customer_shipment_position = array_search( 'WC_GZD_Email_Customer_Shipment', array_keys( $listEmails ) );
54 $listEmails = array_merge(
55 array_slice( $listEmails, 0, $customer_shipment_position ),
56 array( 'WC_GZD_Email_Customer_Partial_Shipment' => $partial_email ),
57 array_slice( $listEmails, $customer_shipment_position )
58 );
59 }
60 if ( class_exists( 'AW_Referrals_Plugin_Data' ) && ( is_plugin_active( 'yaymail-addon-for-automatewoo/yaymail-automatewoo.php' ) || is_plugin_active( 'email-customizer-automatewoo/yaymail-automatewoo.php' ) ) ) {
61 $referrals_email = new stdClass();
62 $referrals_email->id = 'AutomateWoo_Referrals_Email';
63 $referrals_email->title = __( 'AutomateWoo Referrals Email', 'yaymail' );
64 $listEmails = array_merge( $listEmails, array( 'AutomateWoo_Referrals_Email' => $referrals_email ) );
65 }
66 $listEmails = apply_filters( 'YaymailCreateFollowUpTemplates', $listEmails );
67 $listEmails = apply_filters( 'YaymailCreateGermanMarketTemplates', $listEmails );
68 $listEmails = apply_filters( 'YaymailCreateAutomateWooTemplates', $listEmails );
69 $listEmails = apply_filters( 'YaymailCreateTrackShipWooTemplates', $listEmails );
70 $listEmails = apply_filters( 'YaymailCreateWCFMWooFMTemplates', $listEmails );
71 $listEmails = apply_filters( 'YaymailCreateListYWCESTemplates', $listEmails );
72 $listEmails = apply_filters( 'YaymailCreateWcCartAbandonmentRecoveryTemplates', $listEmails );
73 $listEmails = apply_filters( 'YaymailCreateB2BMarketTemplates', $listEmails );
74 $listEmails = apply_filters( 'YaymailCreateShopMagicTemplates', $listEmails );
75
76 $listEmailDefaultOfWoo = array(
77 'new_order',
78 'failed_order',
79 'customer_reset_password',
80 'customer_refunded_order',
81 'customer_processing_order',
82 'customer_on_hold_order',
83 'customer_note',
84 'customer_new_account',
85 'customer_invoice',
86 'customer_completed_order',
87 'cancelled_order',
88 );
89 // Get Default Template
90 $newOrderArr = NewOrder::getTemplates();
91 $cancelledOrderArr = CancelledOrder::getTemplates();
92 $cusComdOrderArr = CustomerCompletedOrder::getTemplates();
93 $cusInvoiceArr = CustomerInvoice::getTemplates();
94 $cusNewAccountArr = CustomerNewAccount::getTemplates();
95 $cusNoteArr = CustomerNote::getTemplates();
96 $cusOnHoldOrderArr = CustomerOnHoldOrder::getTemplates();
97 $cusProOrderArr = CustomerProcessingOrder::getTemplates();
98 $cusRefdOrderArr = CustomerRefundedOrder::getTemplates();
99 $cusResPasswordArr = CustomerResetPassword::getTemplates();
100 $faiOrderArr = FailedOrder::getTemplates();
101
102 $listTemplates = array();
103 $listTemplates = array_merge( $listTemplates, $newOrderArr );
104 $listTemplates = array_merge( $listTemplates, $cancelledOrderArr );
105 $listTemplates = array_merge( $listTemplates, $faiOrderArr );
106 $listTemplates = array_merge( $listTemplates, $cusOnHoldOrderArr );
107 $listTemplates = array_merge( $listTemplates, $cusProOrderArr );
108 $listTemplates = array_merge( $listTemplates, $cusComdOrderArr );
109 $listTemplates = array_merge( $listTemplates, $cusRefdOrderArr );
110 $listTemplates = array_merge( $listTemplates, $cusInvoiceArr );
111 $listTemplates = array_merge( $listTemplates, $cusNoteArr );
112 $listTemplates = array_merge( $listTemplates, $cusResPasswordArr );
113 $listTemplates = array_merge( $listTemplates, $cusNewAccountArr );
114
115 foreach ( $listEmails as $key => $value ) {
116 if ( is_array( $value ) ) {
117 if ( ! in_array( $value['id'], $listEmailDefaultOfWoo ) ) {
118 $newTempalte = apply_filters( 'YaymailNewTempalteDefault', '', $key, $value );
119 if ( isset( $newTempalte ) && null != $newTempalte && is_array( $newTempalte ) ) {
120 $listTemplates = array_merge( $listTemplates, $newTempalte );
121 }
122 }
123 } else {
124 if ( ! in_array( $value->id, $listEmailDefaultOfWoo ) ) {
125 $newTempalte = apply_filters( 'YaymailNewTempalteDefault', '', $key, $value );
126 if ( isset( $newTempalte ) && null != $newTempalte && is_array( $newTempalte ) ) {
127 $listTemplates = array_merge( $listTemplates, $newTempalte );
128 }
129 }
130 }
131 }
132
133 return $listTemplates;
134 }
135
136 public static function getCssFortmat() {
137 $yaymail_settings = get_option( 'yaymail_settings' );
138 $colorTableItems = isset( $yaymail_settings['background_color_table_items'] ) && ! empty( $yaymail_settings['background_color_table_items'] ) ? sanitize_text_field( $yaymail_settings['background_color_table_items'] ) : '#e5e5e5';
139 $colorTitleTableItems = isset( $yaymail_settings['title_items_color'] ) && ! empty( $yaymail_settings['title_items_color'] ) ? sanitize_text_field( $yaymail_settings['title_items_color'] ) : '#7f54b3';
140 $colorContentTableItems = isset( $yaymail_settings['content_items_color'] ) && ! empty( $yaymail_settings['content_items_color'] ) ? sanitize_text_field( $yaymail_settings['content_items_color'] ) : '#636363';
141 $custom_css = isset( $yaymail_settings['custom_css'] ) && ! empty( $yaymail_settings['custom_css'] ) ? sanitize_text_field( $yaymail_settings['custom_css'] ) : '';
142 $enableCustomCss = isset( $yaymail_settings['enable_css_custom'] ) && ! empty( $yaymail_settings['enable_css_custom'] ) ? $yaymail_settings['enable_css_custom'] : '';
143 $orderImagePostions = isset( $yaymail_settings['image_position'] ) && ! empty( $yaymail_settings['image_position'] ) ? $yaymail_settings['image_position'] : 'Top';
144 $productRegularPrice = isset( $yaymail_settings['product_regular_price'] ) ? $yaymail_settings['product_regular_price'] : 0;
145 /*
146 ======
147 @@@ Start css for shortcode [yaymail_items_border]
148 @@@ note: use for table has border
149 ====== */
150 $order_dh = '<table></table>';
151 $css = 'table.yaymail_builder_table_items_border {
152 border-collapse: separate !important;
153 width: 100%;
154 border: 1px solid ' . $colorTableItems . ';
155 flex-direction: inherit;
156 }';
157 $css .= 'ul {
158 list-style: none;
159 }';
160 $css .= 'table.yaymail_builder_table_items_content tbody tr td, table.yaymail_builder_table_items_content tbody tr th {
161 vertical-align:middle;
162 padding:12px;
163 text-align:left;
164 font-size: 14px;
165 border-width: 1px;
166 border-style: solid;
167 border-color: inherit;
168 }';
169 $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 {
170 border-color: inherit;
171 }';
172
173 $css .= '.element-text-content h1 .yaymail-order-id {
174 color: inherit !important;
175 text-decoration: unset;
176 }';
177
178 $css .= 'table.yaymail_builder_table_items_border img {
179 max-width: 100%;
180 }';
181
182 $css .= 'table.yaymail_builder_table_items_border thead {
183 border-width: 1px;
184 border-style: solid;
185 border-color: inherit
186 }';
187
188 $css .= 'table.yaymail_builder_table_items_border thead tr {
189 border-width: 1px;
190 border-style: solid;
191 border-color: inherit
192 }';
193
194 $css .= 'table.yaymail_builder_table_items_border thead tr th {
195 vertical-align:middle;
196 padding:12px;
197 text-align:left;
198 font-family: inherit;
199 font-size: 14px;
200 border-width: 1px;
201 border-style: solid;
202 border-color: inherit
203 }';
204
205 $css .= 'table.yaymail_builder_table_items_border tbody {
206 border-width: 1px;
207 border-style: solid;
208 border-color: inherit
209 }';
210
211 $css .= 'table.yaymail_builder_table_items_border tbody tr {
212 border-width: 1px;
213 border-style: solid;
214 border-color: inherit
215 }';
216
217 $css .= 'table.yaymail_builder_table_items_border tbody tr td {
218 padding:12px;
219 text-align:left;
220 vertical-align:middle;
221 font-family: inherit;
222 word-break:normal;
223 font-size: 14px;
224 border-width: 1px;
225 border-style: solid;
226 border-color: inherit
227 }';
228
229 $css .= 'table.yaymail_builder_table_items_border tfoot {
230 border-width: 1px;
231 border-style: solid;
232 border-color: inherit
233 }';
234
235 $css .= 'table.yaymail_builder_table_items_border tfoot tr {
236 border-width: 1px;
237 border-style: solid;
238 border-color: inherit
239 }';
240
241 $css .= 'table.yaymail_builder_table_items_border tfoot tr td {
242 vertical-align:middle;
243 padding:12px;
244 text-align:left;
245 font-family: inherit;
246 font-size: 14px;
247 border-width: 1px;
248 border-style: solid;
249 border-color: inherit
250 }';
251
252 $css .= ' table.yaymail_builder_table_items_border tfoot tr th {
253 vertical-align:middle;
254 padding:12px;
255 text-align:left;
256 font-size: 14px;
257 border-width: 1px;
258 border-style: solid;
259 border-color: inherit
260 }';
261
262 $css .= 'table.yaymail_builder_table_items_border tr.order_item ul {
263 font-size: small;
264 margin: 1em 0 0;
265 padding: 0;
266 list-style: none;
267 }';
268
269 $css .= 'table.yaymail_builder_table_items_border tr.order_item li strong {
270 float:left;
271 margin-right:.25em;
272 clear:both;
273 }';
274
275 $css .= 'table.yaymail_builder_table_items_border tr.order_item li {
276 margin:0.5em 0 0;
277 padding:0;
278 }';
279
280 $css .= 'table.yaymail_builder_table_items_border tr.order_item li p {
281 margin: 0;
282 }';
283
284 $css .= '.yaymail-product-sku{
285 word-break: break-word;
286 }';
287
288 $css .= '.yaymail-sup-infor{
289 white-space: nowrap;
290 }';
291 /* ====== End ====== */
292
293 /*
294 ======
295 @@@ Start css for shortcode [yaymail_items]
296 @@@ note: use for table not border
297 ====== */
298 $css .= 'table.yaymail_builder_table_items {
299 border-collapse: collapse !important;
300 width: 100%;
301 color:' . $colorContentTableItems . ';
302 }';
303
304 $css .= 'table.yaymail_builder_table_items img {
305 max-width: 100%
306 }';
307
308 $css .= 'table.yaymail_builder_table_items tbody tr,
309 table.yaymail_builder_table_items tbody tr td,
310 table.yaymail_builder_table_items thead tr,
311 table.yaymail_builder_table_items thead tr th,
312 table.yaymail_builder_table_items thead tr td,
313 table.yaymail_builder_table_items tfoot tr,
314 table.yaymail_builder_table_items tfoot tr th,
315 table.yaymail_builder_table_items tfoot tr td {
316 vertical-align:middle;
317 padding:12px;
318 text-align:left;
319 font-size:14px;
320 }';
321
322 $css .= 'table td {
323 font-family: inherit;
324 }';
325
326 $css .= 'table.yaymail_builder_table_items tr {
327 border-bottom: 1px solid ' . $colorTableItems . '
328 }';
329
330 $css .= '.yaymail_builder_bank_details, .yaymail_builder_account_name {
331 color: inherit;
332 display:block;
333 font-family: inherit;
334 font-size:18px;
335 font-weight:bold;
336 line-height:130%;
337 margin:0 0 18px;
338 }';
339
340 $css .= '.yaymail_builder_order {
341 margin-bottom: 0.83em;
342 display:block;
343 font-family: inherit;
344 font-size:18px;
345 font-weight:bold;
346 line-height:130%;
347 margin:0 0 18px;
348 }';
349
350 $css .= 'table.yaymail_builder_table_items tr.order_item ul {
351 font-size: small;
352 margin: 1em 0 0;
353 padding: 0;
354 list-style: none;
355 }';
356
357 $css .= 'table.yaymail_builder_table_items tr.order_item li strong {
358 float:left;
359 margin-right:.25em;
360 clear:both
361 }';
362
363 $css .= 'table.yaymail_builder_table_items tr.order_item li {
364 margin:0.5em 0 0;
365 padding:0;
366 }';
367
368 $css .= 'table.yaymail_builder_table_items tr.order_item li p {
369 margin: 0;
370 }';
371
372 $css .= 'table.yaymail_builder_table_items ul li {
373 list-style: none;
374 margin-left: 0px;
375 }';
376 /* ====== End ====== */
377
378 $css .= 'h3.yaymail_builder_account_name {
379 font-size:16px;
380 }';
381
382 $css .= '.yaymail_builder_order a.yaymail_builder_link {
383 font-weight: normal;
384 text-decoration: underline;
385 }';
386
387 $css .= '.yaymail_builder_order ul {
388 padding-left: 0px
389 }';
390
391 $css .= 'section.yaymail_builder_wrap_account {
392 color: inherit;
393 font-family: inherit;
394 font-size: 14px;
395 line-height: 150%;
396 text-align: left;
397 }';
398
399 $css .= 'section.yaymail_builder_wrap_account ul {
400 color: ' . $colorContentTableItems . ';
401 }';
402
403 $css .= '.yaymail_builder_instructions{
404 color: ' . $colorContentTableItems . ';
405 font-family: inherit;
406 font-size: 14px;
407 line-height: 150%;
408 text-align: left;
409 }';
410
411 // reset css
412 $css .= 'table p {
413 margin: 0px;
414 }';
415
416 $css .= 'table h1, table h2, table h3, table h4, table h5, table h6 {
417 margin: 0px;
418 }';
419
420 $css .= '.yaymail-yith-review-discounts h2 {
421 color: #7f54b3 !important;
422 }';
423
424 $css .= '.yaymail-items-order-border tbody[data-shordcode="yaymail_items_border_content"],
425 .yaymail-items-order-border tbody[data-shordcode="yaymail_items_border_content"]
426 .yaymail_builder_table_items_border {
427 border-color: inherit;
428 flex-direction: inherit;
429 }
430 .yaymail-items-order-border tbody[data-shordcode="yaymail_items_border_content"]
431 .yaymail_builder_table_items_border tbody {
432 flex-direction: inherit;
433 }';
434 // add css for table subcription, item download
435 $css .= 'table.yaymail_builder_table_subcription,
436 table.yaymail_builder_table_tracking_item,
437 table.yaymail_builder_table_item_download,
438 table.yaymail_builder_table_item_subscription,
439 table.yaymail_builder_table_item_multi_vendor {
440 color: inherit;
441 border-width: 1px;
442 border-style: solid;
443 border-color: inherit;
444 }';
445 $css .= '.yaymail-items-order-border span[data-shordcode="yaymail_items_subscription_expired"],
446 .yaymail-items-order-border span[data-shordcode="yaymail_items_subscription_suspended"],
447 .yaymail-items-order-border span[data-shordcode="yaymail_items_subscription_cancelled"],
448 .yaymail-items-order-border span[data-shordcode="yaymail_items_subscription_information"],
449 .yaymail-items-tracking-item span[data-shordcode="yaymail_order_meta:_wc_shipment_tracking_items"],
450 .yaymail-items-item-download span[data-shordcode="yaymail_items_downloadable_product"],
451 .yaymail-items-subscript-border span[data-shordcode="yaymail_subscription_table"]
452 {
453 border-color: inherit;
454 }';
455
456 $css .= '#web-ad422370-f762-4a26-92de-c4cf3821b8eb-order-item .yaymail_items_border_default h2,
457 #web-ad422370-f762-4a26-92de-c4cf3821b8eb-order-item .yaymail_items_border_default h3 {
458 color: #7f54b3;
459 }';
460 $css .= '.yaymail_items_border_custom h2,.yaymail_items_border_custom h3 {
461 color: inherit !important;
462 }';
463 $css .= '.nta-two-column-items table.web-main-row ,
464 .nta-three-column-items table.web-main-row,
465 .nta-four-column-items table.web-main-row
466 {
467 width: 100% !important;
468 }';
469 if ( 'yes' == $enableCustomCss ) {
470 $css .= $custom_css;
471 }
472
473 if ( 'Left' == $orderImagePostions ) {
474 $css .= '.yaymail-product-image{
475 float: left;
476 }';
477 }
478
479 if ( 'Top' == $orderImagePostions ) {
480 $css .= '.yaymail-product-image{
481 float: unset;
482 }';
483 }
484 if ( $productRegularPrice ) {
485 $css .= '.order_item del{
486 opacity: 0.5;
487 }';
488 }
489 $css .= 'a.yaymail-web-button{
490 display: block;
491 }';
492 return $css;
493 }
494 }
495