PluginProbe
YayMail – WooCommerce Email Customizer / 3.3.5
YayMail – WooCommerce Email Customizer v3.3.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
yaymail / includes / Templates / Templates.php

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

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