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

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