PluginProbe
YayMail – WooCommerce Email Customizer / 2.1.5
YayMail – WooCommerce Email Customizer v2.1.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 / views / templates / single-mail-template.php

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

251 lines 12.8 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( $template === 'customer_partially_refunded_order') {
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( $cache_path, plugin_dir_path( WC_SC_PLUGIN_FILE ) ) !== false ) {
47 $templateName = str_replace( plugin_dir_path( WC_SC_PLUGIN_FILE ) . 'templates/', '', $cache_path );
48 if ( 'email.php' == $templateName ) {
49 $template = 'wc_sc_email_coupon';
50 }
51 if ( 'combined-email.php' == $templateName ) {
52 $template = 'wc_sc_combined_email_coupon';
53 }
54 if ( 'acknowledgement-email.php' == $templateName ) {
55 $template = 'wc_sc_acknowledgement_email';
56 }
57 }
58 }
59 if ( 'emails/waitlist-mailout.php' == $template_name ) {
60 $template = 'woocommerce_waitlist_mailout';
61 }
62 if ( 'emails/waitlist-left.php' == $template_name ) {
63 $template = 'woocommerce_waitlist_left_email';
64 }
65 if ( 'emails/waitlist-joined.php' == $template_name ) {
66 $template = 'woocommerce_waitlist_joined_email';
67 }
68 if ( 'emails/waitlist-new-signup.php' == $template_name ) {
69 $template = 'woocommerce_waitlist_signup_email';
70 }
71 }
72 if ( isset( $args['email'] ) && isset( $args['email']->id ) && false !== strpos( get_class( $args['email'] ), 'ORDDD_Email_Delivery_Reminder' ) ) {
73 $template .= '_customer';
74 }
75 $custom_shortcode = new YayMail\MailBuilder\Shortcodes( $template );
76 if ( CustomPostType::postIDByTemplate( $template ) ) {
77 $postID = CustomPostType::postIDByTemplate( $template );
78 }
79
80 switch ( $template ) {
81 case 'qwc_req_new_quote':
82 case 'qwc_request_sent':
83 case 'qwc_send_quote':
84 $args['order'] = new WC_Order( $args['order']->order_id );
85 break;
86 default:
87 break;
88 }
89 if ( isset( $args['email'] ) && 'wc_sc_email_coupon' != $template && 'wc_sc_combined_email_coupon' != $template && 'wc_sc_acknowledgement_email' != $template ) {
90 $checkIsSumoTemp = strpos( get_class( $args['email'] ), 'SUMOSubscriptions' );
91 $checkIsQWCTemp = strpos( get_class( $args['email'] ), 'QWC' );
92 } else {
93 $checkIsSumoTemp = false;
94 $checkIsQWCTemp = false;
95 }
96 if ( ( false === $checkIsSumoTemp ) && ( false === $checkIsQWCTemp ) && isset( $args['email'] ) && isset( $args['email']->id ) && ! empty( $args['email']->id ) && isset( $args['order'] ) && $args['order']->get_id() ) {
97 $flag_do_action = true;
98 $custom_shortcode->setOrderId( $args['order']->get_id(), $args['sent_to_admin'], $args );
99 if ( isset( $args['sent_to_admin'] ) ) {
100 if ( 1 === $args['order']->get_id() && false === $args['sent_to_admin'] ) {
101 $custom_shortcode->shortCodesOrderSample();
102 } else {
103 $custom_shortcode->shortCodesOrderDefined( $args['sent_to_admin'], $args );
104 }
105 } else {
106 $custom_shortcode->shortCodesOrderDefined();
107 }
108 } elseif ( $template ) {
109 $flag_do_action = true;
110 if ( 'customer_new_account' === $args['email']->id || 'customer_new_account_activation' === $args['email']->id || 'customer_reset_password' === $args['email']->id ) {
111 $custom_shortcode->setOrderId( 0, $args['sent_to_admin'], $args );
112 $custom_shortcode->shortCodesOrderDefined( $args['sent_to_admin'], $args );
113 } else {
114 $arrData = array( $custom_shortcode, $args, $template );
115 do_action_ref_array( 'yaymail_addon_defined_shorcode', array( &$arrData ) );
116 }
117 // if ( 'cancelled_subscription' === $args['email']->id || 'expired_subscription' === $args['email']->id || 'suspended_subscription' === $args['email']->id ) {
118 // $custom_shortcode->setOrderId( $args['subscription']->data['parent_id'], $args['sent_to_admin'], $args );
119 // $custom_shortcode->shortCodesOrderDefined( $args['sent_to_admin'], $args );
120 // $html = do_shortcode( $html );
121 // }
122 // if ( 'ywsbs_subscription_admin_mail' === $args['email']->id || 'ywsbs_customer_subscription_cancelled' === $args['email']->id || 'ywsbs_customer_subscription_suspended' === $args['email']->id || 'ywsbs_customer_subscription_expired' === $args['email']->id || 'ywsbs_customer_subscription_before_expired' === $args['email']->id || 'ywsbs_customer_subscription_paused' === $args['email']->id || 'ywsbs_customer_subscription_resumed' === $args['email']->id || 'ywsbs_customer_subscription_request_payment' === $args['email']->id || 'ywsbs_customer_subscription_renew_reminder' === $args['email']->id || 'ywsbs_customer_subscription_payment_done' === $args['email']->id || 'ywsbs_customer_subscription_payment_failed' === $args['email']->id ) {
123 // $custom_shortcode->setOrderId( $args['subscription']->order->id, $args['sent_to_admin'], $args );
124 // $custom_shortcode->shortCodesOrderDefined( $args['sent_to_admin'], $args );
125 // $html = do_shortcode( $html );
126 // }
127 // if ( in_array( $template, $templateYITHCommissions ) ) {
128 // if ( isset( $args['commissions'] ) && isset( $args['commissions']->order_id ) ) {
129 // $custom_shortcode->setOrderId( $args['commissions']->order_id, $args['sent_to_admin'], $args );
130 // }
131 // if ( isset( $args['commission'] ) && isset( $args['commission']->order_id ) ) {
132 // $custom_shortcode->setOrderId( $args['commission']->order_id, $args['sent_to_admin'], $args );
133 // }
134 // if ( isset( $args['order_number'] ) ) {
135 // $custom_shortcode->setOrderId( $args['order_number'], $args['sent_to_admin'], $args );
136 // }
137 // $custom_shortcode->shortCodesOrderDefined( $args['sent_to_admin'], $args );
138 // $html = do_shortcode( $html );
139 // }
140 // if ( in_array( $template, $templateGermanizedForWC ) ) {
141 // $custom_shortcode->setOrderId( $args['document']->get_order()->get_order()->id, $args['sent_to_admin'], $args );
142 // $custom_shortcode->shortCodesOrderDefined( $args['sent_to_admin'], $args );
143 // $html = do_shortcode( $html );
144 // }
145 // if ( in_array( $template, $templateYITHWishlist ) ) {
146 // $custom_shortcode->shortCodesOrderDefined( $args['sent_to_admin'], $args, 'not_order' );
147 // $html = do_shortcode( $html );
148 // }
149 // if ( in_array( $template, $templateWooBookings ) ) {
150 // $custom_shortcode->setOrderId( $args['booking']->data['order_id'], false, $args );
151 // $custom_shortcode->shortCodesOrderDefined( false, $args );
152 // $html = do_shortcode( $html );
153 // }
154 }
155
156 if ( $flag_do_action ) {
157 $updateElement = new UpdateElement();
158 $yaymail_elements = get_post_meta( $postID, '_yaymail_elements', true );
159 $yaymail_elements = $updateElement->merge_new_props_to_elements( $yaymail_elements );
160 $yaymail_settings = get_option( 'yaymail_settings' );
161 $emailBackgroundColor = get_post_meta( $postID, '_email_backgroundColor_settings', true ) ? get_post_meta( $postID, '_email_backgroundColor_settings', true ) : '#ECECEC';
162 $general_attrs = array( 'tableWidth' => str_replace( 'px', '', $yaymail_settings['container_width'] ) );
163 ?>
164 <!DOCTYPE html>
165 <html lang="en">
166 <head>
167 <meta charset="UTF-8">
168 <meta http-equiv="X-UA-Compatible" content="IE=edge">
169 <meta name="viewport" content="width=device-width, initial-scale=1"/>
170 <style>
171 h1{ font-family:inherit;text-shadow:unset;text-align:inherit;}
172 h2,h3{ font-family:inherit;color:inherit;text-align:inherit;}
173 </style>
174 </head>
175 <body style="background: <?php echo esc_attr( $emailBackgroundColor ); ?>">
176 <table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
177 <?php
178 foreach ( $yaymail_elements as $key => $element ) {
179 ?>
180 <tr><td>
181 <?php
182 $reg_pattern = '/\[([a-z0-9A-Z_]+)\]/';
183 if ( isset( $element['settingRow']['content'] ) ) {
184 $content = $element['settingRow']['content'];
185 $contentTitle = isset( $element['settingRow']['contentTitle'] ) ? $element['settingRow']['contentTitle'] : '';
186
187 // Add $atts for content if has shortcode
188 preg_match_all( $reg_pattern, $content, $result );
189 if ( ! empty( $result[0] ) ) {
190 foreach ( $result[0] as $key => $shortcode ) {
191 $textcolor = isset( $element['settingRow']['textColor'] ) ? ' textcolor=' . $element['settingRow']['textColor'] : '';
192 $bordercolor = isset( $element['settingRow']['borderColor'] ) ? ' bordercolor=' . $element['settingRow']['borderColor'] : '';
193 $titlecolor = isset( $element['settingRow']['titleColor'] ) ? ' titlecolor=' . $element['settingRow']['titleColor'] : '';
194 $fontfamily = isset( $element['settingRow']['family'] ) ? ' fontfamily=' . str_replace( ' ', '', str_replace( array( '\'', '"' ), '', $element['settingRow']['family'] ) ) : '';
195 $newshortcode = substr( $shortcode, 0, -1 );
196 $newshortcode .= $textcolor . $bordercolor . $titlecolor . $fontfamily . ']';
197 $content = str_replace( $shortcode, $newshortcode, $content );
198 }
199 $element['settingRow']['content'] = $content;
200 }
201 // Add $atts for contentTitle if has shortcode
202 if ( $contentTitle ) {
203 preg_match_all( $reg_pattern, $contentTitle, $result );
204 if ( ! empty( $result[0] ) ) {
205 foreach ( $result[0] as $key => $shortcode ) {
206 $textcolor = isset( $element['settingRow']['textColor'] ) ? ' textcolor=' . $element['settingRow']['textColor'] : '';
207 $bordercolor = isset( $element['settingRow']['borderColor'] ) ? ' bordercolor=' . $element['settingRow']['borderColor'] : '';
208 $titlecolor = isset( $element['settingRow']['titleColor'] ) ? ' titlecolor=' . $element['settingRow']['titleColor'] : '';
209 $fontfamily = isset( $element['settingRow']['family'] ) ? ' fontfamily=' . str_replace( ' ', '', str_replace( array( '\'', '"' ), '', $element['settingRow']['family'] ) ) : '';
210 $newshortcode = substr( $shortcode, 0, -1 );
211 $newshortcode .= $textcolor . $bordercolor . $titlecolor . $fontfamily . ']';
212 $contentTitle = str_replace( $shortcode, $newshortcode, $contentTitle );
213 }
214 $element['settingRow']['contentTitle'] = $contentTitle;
215 }
216 }
217
218 // Add $atts for content of shipment tracking if has shortcode
219 if ( '[yaymail_order_meta:_wc_shipment_tracking_items]' === $content ) {
220 $shortcode = $content;
221 $textcolor = isset( $element['settingRow']['textColor'] ) ? ' textcolor=' . $element['settingRow']['textColor'] : '';
222 $bordercolor = isset( $element['settingRow']['borderColor'] ) ? ' bordercolor=' . $element['settingRow']['borderColor'] : '';
223 $titlecolor = isset( $element['settingRow']['titleColor'] ) ? ' titlecolor=' . $element['settingRow']['titleColor'] : '';
224 $fontfamily = isset( $element['settingRow']['family'] ) ? ' fontfamily=' . str_replace( ' ', '', str_replace( array( '\'', '"' ), '', $element['settingRow']['family'] ) ) : '';
225 $newshortcode = substr( $shortcode, 0, -1 );
226 $newshortcode .= $textcolor . $bordercolor . $titlecolor . $fontfamily . ']';
227 $content = str_replace( $shortcode, $newshortcode, $content );
228 $element['settingRow']['content'] = $content;
229 }
230 }
231 if ( isset( $element['settingRow']['arrConditionLogic'] ) && ! empty( $element['settingRow']['arrConditionLogic'] ) ) {
232 $conditional_Logic = apply_filters( 'yaymail_addon_for_conditional_logic', false, $args, $element['settingRow'] );
233
234 if ( $conditional_Logic ) {
235 do_action( 'Yaymail' . $element['type'], $args, $element['settingRow'], $general_attrs, $element['id'], $postID, $isInColumns = false );
236 }
237 } else {
238 do_action( 'Yaymail' . $element['type'], $args, $element['settingRow'], $general_attrs, $element['id'], $postID, $isInColumns = false );
239 }
240 ?>
241 </td></tr>
242 <?php
243 }
244 ?>
245 </table>
246 </body>
247 </html>
248 <?php
249 }
250
251