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

483 lines 16.8 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 .= 'table.yaymail_builder_table_items_content tbody tr td, table.yaymail_builder_table_items_content tbody tr th {
154 vertical-align:middle;
155 padding:12px;
156 text-align:left;
157 font-size: 14px;
158 border-width: 1px;
159 border-style: solid;
160 border-color: inherit;
161 }';
162 $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 {
163 border-color: inherit;
164 }';
165
166 $css .= 'table.yaymail_builder_table_items_border img {
167 max-width: 100%;
168 }';
169
170 $css .= 'table.yaymail_builder_table_items_border thead {
171 border-width: 1px;
172 border-style: solid;
173 border-color: inherit
174 }';
175
176 $css .= 'table.yaymail_builder_table_items_border thead tr {
177 border-width: 1px;
178 border-style: solid;
179 border-color: inherit
180 }';
181
182 $css .= 'table.yaymail_builder_table_items_border thead tr th {
183 vertical-align:middle;
184 padding:12px;
185 text-align:left;
186 font-family: inherit;
187 font-size: 14px;
188 border-width: 1px;
189 border-style: solid;
190 border-color: inherit
191 }';
192
193 $css .= 'table.yaymail_builder_table_items_border tbody {
194 border-width: 1px;
195 border-style: solid;
196 border-color: inherit
197 }';
198
199 $css .= 'table.yaymail_builder_table_items_border tbody tr {
200 border-width: 1px;
201 border-style: solid;
202 border-color: inherit
203 }';
204
205 $css .= 'table.yaymail_builder_table_items_border tbody tr td {
206 padding:12px;
207 text-align:left;
208 vertical-align:middle;
209 font-family: inherit;
210 word-break:normal;
211 font-size: 14px;
212 border-width: 1px;
213 border-style: solid;
214 border-color: inherit
215 }';
216
217 $css .= 'table.yaymail_builder_table_items_border tfoot {
218 border-width: 1px;
219 border-style: solid;
220 border-color: inherit
221 }';
222
223 $css .= 'table.yaymail_builder_table_items_border tfoot tr {
224 border-width: 1px;
225 border-style: solid;
226 border-color: inherit
227 }';
228
229 $css .= 'table.yaymail_builder_table_items_border tfoot tr td {
230 vertical-align:middle;
231 padding:12px;
232 text-align:left;
233 font-family: inherit;
234 font-size: 14px;
235 border-width: 1px;
236 border-style: solid;
237 border-color: inherit
238 }';
239
240 $css .= ' table.yaymail_builder_table_items_border tfoot tr th {
241 vertical-align:middle;
242 padding:12px;
243 text-align:left;
244 font-size: 14px;
245 border-width: 1px;
246 border-style: solid;
247 border-color: inherit
248 }';
249
250 $css .= 'table.yaymail_builder_table_items_border tr.order_item ul {
251 font-size: small;
252 margin: 1em 0 0;
253 padding: 0;
254 list-style: none;
255 }';
256
257 $css .= 'table.yaymail_builder_table_items_border tr.order_item li strong {
258 float:left;
259 margin-right:.25em;
260 clear:both;
261 }';
262
263 $css .= 'table.yaymail_builder_table_items_border tr.order_item li {
264 margin:0.5em 0 0;
265 padding:0;
266 }';
267
268 $css .= 'table.yaymail_builder_table_items_border tr.order_item li p {
269 margin: 0;
270 }';
271
272 $css .= '.yaymail-product-sku{
273 word-break: break-word;
274 }';
275
276 $css .= '.yaymail-sup-infor{
277 white-space: nowrap;
278 }';
279 /* ====== End ====== */
280
281 /*
282 ======
283 @@@ Start css for shortcode [yaymail_items]
284 @@@ note: use for table not border
285 ====== */
286 $css .= 'table.yaymail_builder_table_items {
287 border-collapse: collapse !important;
288 width: 100%;
289 color:' . $colorContentTableItems . ';
290 }';
291
292 $css .= 'table.yaymail_builder_table_items img {
293 max-width: 100%
294 }';
295
296 $css .= 'table.yaymail_builder_table_items tbody tr,
297 table.yaymail_builder_table_items tbody tr td,
298 table.yaymail_builder_table_items thead tr,
299 table.yaymail_builder_table_items thead tr th,
300 table.yaymail_builder_table_items thead tr td,
301 table.yaymail_builder_table_items tfoot tr,
302 table.yaymail_builder_table_items tfoot tr th,
303 table.yaymail_builder_table_items tfoot tr td {
304 vertical-align:middle;
305 padding:12px;
306 text-align:left;
307 font-size:14px;
308 }';
309
310 $css .= 'table td {
311 font-family: inherit;
312 }';
313
314 $css .= 'table.yaymail_builder_table_items tr {
315 border-bottom: 1px solid ' . $colorTableItems . '
316 }';
317
318 $css .= '.yaymail_builder_bank_details, .yaymail_builder_account_name {
319 color: inherit;
320 display:block;
321 font-family: inherit;
322 font-size:18px;
323 font-weight:bold;
324 line-height:130%;
325 margin:0 0 18px;
326 }';
327
328 $css .= '.yaymail_builder_order {
329 margin-bottom: 0.83em;
330 display:block;
331 font-family: inherit;
332 font-size:18px;
333 font-weight:bold;
334 line-height:130%;
335 margin:0 0 18px;
336 }';
337
338 $css .= 'table.yaymail_builder_table_items tr.order_item ul {
339 font-size: small;
340 margin: 1em 0 0;
341 padding: 0;
342 list-style: none;
343 }';
344
345 $css .= 'table.yaymail_builder_table_items tr.order_item li strong {
346 float:left;
347 margin-right:.25em;
348 clear:both
349 }';
350
351 $css .= 'table.yaymail_builder_table_items tr.order_item li {
352 margin:0.5em 0 0;
353 padding:0;
354 }';
355
356 $css .= 'table.yaymail_builder_table_items tr.order_item li p {
357 margin: 0;
358 }';
359
360 $css .= 'table.yaymail_builder_table_items ul li {
361 list-style: none;
362 margin-left: 0px;
363 }';
364 /* ====== End ====== */
365
366 $css .= 'h3.yaymail_builder_account_name {
367 font-size:16px;
368 }';
369
370 $css .= '.yaymail_builder_order a.yaymail_builder_link {
371 font-weight: normal;
372 text-decoration: underline;
373 }';
374
375 $css .= '.yaymail_builder_order ul {
376 padding-left: 0px
377 }';
378
379 $css .= 'section.yaymail_builder_wrap_account {
380 color: inherit;
381 font-family: inherit;
382 font-size: 14px;
383 line-height: 150%;
384 text-align: left;
385 }';
386
387 $css .= 'section.yaymail_builder_wrap_account ul {
388 color: ' . $colorContentTableItems . ';
389 }';
390
391 $css .= '.yaymail_builder_instructions{
392 color: ' . $colorContentTableItems . ';
393 font-family: inherit;
394 font-size: 14px;
395 line-height: 150%;
396 text-align: left;
397 }';
398
399 // reset css
400 $css .= 'table p {
401 margin: 0px;
402 }';
403
404 $css .= 'table h1, table h2, table h3, table h4, table h5, table h6 {
405 margin: 0px;
406 }';
407
408 $css .= '.yaymail-yith-review-discounts h2 {
409 color: #7f54b3 !important;
410 }';
411
412 $css .= '.yaymail-items-order-border tbody[data-shordcode="yaymail_items_border_content"],
413 .yaymail-items-order-border tbody[data-shordcode="yaymail_items_border_content"]
414 .yaymail_builder_table_items_border {
415 border-color: inherit;
416 flex-direction: inherit;
417 }
418 .yaymail-items-order-border tbody[data-shordcode="yaymail_items_border_content"]
419 .yaymail_builder_table_items_border tbody {
420 flex-direction: inherit;
421 }';
422 // add css for table subcription, item download
423 $css .= 'table.yaymail_builder_table_subcription,
424 table.yaymail_builder_table_tracking_item,
425 table.yaymail_builder_table_item_download,
426 table.yaymail_builder_table_item_subscription,
427 table.yaymail_builder_table_item_multi_vendor {
428 color: inherit;
429 border-width: 1px;
430 border-style: solid;
431 border-color: inherit;
432 }';
433 $css .= '.yaymail-items-order-border span[data-shordcode="yaymail_items_subscription_expired"],
434 .yaymail-items-order-border span[data-shordcode="yaymail_items_subscription_suspended"],
435 .yaymail-items-order-border span[data-shordcode="yaymail_items_subscription_cancelled"],
436 .yaymail-items-order-border span[data-shordcode="yaymail_items_subscription_information"],
437 .yaymail-items-tracking-item span[data-shordcode="yaymail_order_meta:_wc_shipment_tracking_items"],
438 .yaymail-items-item-download span[data-shordcode="yaymail_items_downloadable_product"],
439 .yaymail-items-subscript-border span[data-shordcode="yaymail_subscription_table"]
440 {
441 border-color: inherit;
442 }';
443
444 $css .= '#web-ad422370-f762-4a26-92de-c4cf3821b8eb-order-item .yaymail_items_border_default h2,
445 #web-ad422370-f762-4a26-92de-c4cf3821b8eb-order-item .yaymail_items_border_default h3 {
446 color: #7f54b3;
447 }';
448 $css .= '.yaymail_items_border_custom h2,.yaymail_items_border_custom h3 {
449 color: inherit !important;
450 }';
451 $css .= '.nta-two-column-items table.web-main-row ,
452 .nta-three-column-items table.web-main-row,
453 .nta-four-column-items table.web-main-row
454 {
455 width: 100% !important;
456 }';
457 if ( 'yes' == $enableCustomCss ) {
458 $css .= $custom_css;
459 }
460
461 if ( 'Left' == $orderImagePostions ) {
462 $css .= '.yaymail-product-image{
463 float: left;
464 }';
465 }
466
467 if ( 'Top' == $orderImagePostions ) {
468 $css .= '.yaymail-product-image{
469 float: unset;
470 }';
471 }
472 if ( $productRegularPrice ) {
473 $css .= '.order_item del{
474 opacity: 0.5;
475 }';
476 }
477 $css .= 'a.yaymail-web-button{
478 display: block;
479 }';
480 return $css;
481 }
482 }
483