PluginProbe
YayMail – WooCommerce Email Customizer / 3.2.6
YayMail – WooCommerce Email Customizer v3.2.6
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 3.2.6, at views/templates/single-mail-template.php

252 lines 12.1 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( $args['email'] ) && is_object( $args['email'] ) && 'WC_GZD_Email_Customer_Cancelled_Order' === get_class( $args['email'] ) && 'customer_failed_order' === $template ) {
82 $template = 'customer_cancelled_order';
83 }
84
85 if ( isset( $check_YWCES ) && $check_YWCES ) {
86 $template = 'YWCES_' . $email_template_type;
87 }
88
89 if ( ( 'ywgc-email-send-gift-card' === $template || 'ywgc-email-delivered-gift-card' === $template ) && isset( $args['gift_card'] ) ) {
90 if ( ! empty( $args['gift_card']->order_id ) ) {
91 $args['order'] = wc_get_order( $args['gift_card']->order_id );
92 }
93 }
94
95 $custom_shortcode = new YayMail\MailBuilder\Shortcodes( $template, '', false );
96 if ( CustomPostType::postIDByTemplate( $template ) ) {
97 $postID = CustomPostType::postIDByTemplate( $template );
98 }
99
100 switch ( $template ) {
101 case 'qwc_req_new_quote':
102 case 'qwc_request_sent':
103 case 'qwc_send_quote':
104 $args['order'] = new WC_Order( $args['order']->order_id );
105 break;
106 default:
107 break;
108 }
109 if ( is_object( $args['email'] ) && isset( $args['email'] ) && 'wc_sc_email_coupon' != $template && 'wc_sc_combined_email_coupon' != $template && 'wc_sc_acknowledgement_email' != $template ) {
110 $checkIsSumoTemp = strpos( get_class( $args['email'] ), 'SUMOSubscriptions' );
111 $checkIsQWCTemp = strpos( get_class( $args['email'] ), 'QWC' );
112 } else {
113 $checkIsSumoTemp = false;
114 $checkIsQWCTemp = false;
115 }
116 if ( ( false === $checkIsSumoTemp ) && ( false === $checkIsQWCTemp ) && isset( $args['email'] ) && isset( $args['email']->id ) && ! empty( $args['email']->id ) && isset( $args['order'] ) && $args['order']->get_id() ) {
117 $flag_do_action = true;
118 $custom_shortcode->setOrderId( $args['order']->get_id(), $args['sent_to_admin'], $args );
119 if ( isset( $args['sent_to_admin'] ) ) {
120 if ( 1 === $args['order']->get_id() && false === $args['sent_to_admin'] ) {
121 $custom_shortcode->shortCodesOrderSample();
122 } else {
123 $custom_shortcode->shortCodesOrderDefined( $args['sent_to_admin'], $args );
124 }
125 } else {
126 $custom_shortcode->shortCodesOrderDefined();
127 }
128 } elseif ( $template ) {
129 $flag_do_action = true;
130 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 ) ) {
131 $custom_shortcode->setOrderId( 0, $args['sent_to_admin'], $args );
132 $custom_shortcode->shortCodesOrderDefined( $args['sent_to_admin'], $args );
133 } else {
134 $arrData = array( $custom_shortcode, $args, $template );
135 do_action_ref_array( 'yaymail_addon_defined_shorcode', array( &$arrData ) );
136 }
137 }
138
139 if ( $flag_do_action ) {
140 $updateElement = new UpdateElement();
141 $yaymail_elements = get_post_meta( $postID, '_yaymail_elements', true );
142 $yaymail_elements = $updateElement->merge_new_props_to_elements( $yaymail_elements );
143 $yaymail_template = get_post_meta( $postID, '_yaymail_template', true );
144 $yaymail_settings = get_option( 'yaymail_settings' );
145 $emailBackgroundColor = get_post_meta( $postID, '_email_backgroundColor_settings', true ) ? get_post_meta( $postID, '_email_backgroundColor_settings', true ) : '#ECECEC';
146 $general_attrs = array( 'tableWidth' => str_replace( 'px', '', $yaymail_settings['container_width'] ) );
147 ?>
148 <!DOCTYPE html>
149 <html lang="en">
150 <head>
151 <meta charset="UTF-8">
152 <meta http-equiv="X-UA-Compatible" content="IE=edge">
153 <meta name="viewport" content="width=device-width, initial-scale=1"/>
154 <style>
155 h1{ font-family:inherit;text-shadow:unset;text-align:inherit;}
156 h2,h3{ font-family:inherit;color:inherit;text-align:inherit;}
157 </style>
158 </head>
159 <body style="background: <?php echo esc_attr( $emailBackgroundColor ); ?>">
160 <table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%" class="<?php echo esc_attr( 'yaymail-template-' . $yaymail_template ); ?>">
161 <?php
162 foreach ( $yaymail_elements as $key => $element ) {
163 ?>
164 <tr><td>
165 <?php
166 $reg_pattern = '/\[([a-z0-9A-Z_]+)\]/';
167 if ( isset( $element['settingRow']['content'] ) ) {
168 $content = $element['settingRow']['content'];
169 $contentTitle = isset( $element['settingRow']['contentTitle'] ) ? $element['settingRow']['contentTitle'] : '';
170
171 // Add $atts for content if has shortcode
172 preg_match_all( $reg_pattern, $content, $result );
173 if ( ! empty( $result[0] ) ) {
174 foreach ( $result[0] as $key => $shortcode ) {
175 $textcolor = isset( $element['settingRow']['textColor'] ) ? ' textcolor=' . $element['settingRow']['textColor'] : '';
176 $bordercolor = isset( $element['settingRow']['borderColor'] ) ? ' bordercolor=' . $element['settingRow']['borderColor'] : '';
177 $titlecolor = isset( $element['settingRow']['titleColor'] ) ? ' titlecolor=' . $element['settingRow']['titleColor'] : '';
178 $fontfamily = isset( $element['settingRow']['family'] ) ? ' fontfamily=' . str_replace( ' ', '', str_replace( array( '\'', '"' ), '', $element['settingRow']['family'] ) ) : '';
179 $newshortcode = substr( $shortcode, 0, -1 );
180 $newshortcode .= $textcolor . $bordercolor . $titlecolor . $fontfamily . ']';
181 $content = str_replace( $shortcode, $newshortcode, $content );
182 }
183 $element['settingRow']['content'] = $content;
184 }
185 // Add $atts for contentTitle if has shortcode
186 if ( $contentTitle ) {
187 preg_match_all( $reg_pattern, $contentTitle, $result );
188 if ( ! empty( $result[0] ) ) {
189 foreach ( $result[0] as $key => $shortcode ) {
190 $textcolor = isset( $element['settingRow']['textColor'] ) ? ' textcolor=' . $element['settingRow']['textColor'] : '';
191 $bordercolor = isset( $element['settingRow']['borderColor'] ) ? ' bordercolor=' . $element['settingRow']['borderColor'] : '';
192 $titlecolor = isset( $element['settingRow']['titleColor'] ) ? ' titlecolor=' . $element['settingRow']['titleColor'] : '';
193 $fontfamily = isset( $element['settingRow']['family'] ) ? ' fontfamily=' . str_replace( ' ', '', str_replace( array( '\'', '"' ), '', $element['settingRow']['family'] ) ) : '';
194 $newshortcode = substr( $shortcode, 0, -1 );
195 $newshortcode .= $textcolor . $bordercolor . $titlecolor . $fontfamily . ']';
196 $contentTitle = str_replace( $shortcode, $newshortcode, $contentTitle );
197 }
198 $element['settingRow']['contentTitle'] = $contentTitle;
199 }
200 }
201
202 // Add $atts for content of shipment tracking if has shortcode
203 if ( '[yaymail_order_meta:_wc_shipment_tracking_items]' === $content ) {
204 $shortcode = $content;
205 $textcolor = isset( $element['settingRow']['textColor'] ) ? ' textcolor=' . $element['settingRow']['textColor'] : '';
206 $bordercolor = isset( $element['settingRow']['borderColor'] ) ? ' bordercolor=' . $element['settingRow']['borderColor'] : '';
207 $titlecolor = isset( $element['settingRow']['titleColor'] ) ? ' titlecolor=' . $element['settingRow']['titleColor'] : '';
208 $fontfamily = isset( $element['settingRow']['family'] ) ? ' fontfamily=' . str_replace( ' ', '', str_replace( array( '\'', '"' ), '', $element['settingRow']['family'] ) ) : '';
209 $newshortcode = substr( $shortcode, 0, -1 );
210 $newshortcode .= $textcolor . $bordercolor . $titlecolor . $fontfamily . ']';
211 $content = str_replace( $shortcode, $newshortcode, $content );
212 $element['settingRow']['content'] = $content;
213 }
214 }
215 if ( has_filter( 'yaymail_addon_for_conditional_logic' ) && isset( $element['settingRow']['arrConditionLogic'] ) ) {
216 if ( ! empty( $element['settingRow']['arrConditionLogic'] ) ) {
217 $conditional_Logic = apply_filters( 'yaymail_addon_for_conditional_logic', false, $args, $element['settingRow'] );
218 if ( $conditional_Logic ) {
219 do_action( 'Yaymail' . $element['type'], $args, $element['settingRow'], $general_attrs, $element['id'], $postID, $isInColumns = false );
220 }
221 } else {
222 if ( 'OneColumn' === $element['type'] || 'TwoColumns' === $element['type'] || 'ThreeColumns' === $element['type'] || 'FourColumns' === $element['type'] ) {
223 for ( $column = 1; $column <= 4; $column++ ) {
224 if ( isset( $element['settingRow'][ 'column' . $column ] ) ) {
225 foreach ( $element['settingRow'][ 'column' . $column ] as $column_key => $column_element ) {
226 if ( isset( $column_element['settingRow']['arrConditionLogic'] ) && ! empty( $column_element['settingRow']['arrConditionLogic'] ) ) {
227 $conditional_Logic = apply_filters( 'yaymail_addon_for_conditional_logic', false, $args, $column_element['settingRow'] );
228 if ( ! $conditional_Logic ) {
229 unset( $element['settingRow'][ 'column' . $column ][ $column_key ] );
230 }
231 }
232 }
233 }
234 }
235 }
236 do_action( 'Yaymail' . $element['type'], $args, $element['settingRow'], $general_attrs, $element['id'], $postID, $isInColumns = false );
237 }
238 } else {
239 do_action( 'Yaymail' . $element['type'], $args, $element['settingRow'], $general_attrs, $element['id'], $postID, $isInColumns = false );
240 }
241 ?>
242 </td></tr>
243 <?php
244 }
245 ?>
246 </table>
247 </body>
248 </html>
249 <?php
250 }
251
252