PluginProbe
YayMail – WooCommerce Email Customizer / 2.1.4
YayMail – WooCommerce Email Customizer v2.1.4
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.4, at views/templates/single-mail-template.php

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