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 / views / templates / single-mail-template.php

single-mail-template.php in YayMail – WooCommerce Email Customizer 3.2.2, at views/templates/single-mail-template.php

231 lines 10.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 use YayMail\Page\Source\CustomPostType;
8 use YayMail\Page\Source\UpdateElement;
9 $flag_do_action = false;
10 if ( isset( $args['yith_wc_email'] ) && isset( $args['yith_wc_email']->id ) && ! empty( $args['yith_wc_email']->id ) ) {
11 // Get Email ID in yith-woocommerce-multi-vendor-premium
12 $template = $args['yith_wc_email']->id;
13 } else {
14 $template = isset( $args['email'] ) && isset( $args['email']->id ) && ! empty( $args['email']->id ) ? $args['email']->id : false;
15 if ( 'dokan-wholesale/' == $template_path ) {
16 $template = 'Dokan_Email_Wholesale_Register';
17 }
18 if ( 'emails/admin-notify-approved.php' === $template_name ) {
19 $template = 'admin_notify_approved';
20 }
21 if ( 'customer_partially_refunded_order' === $template ) {
22 $template = 'customer_refunded_order';
23 }
24 if ( 'new-user-registration.php' == $template_name ) {
25 $template = 'wp_crowdfunding_new_user';
26 }
27 if ( 'campaign-accepted.php' == $template_name ) {
28 $template = 'wp_crowdfunding_campaign_accept';
29 }
30 if ( 'submit-campaign.php' == $template_name ) {
31 $template = 'wp_crowdfunding_submit_campaign';
32 }
33 if ( 'campaign-updated.php' == $template_name ) {
34 $template = 'wp_crowdfunding_campaign_update_email';
35 }
36 if ( 'new-backed.php' == $template_name ) {
37 $template = 'wp_crowdfunding_new_backed';
38 }
39 if ( 'campaign-target-reached.php' == $template_name ) {
40 $template = 'wp_crowdfunding_target_reached_email';
41 }
42 if ( 'withdraw-request.php' == $template_name ) {
43 $template = 'wp_crowdfunding_withdraw_request';
44 }
45 if ( class_exists( 'WC_Smart_Coupons' ) ) {
46 if ( isset( $args['email'] ) && strpos( $default_path, plugin_dir_path( WC_SC_PLUGIN_FILE ) ) !== false ) {
47 if ( 'email.php' === $template_name ) {
48 $template = 'wc_sc_email_coupon';
49 }
50 if ( 'combined-email.php' === $template_name ) {
51 $template = 'wc_sc_combined_email_coupon';
52 }
53 if ( 'acknowledgement-email.php' === $template_name ) {
54 $template = 'wc_sc_acknowledgement_email';
55 }
56 }
57 }
58 if ( 'emails/waitlist-mailout.php' == $template_name ) {
59 $template = 'woocommerce_waitlist_mailout';
60 }
61 if ( 'emails/waitlist-left.php' == $template_name ) {
62 $template = 'woocommerce_waitlist_left_email';
63 }
64 if ( 'emails/waitlist-joined.php' == $template_name ) {
65 $template = 'woocommerce_waitlist_joined_email';
66 }
67 if ( 'emails/waitlist-new-signup.php' == $template_name ) {
68 $template = 'woocommerce_waitlist_signup_email';
69 }
70 if ( 'emails/dokan-admin-new-booking.php' == $template_name ) {
71 $template = 'Dokan_Email_Booking_New';
72 }
73 if ( 'emails/dokan-customer-booking-cancelled.php' == $template_name ) {
74 $template = 'Dokan_Email_Booking_Cancelled_NEW';
75 }
76 }
77 if ( isset( $args['email'] ) && isset( $args['email']->id ) && false !== strpos( get_class( $args['email'] ), 'ORDDD_Email_Delivery_Reminder' ) ) {
78 $template .= '_customer';
79 }
80
81 if ( isset( $check_YWCES ) && $check_YWCES ) {
82 $template = 'YWCES_' . $email_template_type;
83 }
84
85 if ( ( 'ywgc-email-send-gift-card' === $template || 'ywgc-email-delivered-gift-card' === $template ) && isset( $args['gift_card'] ) ) {
86 if ( ! empty( $args['gift_card']->order_id ) ) {
87 $args['order'] = wc_get_order( $args['gift_card']->order_id );
88 }
89 }
90
91 $custom_shortcode = new YayMail\MailBuilder\Shortcodes( $template, '', false );
92 if ( CustomPostType::postIDByTemplate( $template ) ) {
93 $postID = CustomPostType::postIDByTemplate( $template );
94 }
95
96 switch ( $template ) {
97 case 'qwc_req_new_quote':
98 case 'qwc_request_sent':
99 case 'qwc_send_quote':
100 $args['order'] = new WC_Order( $args['order']->order_id );
101 break;
102 default:
103 break;
104 }
105 if ( is_object( $args['email'] ) && isset( $args['email'] ) && 'wc_sc_email_coupon' != $template && 'wc_sc_combined_email_coupon' != $template && 'wc_sc_acknowledgement_email' != $template ) {
106 $checkIsSumoTemp = strpos( get_class( $args['email'] ), 'SUMOSubscriptions' );
107 $checkIsQWCTemp = strpos( get_class( $args['email'] ), 'QWC' );
108 } else {
109 $checkIsSumoTemp = false;
110 $checkIsQWCTemp = false;
111 }
112 if ( ( false === $checkIsSumoTemp ) && ( false === $checkIsQWCTemp ) && isset( $args['email'] ) && isset( $args['email']->id ) && ! empty( $args['email']->id ) && isset( $args['order'] ) && $args['order']->get_id() ) {
113 $flag_do_action = true;
114 $custom_shortcode->setOrderId( $args['order']->get_id(), $args['sent_to_admin'], $args );
115 if ( isset( $args['sent_to_admin'] ) ) {
116 if ( 1 === $args['order']->get_id() && false === $args['sent_to_admin'] ) {
117 $custom_shortcode->shortCodesOrderSample();
118 } else {
119 $custom_shortcode->shortCodesOrderDefined( $args['sent_to_admin'], $args );
120 }
121 } else {
122 $custom_shortcode->shortCodesOrderDefined();
123 }
124 } elseif ( $template ) {
125 $flag_do_action = true;
126 if ( isset( $args['email'] ) && isset( $args['email']->id ) && ( 'customer_new_account' === $args['email']->id || 'customer_new_account_activation' === $args['email']->id || 'customer_reset_password' === $args['email']->id ) ) {
127 $custom_shortcode->setOrderId( 0, $args['sent_to_admin'], $args );
128 $custom_shortcode->shortCodesOrderDefined( $args['sent_to_admin'], $args );
129 } else {
130 $arrData = array( $custom_shortcode, $args, $template );
131 do_action_ref_array( 'yaymail_addon_defined_shorcode', array( &$arrData ) );
132 }
133 }
134
135 if ( $flag_do_action ) {
136 $updateElement = new UpdateElement();
137 $yaymail_elements = get_post_meta( $postID, '_yaymail_elements', true );
138 $yaymail_elements = $updateElement->merge_new_props_to_elements( $yaymail_elements );
139 $yaymail_template = get_post_meta( $postID, '_yaymail_template', true );
140 $yaymail_settings = get_option( 'yaymail_settings' );
141 $emailBackgroundColor = get_post_meta( $postID, '_email_backgroundColor_settings', true ) ? get_post_meta( $postID, '_email_backgroundColor_settings', true ) : '#ECECEC';
142 $general_attrs = array( 'tableWidth' => str_replace( 'px', '', $yaymail_settings['container_width'] ) );
143 ?>
144 <!DOCTYPE html>
145 <html lang="en">
146 <head>
147 <meta charset="UTF-8">
148 <meta http-equiv="X-UA-Compatible" content="IE=edge">
149 <meta name="viewport" content="width=device-width, initial-scale=1"/>
150 <style>
151 h1{ font-family:inherit;text-shadow:unset;text-align:inherit;}
152 h2,h3{ font-family:inherit;color:inherit;text-align:inherit;}
153 </style>
154 </head>
155 <body style="background: <?php echo esc_attr( $emailBackgroundColor ); ?>">
156 <table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%" class="<?php echo esc_attr( 'yaymail-template-' . $yaymail_template ); ?>">
157 <?php
158 foreach ( $yaymail_elements as $key => $element ) {
159 ?>
160 <tr><td>
161 <?php
162 $reg_pattern = '/\[([a-z0-9A-Z_]+)\]/';
163 if ( isset( $element['settingRow']['content'] ) ) {
164 $content = $element['settingRow']['content'];
165 $contentTitle = isset( $element['settingRow']['contentTitle'] ) ? $element['settingRow']['contentTitle'] : '';
166
167 // Add $atts for content if has shortcode
168 preg_match_all( $reg_pattern, $content, $result );
169 if ( ! empty( $result[0] ) ) {
170 foreach ( $result[0] as $key => $shortcode ) {
171 $textcolor = isset( $element['settingRow']['textColor'] ) ? ' textcolor=' . $element['settingRow']['textColor'] : '';
172 $bordercolor = isset( $element['settingRow']['borderColor'] ) ? ' bordercolor=' . $element['settingRow']['borderColor'] : '';
173 $titlecolor = isset( $element['settingRow']['titleColor'] ) ? ' titlecolor=' . $element['settingRow']['titleColor'] : '';
174 $fontfamily = isset( $element['settingRow']['family'] ) ? ' fontfamily=' . str_replace( ' ', '', str_replace( array( '\'', '"' ), '', $element['settingRow']['family'] ) ) : '';
175 $newshortcode = substr( $shortcode, 0, -1 );
176 $newshortcode .= $textcolor . $bordercolor . $titlecolor . $fontfamily . ']';
177 $content = str_replace( $shortcode, $newshortcode, $content );
178 }
179 $element['settingRow']['content'] = $content;
180 }
181 // Add $atts for contentTitle if has shortcode
182 if ( $contentTitle ) {
183 preg_match_all( $reg_pattern, $contentTitle, $result );
184 if ( ! empty( $result[0] ) ) {
185 foreach ( $result[0] as $key => $shortcode ) {
186 $textcolor = isset( $element['settingRow']['textColor'] ) ? ' textcolor=' . $element['settingRow']['textColor'] : '';
187 $bordercolor = isset( $element['settingRow']['borderColor'] ) ? ' bordercolor=' . $element['settingRow']['borderColor'] : '';
188 $titlecolor = isset( $element['settingRow']['titleColor'] ) ? ' titlecolor=' . $element['settingRow']['titleColor'] : '';
189 $fontfamily = isset( $element['settingRow']['family'] ) ? ' fontfamily=' . str_replace( ' ', '', str_replace( array( '\'', '"' ), '', $element['settingRow']['family'] ) ) : '';
190 $newshortcode = substr( $shortcode, 0, -1 );
191 $newshortcode .= $textcolor . $bordercolor . $titlecolor . $fontfamily . ']';
192 $contentTitle = str_replace( $shortcode, $newshortcode, $contentTitle );
193 }
194 $element['settingRow']['contentTitle'] = $contentTitle;
195 }
196 }
197
198 // Add $atts for content of shipment tracking if has shortcode
199 if ( '[yaymail_order_meta:_wc_shipment_tracking_items]' === $content ) {
200 $shortcode = $content;
201 $textcolor = isset( $element['settingRow']['textColor'] ) ? ' textcolor=' . $element['settingRow']['textColor'] : '';
202 $bordercolor = isset( $element['settingRow']['borderColor'] ) ? ' bordercolor=' . $element['settingRow']['borderColor'] : '';
203 $titlecolor = isset( $element['settingRow']['titleColor'] ) ? ' titlecolor=' . $element['settingRow']['titleColor'] : '';
204 $fontfamily = isset( $element['settingRow']['family'] ) ? ' fontfamily=' . str_replace( ' ', '', str_replace( array( '\'', '"' ), '', $element['settingRow']['family'] ) ) : '';
205 $newshortcode = substr( $shortcode, 0, -1 );
206 $newshortcode .= $textcolor . $bordercolor . $titlecolor . $fontfamily . ']';
207 $content = str_replace( $shortcode, $newshortcode, $content );
208 $element['settingRow']['content'] = $content;
209 }
210 }
211 if ( has_filter( 'yaymail_addon_for_conditional_logic' ) && isset( $element['settingRow']['arrConditionLogic'] ) && ! empty( $element['settingRow']['arrConditionLogic'] ) ) {
212 $conditional_Logic = apply_filters( 'yaymail_addon_for_conditional_logic', false, $args, $element['settingRow'] );
213
214 if ( $conditional_Logic ) {
215 do_action( 'Yaymail' . $element['type'], $args, $element['settingRow'], $general_attrs, $element['id'], $postID, $isInColumns = false );
216 }
217 } else {
218 do_action( 'Yaymail' . $element['type'], $args, $element['settingRow'], $general_attrs, $element['id'], $postID, $isInColumns = false );
219 }
220 ?>
221 </td></tr>
222 <?php
223 }
224 ?>
225 </table>
226 </body>
227 </html>
228 <?php
229 }
230
231