Changeset 2785694
- Timestamp:
- 09/16/2022 03:31:30 AM (4 years ago)
- Location:
- email-creatior/trunk
- Files:
-
- 5 edited
-
README.md (modified) (1 diff)
-
emailcreator.php (modified) (2 diffs)
-
src/Email/Controllers/EmailController.php (modified) (1 diff)
-
src/Email/Controllers/ReplaceEmailController.php (modified) (12 diffs)
-
src/Shared/GetFieldPlaceholderSubjectEmail.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
email-creatior/trunk/README.md
r2779503 r2785694 6 6 Tested up to: 6.0.1 7 7 Requires PHP: 7.4 8 Stable tag: 1.0. 88 Stable tag: 1.0.9 9 9 License: GPLv2 or later 10 10 -
email-creatior/trunk/emailcreator.php
r2779503 r2785694 5 5 * Author: wiloke 6 6 * Author URI: https://wiloke.com/ 7 * Version: 1.0. 87 * Version: 1.0.9 8 8 * Domain Path: /languages 9 9 * Requires PHP: 7.4 … … 17 17 18 18 19 define('WILOKE_EMAIL_CREATOR_VERSION', defined('WP_DEBUG') && WP_DEBUG ? uniqid() : '1.0. 8');19 define('WILOKE_EMAIL_CREATOR_VERSION', defined('WP_DEBUG') && WP_DEBUG ? uniqid() : '1.0.9'); 20 20 define('WILOKE_EMAIL_CREATOR_HOOK_PREFIX', ' wiloke-email-creator/'); 21 21 define('WILOKE_EMAIL_CREATOR_PREFIX', 'wilETP_'); -
email-creatior/trunk/src/Email/Controllers/EmailController.php
r2779511 r2785694 299 299 } 300 300 301 public function actionSendEmail($email, $subject, $body, $aHeader 301 public function actionSendEmail( 302 $email, $subject, $body, $aHeader 302 303 = [ 303 304 'Content-Type: text/html; charset=UTF-8' 304 ]) 305 { 306 return wp_mail(sanitize_email($email), $subject, $body, $aHeader); 305 ] 306 ) 307 { 308 return wp_mail( 309 sanitize_email($email), 310 wp_kses(html_entity_decode(wp_unslash($subject)), [ 311 "img" => [ 312 "src" => true, 313 "alt" => true, 314 "class" => true, 315 "aria-label" => true, 316 "loading" => true 317 ] 318 ]), 319 $body, 320 $aHeader 321 ); 307 322 } 308 323 } -
email-creatior/trunk/src/Email/Controllers/ReplaceEmailController.php
r2779503 r2785694 226 226 } 227 227 228 private function replaceEmailSubjectCommon($postID, array $aVariables, $oldSubject) 229 { 230 $emailSubject = get_post_meta($postID, AutoPrefix::namePrefix('emailSubject'), true); 231 if (empty($emailSubject)) { 232 return $oldSubject; 233 } 234 235 return str_replace(array_keys($aVariables), array_values($aVariables), $emailSubject); 236 } 237 228 238 public function replaceSubjectNewOrder($subject, $oOrder) 229 239 { … … 231 241 $aKeyEmailType = $this->handleListKeyEmailTypeUsedUser(); 232 242 if ($postID = (int)array_search('new_order', $aKeyEmailType)) { 233 $emailSubject = get_post_meta($postID, AutoPrefix::namePrefix('emailSubject'), true); 234 $subject = str_replace(array_keys($aVariables), array_values($aVariables), $emailSubject); 243 return $this->replaceEmailSubjectCommon($postID, $aVariables, $subject); 235 244 } 236 245 … … 243 252 $aKeyEmailType = $this->handleListKeyEmailTypeUsedUser(); 244 253 if ($postID = (int)array_search('cancelled_order', $aKeyEmailType)) { 245 $emailSubject = get_post_meta($postID, AutoPrefix::namePrefix('emailSubject'), true); 246 $subject = str_replace(array_keys($aVariables), array_values($aVariables), $emailSubject); 254 return $this->replaceEmailSubjectCommon($postID, $aVariables, $subject); 247 255 } 248 256 return $subject; … … 254 262 $aKeyEmailType = $this->handleListKeyEmailTypeUsedUser(); 255 263 if ($postID = (int)array_search('failed_order', $aKeyEmailType)) { 256 $emailSubject = get_post_meta($postID, AutoPrefix::namePrefix('emailSubject'), true); 257 $subject = str_replace(array_keys($aVariables), array_values($aVariables), $emailSubject); 264 return $this->replaceEmailSubjectCommon($postID, $aVariables, $subject); 258 265 } 259 266 return $subject; … … 265 272 $aKeyEmailType = $this->handleListKeyEmailTypeUsedUser(); 266 273 if ($postID = (int)array_search('customer_on_hold_order', $aKeyEmailType)) { 267 $emailSubject = get_post_meta($postID, AutoPrefix::namePrefix('emailSubject'), true); 268 $subject = str_replace(array_keys($aVariables), array_values($aVariables), $emailSubject); 274 return $this->replaceEmailSubjectCommon($postID, $aVariables, $subject); 269 275 } 270 276 return $subject; … … 276 282 $aKeyEmailType = $this->handleListKeyEmailTypeUsedUser(); 277 283 if ($postID = (int)array_search('customer_processing_order', $aKeyEmailType)) { 278 $emailSubject = get_post_meta($postID, AutoPrefix::namePrefix('emailSubject'), true); 279 $subject = str_replace(array_keys($aVariables), array_values($aVariables), $emailSubject); 284 return $this->replaceEmailSubjectCommon($postID, $aVariables, $subject); 280 285 } 281 286 return $subject; … … 287 292 $aKeyEmailType = $this->handleListKeyEmailTypeUsedUser(); 288 293 if ($postID = (int)array_search('customer_completed_order', $aKeyEmailType)) { 289 $emailSubject = get_post_meta($postID, AutoPrefix::namePrefix('emailSubject'), true); 290 $subject = str_replace(array_keys($aVariables), array_values($aVariables), $emailSubject); 294 return $this->replaceEmailSubjectCommon($postID, $aVariables, $subject); 291 295 } 292 296 return $subject; … … 298 302 $aKeyEmailType = $this->handleListKeyEmailTypeUsedUser(); 299 303 if ($postID = (int)array_search('customer_refunded_order', $aKeyEmailType)) { 300 $emailSubject = get_post_meta($postID, AutoPrefix::namePrefix('emailSubject'), true); 301 $subject = str_replace(array_keys($aVariables), array_values($aVariables), $emailSubject); 304 return $this->replaceEmailSubjectCommon($postID, $aVariables, $subject); 302 305 } 303 306 return $subject; … … 309 312 $aKeyEmailType = $this->handleListKeyEmailTypeUsedUser(); 310 313 if ($postID = (int)array_search('customer_invoice', $aKeyEmailType)) { 311 $emailSubject = get_post_meta($postID, AutoPrefix::namePrefix('emailSubject'), true); 312 $subject = str_replace(array_keys($aVariables), array_values($aVariables), $emailSubject); 314 return $this->replaceEmailSubjectCommon($postID, $aVariables, $subject); 313 315 } 314 316 return $subject; … … 320 322 $aKeyEmailType = $this->handleListKeyEmailTypeUsedUser(); 321 323 if ($postID = (int)array_search('customer_note', $aKeyEmailType)) { 322 $emailSubject = get_post_meta($postID, AutoPrefix::namePrefix('emailSubject'), true); 323 $subject = str_replace(array_keys($aVariables), array_values($aVariables), $emailSubject); 324 return $this->replaceEmailSubjectCommon($postID, $aVariables, $subject); 324 325 } 325 326 … … 332 333 $aKeyEmailType = $this->handleListKeyEmailTypeUsedUser(); 333 334 if ($postID = (int)array_search('customer_reset_password', $aKeyEmailType)) { 334 $emailSubject = get_post_meta($postID, AutoPrefix::namePrefix('emailSubject'), true); 335 $subject = str_replace(array_keys($aVariables), array_values($aVariables), $emailSubject); 335 return $this->replaceEmailSubjectCommon($postID, $aVariables, $subject); 336 336 } 337 337 return $subject; … … 344 344 345 345 if ($postID = (int)array_search('customer_new_account', $aKeyEmailType)) { 346 $emailSubject = get_post_meta($postID, AutoPrefix::namePrefix('emailSubject'), true); 347 $subject = str_replace(array_keys($aVariables), array_values($aVariables), $emailSubject); 346 return $this->replaceEmailSubjectCommon($postID, $aVariables, $subject); 348 347 } 349 348 -
email-creatior/trunk/src/Shared/GetFieldPlaceholderSubjectEmail.php
r2774630 r2785694 3 3 namespace WilokeEmailCreator\Shared; 4 4 5 use WC_Order; 5 6 use WilokeEmailCreator\Illuminate\Prefix\AutoPrefix; 6 7 use WP_User; … … 33 34 return $aArgs; 34 35 } 35 $aOrderData = $aArgs->get_data(); 36 37 /** 38 * @var WC_Order $oWCOrder 39 */ 40 $oWCOrder = $aArgs; 41 $aOrderData = $oWCOrder->get_data(); 42 43 // if (isset($aOrderData['id']) && !empty($aOrderData['id'])) { 44 // $orderNumber = $aOrderData['id']; 45 // if (!is_wp_error($oWCOrder)) { 46 // $paymentMethod = $oWCOrder->get_payment_method(); 47 // } else { 48 // $paymentMethod = $aOrderData['payment_method']; 49 // } 50 // } else { 51 // $orderNumber = 0; 52 // $paymentMethod = $aOrderData['payment_method']; 53 // } 54 36 55 $aVariable = [ 37 '{order_date}' => $ aArgs->get_date_created()->date(wc_date_format()),56 '{order_date}' => $oWCOrder->get_date_created()->date_i18n(wc_date_format()), 38 57 '{last_name}' => $aOrderData['billing']['last_name'], 39 58 '{billing_name}' => $aOrderData['billing']['first_name'] . ' ' . 40 59 $aOrderData['billing']['last_name'], 41 '{billing_phone}' => $ aOrderData['billing']['phone'],42 '{billing_email}' => $ aOrderData['billing']['email'],43 '{customer_note}' => $ aOrderData['customer_note'] ?? '',60 '{billing_phone}' => $oWCOrder->get_billing_phone(), 61 '{billing_email}' => $oWCOrder->get_billing_email(), 62 '{customer_note}' => $oWCOrder->get_customer_note(), 44 63 '{coupon_expire_date}' => date($date_format, current_time('U') + MONTH_IN_SECONDS), 45 '{first_name}' => $ aOrderData['billing']['first_name'],46 '{order_discount}' => wc_price((float)$aOrderData['discount_total']),47 '{order_number}' => $ aOrderData['id'] ?? 0,64 '{first_name}' => $oWCOrder->get_billing_first_name(), 65 '{order_discount}' => $oWCOrder->get_discount_total(), 66 '{order_number}' => $oWCOrder->get_id(), 48 67 '{order_received_url}' => add_query_arg('key', $aOrderData['order_key'], 49 68 wc_get_endpoint_url('order-received', 50 69 $aOrderData['id'], 51 70 wc_get_checkout_url())), 52 '{order_shipping}' => wc_price((float)$aOrderData['shipping_total']),71 '{order_shipping}' => $oWCOrder->get_shipping_total(), 53 72 '{order_subtotal}' => wc_price((float)$aOrderData['total'] + 54 73 (int)$aOrderData['discount_total']), 55 '{order_total}' => wc_price((float)$aOrderData['total']), 56 '{order_tax}' => wc_price((float)$aOrderData['total_tax']), 57 '{payment_url}' => wc_get_endpoint_url('order-pay', $aOrderData['id'], 58 wc_get_checkout_url()) . 59 '?pay_for_order=true&key=' . $aOrderData['order_key'], 60 '{payment_method}' => $aOrderData['payment_method'], 61 '{billing_address1}' => $aOrderData['billing']['address_1'] ?? '', 62 '{billing_address2}' => $aOrderData['billing']['address_2'] ?? '', 63 '{shipping_address1}' => $aOrderData['shipping']['address_1'] ?? '', 64 '{shipping_address2}' => $aOrderData['shipping']['address_2'] ?? '', 65 '{shipping_phone}' => $aOrderData['shipping']['phone'] ?? '', 66 '{shipping_email}' => $aOrderData['shipping']['email'] ?? '', 67 '{shipping_name}' => $aOrderData['shipping']['first_name'] . ' ' . 68 $aOrderData['shipping']['last_name'], 74 '{order_total}' => $oWCOrder->get_total(), 75 '{order_tax}' => $oWCOrder->get_total_tax(), 76 '{payment_url}' => add_query_arg( 77 [ 78 'pay_for_order' => true, 79 'key' => $aOrderData['order_key'] 80 ], 81 wc_get_endpoint_url( 82 'order-pay', 83 $aOrderData['id'], 84 wc_get_checkout_url() 85 ) 86 ), 87 '{payment_method}' => $oWCOrder->get_payment_method_title(), 88 '{billing_address1}' => $oWCOrder->get_billing_address_1(), 89 '{billing_address2}' => $oWCOrder->get_billing_address_2(), 90 '{shipping_address1}' => $oWCOrder->get_shipping_address_1() ?? $oWCOrder->get_billing_address_1(), 91 '{shipping_company}' => $oWCOrder->get_shipping_company(), 92 '{shipping_address2}' => $oWCOrder->get_shipping_address_2() ?? $oWCOrder->get_billing_address_2(), 93 '{shipping_phone}' => $oWCOrder->get_shipping_phone() ?? $oWCOrder->get_billing_phone(), 94 '{shipping_email}' => $aOrderData['shipping']['email'] ?? $oWCOrder->get_billing_email(), 95 '{shipping_name}' => $oWCOrder->get_formatted_shipping_full_name(), 69 96 ]; 70 97 } 98 71 99 return wp_parse_args($aVariable, [ 72 100 '{admin_email}' => get_bloginfo('admin_email'), … … 116 144 '{shipping_email}' => 'loni.alsayed@example.com', 117 145 '{shipping_name}' => 'Loni Alsayed', 146 '{shipping_company}' => '' 118 147 ]); 119 148 } 149 120 150 return [ 121 151 'order' => [
Note: See TracChangeset
for help on using the changeset viewer.