← All changes
|
app/Services/FormBuilder/Notifications/EmailNotification.php
+24
-22
6.2.5
→
6.2.14
View file →
| @@ -1,9 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace FluentForm\App\Services\FormBuilder\Notifications; |
| 4 | 4 | |
| 5 | -defined('ABSPATH') or die; | |
| 5 | +defined('ABSPATH') || die; | |
| 6 | 6 | |
| 7 | 7 | use FluentForm\Framework\Helpers\ArrayHelper; |
| 8 | 8 | use FluentForm\Framework\Foundation\Application; |
| 9 | 9 | use FluentForm\App\Modules\Form\FormFieldsParser; |
| @@ -41,15 +41,15 @@ | ||
| 41 | 41 | */ |
| 42 | 42 | public function notify($notification, $submittedData, $form, $entryId = false) |
| 43 | 43 | { |
| 44 | 44 | $isSendAsPlain = 'yes' == ArrayHelper::get($notification, 'asPlainText'); |
| 45 | - | |
| 45 | + | |
| 46 | 46 | $isSendAsPlain= apply_filters_deprecated( |
| 47 | 47 | 'fluentform_send_plain_html_email', |
| 48 | 48 | [ |
| 49 | 49 | $isSendAsPlain, |
| 50 | 50 | $form, |
| 51 | - $notification | |
| 51 | + $notification, | |
| 52 | 52 | ], |
| 53 | 53 | FLUENTFORM_FRAMEWORK_UPGRADE, |
| 54 | 54 | 'fluentform/send_plain_html_email', |
| 55 | 55 | 'Use fluentform/send_plain_html_email instead of fluentform_send_plain_html_email.' |
| @@ -57,9 +57,9 @@ | ||
| 57 | 57 | |
| 58 | 58 | $isSendAsPlain = apply_filters('fluentform/send_plain_html_email', $isSendAsPlain, $form, $notification); |
| 59 | 59 | |
| 60 | 60 | $emailBody = $notification['message']; |
| 61 | - | |
| 61 | + | |
| 62 | 62 | $emailBody = apply_filters_deprecated( |
| 63 | 63 | 'fluentform_submission_message_parse', |
| 64 | 64 | [ |
| 65 | 65 | $emailBody, |
| @@ -64,9 +64,9 @@ | ||
| 64 | 64 | [ |
| 65 | 65 | $emailBody, |
| 66 | 66 | $entryId, |
| 67 | 67 | $submittedData, |
| 68 | - $form | |
| 68 | + $form, | |
| 69 | 69 | ], |
| 70 | 70 | FLUENTFORM_FRAMEWORK_UPGRADE, |
| 71 | 71 | 'fluentform/submission_message_parse', |
| 72 | 72 | 'Use fluentform/submission_message_parse instead of fluentform_submission_message_parse.' |
| @@ -86,9 +86,9 @@ | ||
| 86 | 86 | [ |
| 87 | 87 | $notification['subject'], |
| 88 | 88 | $notification, |
| 89 | 89 | $submittedData, |
| 90 | - $form | |
| 90 | + $form, | |
| 91 | 91 | ], |
| 92 | 92 | FLUENTFORM_FRAMEWORK_UPGRADE, |
| 93 | 93 | 'fluentform/email_subject', |
| 94 | 94 | 'Use fluentform/email_subject instead of fluentform_email_subject.' |
| @@ -118,9 +118,9 @@ | ||
| 118 | 118 | [ |
| 119 | 119 | $notificationAttachments, |
| 120 | 120 | $notification, |
| 121 | 121 | $form, |
| 122 | - $submittedData | |
| 122 | + $submittedData, | |
| 123 | 123 | ], |
| 124 | 124 | FLUENTFORM_FRAMEWORK_UPGRADE, |
| 125 | 125 | 'fluentform/filter_email_attachments', |
| 126 | 126 | 'Use fluentform/filter_email_attachments instead of fluentform_filter_email_attachments.' |
| @@ -131,9 +131,9 @@ | ||
| 131 | 131 | $notification, |
| 132 | 132 | $form, |
| 133 | 133 | $submittedData |
| 134 | 134 | ); |
| 135 | - | |
| 135 | + | |
| 136 | 136 | $emailBody = apply_filters_deprecated( |
| 137 | 137 | 'fluentform_email_body', |
| 138 | 138 | [ |
| 139 | 139 | $emailBody, |
| @@ -138,9 +138,9 @@ | ||
| 138 | 138 | [ |
| 139 | 139 | $emailBody, |
| 140 | 140 | $notification, |
| 141 | 141 | $submittedData, |
| 142 | - $form | |
| 142 | + $form, | |
| 143 | 143 | ], |
| 144 | 144 | FLUENTFORM_FRAMEWORK_UPGRADE, |
| 145 | 145 | 'fluentform/email_body', |
| 146 | 146 | 'Use fluentform/email_body instead of fluentform_email_body.' |
| @@ -174,9 +174,9 @@ | ||
| 174 | 174 | [ |
| 175 | 175 | $sendAddresses, |
| 176 | 176 | $notification, |
| 177 | 177 | $submittedData, |
| 178 | - $form | |
| 178 | + $form, | |
| 179 | 179 | ], |
| 180 | 180 | FLUENTFORM_FRAMEWORK_UPGRADE, |
| 181 | 181 | 'fluentform/email_to', |
| 182 | 182 | 'Use fluentform/email_to instead of fluentform_email_to.' |
| @@ -247,14 +247,14 @@ | ||
| 247 | 247 | $routings = ArrayHelper::get($notification, 'sendTo.routing'); |
| 248 | 248 | $validAddresses = []; |
| 249 | 249 | foreach ($routings as $routing) { |
| 250 | 250 | $emailAddresses = ArrayHelper::get($routing, 'input_value'); |
| 251 | - | |
| 251 | + | |
| 252 | 252 | if (!$emailAddresses || trim($emailAddresses) === '') { |
| 253 | 253 | continue; |
| 254 | 254 | } |
| 255 | 255 | $emailAddresses = array_map('trim', explode(',', $emailAddresses)); |
| 256 | - $emailAddresses = array_filter($emailAddresses, function($email) { | |
| 256 | + $emailAddresses = array_filter($emailAddresses, function ($email) { | |
| 257 | 257 | return is_email($email); |
| 258 | 258 | }); |
| 259 | 259 | $condition = [ |
| 260 | 260 | 'conditionals' => [ |
| @@ -272,8 +272,10 @@ | ||
| 272 | 272 | return implode(',', $validAddresses); |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
| 276 | + * Resolve a form's input keys and their admin labels. | |
| 277 | + * | |
| 276 | 278 | * @param $formId |
| 277 | 279 | * |
| 278 | 280 | * @return array |
| 279 | 281 | * |
| @@ -293,15 +295,15 @@ | ||
| 293 | 295 | |
| 294 | 296 | public function getEmailWithTemplate($emailBody, $form, $notification) |
| 295 | 297 | { |
| 296 | 298 | $originalEmailBody = $emailBody; |
| 297 | - $emailHeader = ""; | |
| 299 | + $emailHeader = ''; | |
| 298 | 300 | $emailHeader = apply_filters_deprecated( |
| 299 | 301 | 'fluentform_email_header', |
| 300 | 302 | [ |
| 301 | 303 | $emailHeader, |
| 302 | 304 | $form, |
| 303 | - $notification | |
| 305 | + $notification, | |
| 304 | 306 | ], |
| 305 | 307 | FLUENTFORM_FRAMEWORK_UPGRADE, |
| 306 | 308 | 'fluentform/email_header', |
| 307 | 309 | 'Use fluentform/email_header instead of fluentform_email_header.' |
| @@ -306,9 +308,9 @@ | ||
| 306 | 308 | 'fluentform/email_header', |
| 307 | 309 | 'Use fluentform/email_header instead of fluentform_email_header.' |
| 308 | 310 | ); |
| 309 | 311 | $emailHeader = apply_filters('fluentform/email_header', $emailHeader, $form, $notification); |
| 310 | - | |
| 312 | + | |
| 311 | 313 | $emailFooter = ''; |
| 312 | 314 | $emailFooter = apply_filters_deprecated( |
| 313 | 315 | 'fluentform_email_footer', |
| 314 | 316 | [ |
| @@ -313,9 +315,9 @@ | ||
| 313 | 315 | 'fluentform_email_footer', |
| 314 | 316 | [ |
| 315 | 317 | $emailFooter, |
| 316 | 318 | $form, |
| 317 | - $notification | |
| 319 | + $notification, | |
| 318 | 320 | ], |
| 319 | 321 | FLUENTFORM_FRAMEWORK_UPGRADE, |
| 320 | 322 | 'fluentform/email_footer', |
| 321 | 323 | 'Use fluentform/email_footer instead of fluentform_email_footer.' |
| @@ -342,9 +344,9 @@ | ||
| 342 | 344 | 'fluentform_email_styles', |
| 343 | 345 | [ |
| 344 | 346 | $css, |
| 345 | 347 | $form, |
| 346 | - $notification | |
| 348 | + $notification, | |
| 347 | 349 | ], |
| 348 | 350 | FLUENTFORM_FRAMEWORK_UPGRADE, |
| 349 | 351 | 'fluentform/email_styles', |
| 350 | 352 | 'Use fluentform/email_styles instead of fluentform_email_styles.' |
| @@ -356,9 +358,9 @@ | ||
| 356 | 358 | try { |
| 357 | 359 | // apply CSS styles inline for picky email clients |
| 358 | 360 | $emogrifier = new Emogrifier($emailBody, $css); |
| 359 | 361 | $emailBody = $emogrifier->emogrify(); |
| 360 | - } catch (\Exception $e) { | |
| 362 | + } catch (\Exception $e) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement -- Emogrifier failed (malformed HTML/CSS); keep the un-inlined body. | |
| 361 | 363 | } |
| 362 | 364 | $maybeError = ob_get_clean(); |
| 363 | 365 | |
| 364 | 366 | if ($maybeError) { |
| @@ -375,15 +377,15 @@ | ||
| 375 | 377 | $footerText = $option['misc']['email_footer_text']; |
| 376 | 378 | } else { |
| 377 | 379 | $footerText = '© ' . get_bloginfo('name', 'display') . '.'; |
| 378 | 380 | } |
| 379 | - | |
| 381 | + | |
| 380 | 382 | $footerText = apply_filters_deprecated( |
| 381 | 383 | 'fluentform_email_template_footer_text', |
| 382 | 384 | [ |
| 383 | 385 | $footerText, |
| 384 | 386 | $form, |
| 385 | - $notification | |
| 387 | + $notification, | |
| 386 | 388 | ], |
| 387 | 389 | FLUENTFORM_FRAMEWORK_UPGRADE, |
| 388 | 390 | 'fluentform/email_template_footer_text', |
| 389 | 391 | 'Use fluentform/email_template_footer_text instead of fluentform_email_header.' |
| @@ -421,14 +423,14 @@ | ||
| 421 | 423 | |
| 422 | 424 | if ($notification['replyTo'] && is_email($notification['replyTo'])) { |
| 423 | 425 | $headers[] = 'Reply-To: <' . $notification['replyTo'] . '>'; |
| 424 | 426 | } |
| 425 | - | |
| 427 | + | |
| 426 | 428 | $headers = apply_filters_deprecated( |
| 427 | 429 | 'fluenttform_email_header', |
| 428 | 430 | [ |
| 429 | 431 | $headers, |
| 430 | - $notification | |
| 432 | + $notification, | |
| 431 | 433 | ], |
| 432 | 434 | FLUENTFORM_FRAMEWORK_UPGRADE, |
| 433 | 435 | 'fluentform/email_template_header', |
| 434 | 436 | 'Use fluentform/email_template_header instead of fluenttform_email_header.' |