PluginProbe
YayMail – WooCommerce Email Customizer / 3.2.7.1
YayMail – WooCommerce Email Customizer v3.2.7.1
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 3.2.7.1, at includes/Templates/Templates.php

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