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

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