PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/models/FrmEmail.php +114 -252 6.295.0 View file →
@@ -7,99 +7,30 @@
7 7 * @since 2.03.04
8 8 */
9 9 class FrmEmail {
10 10
11 - /**
12 - * @var string
13 - */
14 11 private $email_key = '';
15 -
16 - /**
17 - * @var array
18 - */
19 12 private $to = array();
20 -
21 - /**
22 - * @var array
23 - */
24 13 private $cc = array();
25 -
26 - /**
27 - * @var array
28 - */
29 14 private $bcc = array();
30 -
31 - /**
32 - * @var string
33 - */
34 15 private $from = '';
35 -
36 - /**
37 - * @var string
38 - */
39 16 private $reply_to = '';
40 -
41 - /**
42 - * @var string
43 - */
44 17 private $subject = '';
45 -
46 - /**
47 - * @var string
48 - */
49 18 private $message = '';
50 -
51 - /**
52 - * @var array
53 - */
54 19 private $attachments = array();
55 20
56 - /**
57 - * @var bool
58 - */
59 21 private $is_plain_text = false;
60 -
61 - /**
62 - * @var bool
63 - */
64 22 private $is_single_recipient = false;
65 -
66 - /**
67 - * @var bool
68 - */
69 23 private $include_user_info = false;
70 24
71 - /**
72 - * @var string
73 - */
74 25 private $charset = '';
75 -
76 - /**
77 - * @var string
78 - */
79 26 private $content_type = 'text/html';
80 27
81 - /**
82 - * @var array
83 - */
84 28 private $settings = array();
85 -
86 - /**
87 - * @var stdClass
88 - */
89 29 private $entry;
90 -
91 - /**
92 - * @var stdClass
93 - */
94 30 private $form;
95 31
96 32 /**
97 - * @var int
98 - */
99 - private $action_id = 0;
100 -
101 - /**
102 33 * FrmEmail constructor
103 34 *
104 35 * @param object $action
105 36 * @param object $entry
@@ -106,12 +37,11 @@
106 37 * @param object $form
107 38 */
108 39 public function __construct( $action, $entry, $form ) {
109 40 $this->set_email_key( $action );
110 - $this->entry = $entry;
111 - $this->form = $form;
112 - $this->settings = $action->post_content;
113 - $this->action_id = (int) $action->ID;
41 + $this->entry = $entry;
42 + $this->form = $form;
43 + $this->settings = $action->post_content;
114 44
115 45 $user_id_args = self::get_user_id_args( $form->id );
116 46 $this->set_to( $user_id_args );
117 47 $this->set_cc( $user_id_args );
@@ -141,10 +71,8 @@
141 71 *
142 72 * @since 2.03.04
143 73 *
144 74 * @param object $action
145 - *
146 - * @return void
147 75 */
148 76 private function set_email_key( $action ) {
149 77 $this->email_key = $action->ID;
150 78 }
@@ -154,10 +82,8 @@
154 82 *
155 83 * @since 2.03.04
156 84 *
157 85 * @param array $user_id_args
158 - *
159 - * @return void
160 86 */
161 87 private function set_to( $user_id_args ) {
162 88 $to = $this->prepare_email_setting( $this->settings['email_to'], $user_id_args );
163 89 $to = $this->explode_emails( $to );
@@ -175,9 +101,9 @@
175 101 $to = apply_filters( 'frm_to_email', $to, $values, $this->form->id, $args );
176 102
177 103 $this->to = array_unique( (array) $to );
178 104
179 - if ( ! $this->to ) {
105 + if ( empty( $this->to ) ) {
180 106 return;
181 107 }
182 108
183 109 $this->handle_phone_numbers();
@@ -190,10 +116,8 @@
190 116 *
191 117 * @since 2.03.04
192 118 *
193 119 * @param array $user_id_args
194 - *
195 - * @return void
196 120 */
197 121 private function set_cc( $user_id_args ) {
198 122 $this->cc = $this->prepare_additional_recipients( $this->settings['cc'], $user_id_args );
199 123 }
@@ -203,10 +127,8 @@
203 127 *
204 128 * @since 2.03.04
205 129 *
206 130 * @param array $user_id_args
207 - *
208 - * @return void
209 131 */
210 132 private function set_bcc( $user_id_args ) {
211 133 $this->bcc = $this->prepare_additional_recipients( $this->settings['bcc'], $user_id_args );
212 134 }
@@ -216,9 +138,9 @@
216 138 *
217 139 * @since 2.03.04
218 140 *
219 141 * @param string $recipients
220 - * @param array $user_id_args
142 + * @param array $user_id_args
221 143 *
222 144 * @return array
223 145 */
224 146 private function prepare_additional_recipients( $recipients, $user_id_args ) {
@@ -223,11 +145,13 @@
223 145 */
224 146 private function prepare_additional_recipients( $recipients, $user_id_args ) {
225 147 $recipients = $this->prepare_email_setting( $recipients, $user_id_args );
226 148 $recipients = $this->explode_emails( $recipients );
149 +
227 150 $recipients = array_unique( (array) $recipients );
151 + $recipients = $this->format_recipients( $recipients );
228 152
229 - return $this->format_recipients( $recipients );
153 + return $recipients;
230 154 }
231 155
232 156 /**
233 157 * Set the From addresses
@@ -234,14 +158,12 @@
234 158 *
235 159 * @since 2.03.04
236 160 *
237 161 * @param array $user_id_args
238 - *
239 - * @return void
240 162 */
241 163 private function set_from( $user_id_args ) {
242 164 if ( empty( $this->settings['from'] ) ) {
243 - $from = FrmEmailHelper::get_default_from_email();
165 + $from = get_option( 'admin_email' );
244 166 } else {
245 167 $from = $this->prepare_email_setting( $this->settings['from'], $user_id_args );
246 168 }
247 169
@@ -253,10 +175,8 @@
253 175 *
254 176 * @since 2.03.04
255 177 *
256 178 * @param array $user_id_args
257 - *
258 - * @return void
259 179 */
260 180 private function set_reply_to( $user_id_args ) {
261 181 $this->reply_to = trim( $this->settings['reply_to'] );
262 182
@@ -275,19 +195,13 @@
275 195 * Set the is_plain_text property
276 196 * This should be set before the message
277 197 *
278 198 * @since 2.03.04
279 - *
280 - * @return void
281 199 */
282 200 private function set_is_plain_text() {
283 - if ( empty( $this->settings['email_style'] ) ) {
284 - // If `email_style` isn't set, use the `plain_text` checkbox.
285 - $this->is_plain_text = ! empty( $this->settings['plain_text'] );
286 - return;
201 + if ( $this->settings['plain_text'] ) {
202 + $this->is_plain_text = true;
287 203 }
288 -
289 - $this->is_plain_text = 'plain' === $this->settings['email_style'];
290 204 }
291 205
292 206 /**
293 207 * Set the include_user_info property
@@ -293,10 +207,8 @@
293 207 * Set the include_user_info property
294 208 * This should be set before the message
295 209 *
296 210 * @since 2.03.04
297 - *
298 - * @return void
299 211 */
300 212 private function set_include_user_info() {
301 213 if ( isset( $this->settings['inc_user_info'] ) ) {
302 214 $this->include_user_info = $this->settings['inc_user_info'];
@@ -307,11 +219,9 @@
307 219 * Set the is_single_recipient property
308 220 *
309 221 * @since 2.03.04
310 222 *
311 - * @param object $action
312 - *
313 - * @return void
223 + * @param $action
314 224 */
315 225 private function set_is_single_recipient( $action ) {
316 226 $args = array(
317 227 'form' => $this->form,
@@ -330,10 +240,8 @@
330 240 /**
331 241 * Set the charset
332 242 *
333 243 * @since 2.03.04
334 - *
335 - * @return void
336 244 */
337 245 private function set_charset() {
338 246 $this->charset = get_option( 'blog_charset' );
339 247 }
@@ -341,10 +249,8 @@
341 249 /**
342 250 * Set the content type
343 251 *
344 252 * @since 2.03.04
345 - *
346 - * @return void
347 253 */
348 254 private function set_content_type() {
349 255 if ( $this->is_plain_text ) {
350 256 $this->content_type = 'text/plain';
@@ -354,10 +260,8 @@
354 260 /**
355 261 * Set the subject
356 262 *
357 263 * @since 2.03.04
358 - *
359 - * @return void
360 264 */
361 265 private function set_subject() {
362 266 if ( empty( $this->settings['email_subject'] ) ) {
363 267 /* translators: %1$s: Form name, %2$s: Site name */
@@ -365,9 +269,8 @@
365 269 } else {
366 270 $this->subject = $this->settings['email_subject'];
367 271 }
368 272
369 - // This also replaces [sitename] shortcode in default.
370 273 $this->subject = FrmFieldsHelper::basic_replace_shortcodes( $this->subject, $this->form, $this->entry );
371 274
372 275 $args = array(
373 276 'form' => $this->form,
@@ -374,8 +277,9 @@
374 277 'entry' => $this->entry,
375 278 'email_key' => $this->email_key,
376 279 );
377 280 $this->subject = apply_filters( 'frm_email_subject', $this->subject, $args );
281 +
378 282 $this->subject = wp_specialchars_decode( strip_tags( stripslashes( $this->subject ) ), ENT_QUOTES );
379 283 }
380 284
381 285 /**
@@ -381,38 +285,27 @@
381 285 /**
382 286 * Set the email message
383 287 *
384 288 * @since 2.03.04
385 - *
386 - * @return void
387 289 */
388 290 private function set_message() {
389 - $this->message = $this->settings['email_message'];
291 + $this->message = FrmFieldsHelper::basic_replace_shortcodes( $this->settings['email_message'], $this->form, $this->entry );
390 292
391 - if ( ! $this->is_plain_text ) {
392 - // The decode is to support [default-html] shortcodes.
393 - $this->message = html_entity_decode( $this->message );
394 - }
395 -
396 - $this->message = FrmFieldsHelper::basic_replace_shortcodes( $this->message, $this->form, $this->entry );
397 293 $prev_mail_body = $this->message;
398 -
399 - // Make a copy to prevent changes by reference.
400 - $pass_entry = clone $this->entry;
401 - $mail_body = FrmEntriesHelper::replace_default_message(
294 + $pass_entry = clone $this->entry; // make a copy to prevent changes by reference
295 + $mail_body = FrmEntriesHelper::replace_default_message(
402 296 $prev_mail_body,
403 297 array(
404 - 'id' => $this->entry->id,
405 - 'entry' => $pass_entry,
406 - 'plain_text' => $this->is_plain_text,
407 - 'user_info' => $this->include_user_info,
408 - 'table_style' => $this->settings['email_style'],
298 + 'id' => $this->entry->id,
299 + 'entry' => $pass_entry,
300 + 'plain_text' => $this->is_plain_text,
301 + 'user_info' => $this->include_user_info,
409 302 )
410 303 );
411 304
412 305 // Add the user info if it isn't already included
413 306 if ( $this->include_user_info && $prev_mail_body === $mail_body ) {
414 - $data = $this->entry->description;
307 + $data = $this->entry->description;
415 308 $mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) . "\r\n";
416 309 $this->maybe_add_ip( $mail_body );
417 310 $mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntriesHelper::get_browser( $data['browser'] ) . "\r\n";
418 311 $mail_body .= __( 'Referrer', 'formidable' ) . ': ' . $data['referrer'] . "\r\n";
@@ -419,39 +312,17 @@
419 312 }
420 313
421 314 $this->message = $mail_body;
422 315
316 + $this->message = do_shortcode( $this->message );
317 +
423 318 if ( $this->is_plain_text ) {
424 319 $this->message = wp_specialchars_decode( strip_tags( $this->message ), ENT_QUOTES );
425 - $this->message = str_replace( ' ', '', $this->message );
426 - } else {
427 - $this->add_autop();
428 320 }
429 321
430 322 $this->message = apply_filters( 'frm_email_message', $this->message, $this->package_atts() );
431 323 }
432 324
433 - /**
434 - * Runs message through autop, extracting the content inside body tag if it has <body>.
435 - *
436 - * @return void
437 - */
438 - private function add_autop() {
439 - $message = $this->message;
440 - preg_match( '/<body[^>]*>([\s\S]*?)<\/body>/', $message, $match );
441 -
442 - if ( ! empty( $match[1] ) ) {
443 - $this->message = str_replace( $match[1], trim( wpautop( $match[1] ) ), $message );
444 - } else {
445 - $this->message = trim( wpautop( $message ) );
446 - }
447 - }
448 -
449 - /**
450 - * @param string $mail_body
451 - *
452 - * @return void
453 - */
454 325 private function maybe_add_ip( &$mail_body ) {
455 326 if ( ! empty( $this->entry->ip ) ) {
456 327 $mail_body .= __( 'IP Address', 'formidable' ) . ': ' . $this->entry->ip . "\r\n";
457 328 }
@@ -460,11 +331,8 @@
460 331 /**
461 332 * Set the attachments for an email message
462 333 *
463 334 * @since 2.03.04
464 - * @since 5.0.16 added new action_id key to $args.
465 - *
466 - * @return void
467 335 */
468 336 private function set_attachments() {
469 337 $args = array(
470 338 'entry' => $this->entry,
@@ -469,9 +337,8 @@
469 337 $args = array(
470 338 'entry' => $this->entry,
471 339 'email_key' => $this->email_key,
472 340 'settings' => $this->settings,
473 - 'action_id' => $this->action_id,
474 341 );
475 342
476 343 $this->attachments = apply_filters( 'frm_notification_attachment', array(), $this->form, $args );
477 344 }
@@ -484,24 +351,28 @@
484 351 * @return bool|mixed|void
485 352 */
486 353 public function should_send() {
487 354 if ( ! $this->has_recipients() ) {
488 - return false;
355 + $send = false;
356 + } else {
357 +
358 + $filter_args = array(
359 + 'message' => $this->message,
360 + 'subject' => $this->subject,
361 + 'recipient' => $this->to,
362 + 'header' => $this->package_header(),
363 + );
364 +
365 + /**
366 + * Stop an email based on the message, subject, recipient,
367 + * or any information included in the email header
368 + *
369 + * @since 2.2.8
370 + */
371 + $send = apply_filters( 'frm_send_email', true, $filter_args );
489 372 }
490 373
491 - $filter_args = array(
492 - 'message' => $this->message,
493 - 'subject' => $this->subject,
494 - 'recipient' => $this->to,
495 - 'header' => $this->package_header(),
496 - );
497 - /**
498 - * Stop an email based on the message, subject, recipient,
499 - * or any information included in the email header
500 - *
501 - * @since 2.2.8
502 - */
503 - return apply_filters( 'frm_send_email', true, $filter_args );
374 + return $send;
504 375 }
505 376
506 377 /**
507 378 * Check if an email has any recipients
@@ -510,9 +381,13 @@
510 381 *
511 382 * @return bool
512 383 */
513 384 private function has_recipients() {
514 - return $this->to || $this->cc || $this->bcc;
385 + if ( empty( $this->to ) && empty( $this->cc ) && empty( $this->bcc ) ) {
386 + return false;
387 + } else {
388 + return true;
389 + }
515 390 }
516 391
517 392 /**
518 393 * Send an email
@@ -525,9 +400,8 @@
525 400 $this->remove_buddypress_filters();
526 401 $this->add_mandrill_filter();
527 402
528 403 $sent = false;
529 -
530 404 if ( count( $this->to ) > 1 && $this->is_single_recipient ) {
531 405 foreach ( $this->to as $recipient ) {
532 406 $sent = $this->send_single( $recipient );
533 407 }
@@ -559,15 +433,15 @@
559 433 )
560 434 );
561 435
562 436 $subject = $this->encode_subject( $this->subject );
563 - $sent = wp_mail( $recipient, $subject, $this->message, $header, $this->attachments );
564 437
438 + $sent = wp_mail( $recipient, $subject, $this->message, $header, $this->attachments );
439 +
565 440 if ( ! $sent ) {
566 441 if ( is_array( $header ) ) {
567 442 $header = implode( "\r\n", $header );
568 443 }
569 -
570 444 $recipient = implode( ',', (array) $recipient );
571 445 $sent = mail( $recipient, $subject, $this->message, $header );
572 446 }
573 447
@@ -585,13 +459,13 @@
585 459 */
586 460 private function package_header() {
587 461 $header = array();
588 462
589 - if ( $this->cc ) {
463 + if ( ! empty( $this->cc ) ) {
590 464 $header[] = 'CC: ' . implode( ',', $this->cc );
591 465 }
592 466
593 - if ( $this->bcc ) {
467 + if ( ! empty( $this->bcc ) ) {
594 468 $header[] = 'BCC: ' . implode( ',', $this->bcc );
595 469 }
596 470
597 471 $header[] = 'From: ' . $this->from;
@@ -605,9 +479,9 @@
605 479 * Get the userID field ID and key for email settings
606 480 *
607 481 * @since 2.03.04
608 482 *
609 - * @param int $form_id
483 + * @param $form_id
610 484 *
611 485 * @return array
612 486 */
613 487 private function get_user_id_args( $form_id ) {
@@ -616,9 +490,8 @@
616 490 'field_key' => '',
617 491 );
618 492
619 493 $user_id_args['field_id'] = FrmEmailHelper::get_user_id_field_for_form( $form_id );
620 -
621 494 if ( $user_id_args['field_id'] ) {
622 495 $user_id_args['field_key'] = FrmField::get_key_by_id( $user_id_args['field_id'] );
623 496 }
624 497
@@ -630,16 +503,16 @@
630 503 *
631 504 * @since 2.03.04
632 505 *
633 506 * @param string $value
634 - * @param array $user_id_args
507 + * @param array $user_id_args
635 508 *
636 509 * @return string
637 510 */
638 511 private function prepare_email_setting( $value, $user_id_args ) {
639 - if ( str_contains( $value, '[' . $user_id_args['field_id'] . ']' ) ) {
512 + if ( strpos( $value, '[' . $user_id_args['field_id'] . ']' ) !== false ) {
640 513 $value = str_replace( '[' . $user_id_args['field_id'] . ']', '[' . $user_id_args['field_id'] . ' show="user_email"]', $value );
641 - } elseif ( str_contains( $value, '[' . $user_id_args['field_key'] . ']' ) ) {
514 + } elseif ( strpos( $value, '[' . $user_id_args['field_key'] . ']' ) !== false ) {
642 515 $value = str_replace( '[' . $user_id_args['field_key'] . ']', '[' . $user_id_args['field_key'] . ' show="user_email"]', $value );
643 516 }
644 517
645 518 $value = FrmFieldsHelper::basic_replace_shortcodes( $value, $this->form, $this->entry );
@@ -645,10 +518,11 @@
645 518 $value = FrmFieldsHelper::basic_replace_shortcodes( $value, $this->form, $this->entry );
646 519
647 520 // Remove brackets and add a space in case there isn't one
648 521 $value = str_replace( '<', ' ', $value );
522 + $value = str_replace( array( '"', '>' ), '', $value );
649 523
650 - return str_replace( array( '"', '>' ), '', $value );
524 + return $value;
651 525 }
652 526
653 527 /**
654 528 * Extract the emails from cc and bcc. Allow separation by , or ;.
@@ -657,13 +531,19 @@
657 531 * @since 2.03.04
658 532 *
659 533 * @param string $emails
660 534 *
661 - * @return array|string Emails.
535 + * @return array|string $emails
662 536 */
663 537 private function explode_emails( $emails ) {
664 - $emails = $emails ? preg_split( '/(,|;)/', $emails ) : '';
665 - return is_array( $emails ) ? array_map( 'trim', $emails ) : trim( $emails );
538 + $emails = ( ! empty( $emails ) ? preg_split( '/(,|;)/', $emails ) : '' );
539 + if ( is_array( $emails ) ) {
540 + $emails = array_map( 'trim', $emails );
541 + } else {
542 + $emails = trim( $emails );
543 + }
544 +
545 + return $emails;
666 546 }
667 547
668 548 /**
669 549 * Format the recipients( to, cc, bcc)
@@ -672,9 +552,9 @@
672 552 *
673 553 * @return array
674 554 */
675 555 private function format_recipients( $recipients ) {
676 - if ( ! $recipients ) {
556 + if ( empty( $recipients ) ) {
677 557 return $recipients;
678 558 }
679 559
680 560 foreach ( $recipients as $key => $val ) {
@@ -682,24 +562,24 @@
682 562
683 563 if ( is_email( $val ) ) {
684 564 // If a plain email is used, no formatting is needed
685 565 continue;
686 - }
566 + } else {
567 + $parts = explode( ' ', $val );
568 + $email = end( $parts );
687 569
688 - $parts = explode( ' ', $val );
689 - $email = end( $parts );
690 -
691 - if ( ! is_email( $email ) ) {
692 - // If user enters a name without an email
693 - unset( $recipients[ $key ] );
694 - continue;
570 + if ( is_email( $email ) ) {
571 + // If user enters a name and email
572 + $name = trim( str_replace( $email, '', $val ) );
573 + } else {
574 + // If user enters a name without an email
575 + unset( $recipients[ $key ] );
576 + continue;
577 + }
695 578 }
696 579
697 - // If user enters a name and email
698 - $name = trim( str_replace( $email, '', $val ) );
699 -
700 580 $recipients[ $key ] = $this->format_from_email( $name, $email );
701 - }//end foreach
581 + }
702 582
703 583 return $recipients;
704 584 }
705 585
@@ -720,14 +600,14 @@
720 600 } else {
721 601 list( $from_name, $from_email ) = $this->get_name_and_email_for_sender( $from );
722 602 }
723 603
724 - // If sending the email from a yahoo address, change it to the WordPress default
725 - if ( str_contains( $from_email, '@yahoo.com' ) ) {
604 + // if sending the email from a yahoo address, change it to the WordPress default
605 + if ( strpos( $from_email, '@yahoo.com' ) ) {
606 +
726 607 // Get the site domain and get rid of www.
727 608 $sitename = strtolower( FrmAppHelper::get_server_value( 'SERVER_NAME' ) );
728 -
729 - if ( str_starts_with( $sitename, 'www.' ) ) {
609 + if ( substr( $sitename, 0, 4 ) === 'www.' ) {
730 610 $sitename = substr( $sitename, 4 );
731 611 }
732 612
733 613 $from_email = 'wordpress@' . $sitename;
@@ -749,9 +629,9 @@
749 629 $reply_to = trim( $reply_to );
750 630
751 631 if ( ! is_email( $reply_to ) ) {
752 632 list( $name, $email ) = $this->get_name_and_email_for_sender( $reply_to );
753 - $reply_to = $this->format_from_email( $name, $email );
633 + $reply_to = $this->format_from_email( $name, $email );
754 634 }
755 635
756 636 return $reply_to;
757 637 }
@@ -759,17 +639,12 @@
759 639 /**
760 640 * Get only the email if the name and email have been combined
761 641 *
762 642 * @since 3.0.06
763 - *
764 - * @param string $name
765 - *
766 - * @return string
767 643 */
768 644 private function get_email_from_name( $name ) {
769 645 $email = trim( trim( $name, '>' ), '<' );
770 -
771 - if ( str_contains( $email, '<' ) ) {
646 + if ( strpos( $email, '<' ) !== false ) {
772 647 $parts = explode( '<', $email );
773 648 $email = trim( $parts[1], '>' );
774 649 }
775 650
@@ -801,16 +676,15 @@
801 676 }
802 677
803 678 /**
804 679 * @since 3.0.06
805 - *
806 - * @param string $name
807 - * @param string $email
808 - *
809 - * @return string
810 680 */
811 681 private function format_from_email( $name, $email ) {
812 - return '' !== $name ? $name . ' <' . $email . '>' : $email;
682 + if ( '' !== $name ) {
683 + $email = $name . ' <' . $email . '>';
684 + }
685 +
686 + return $email;
813 687 }
814 688
815 689 /**
816 690 * Remove phone numbers from To addresses
@@ -816,42 +690,38 @@
816 690 * Remove phone numbers from To addresses
817 691 * Send the phone numbers to the frm_send_to_not_email hook
818 692 *
819 693 * @since 2.03.04
820 - *
821 - * @return void
822 694 */
823 695 private function handle_phone_numbers() {
696 +
824 697 foreach ( $this->to as $key => $recipient ) {
825 - if ( '[admin_email]' === $recipient || is_email( $recipient ) ) {
826 - continue;
827 - }
698 + if ( '[admin_email]' !== $recipient && ! is_email( $recipient ) ) {
699 + $recipient = explode( ' ', $recipient );
828 700
829 - $recipient = explode( ' ', $recipient );
701 + if ( is_email( end( $recipient ) ) ) {
702 + continue;
703 + }
830 704
831 - if ( is_email( end( $recipient ) ) ) {
832 - continue;
705 + do_action(
706 + 'frm_send_to_not_email',
707 + array(
708 + 'e' => $recipient,
709 + 'subject' => $this->subject,
710 + 'mail_body' => $this->message,
711 + 'reply_to' => $this->reply_to,
712 + 'from' => $this->from,
713 + 'plain_text' => $this->is_plain_text,
714 + 'attachments' => $this->attachments,
715 + 'form' => $this->form,
716 + 'email_key' => $key,
717 + )
718 + );
719 +
720 + // Remove phone number from to addresses
721 + unset( $this->to[ $key ] );
833 722 }
834 -
835 - do_action(
836 - 'frm_send_to_not_email',
837 - array(
838 - 'e' => $recipient,
839 - 'subject' => $this->subject,
840 - 'mail_body' => $this->message,
841 - 'reply_to' => $this->reply_to,
842 - 'from' => $this->from,
843 - 'plain_text' => $this->is_plain_text,
844 - 'attachments' => $this->attachments,
845 - 'form' => $this->form,
846 - 'email_key' => $key,
847 - )
848 - );
849 -
850 - // Remove phone number from to addresses
851 - unset( $this->to[ $key ] );
852 - // end if
853 - }//end foreach
723 + }
854 724 }
855 725
856 726 /**
857 727 * Package an array of FrmEmail properties
@@ -870,12 +740,10 @@
870 740 'subject' => $this->subject,
871 741 'message' => $this->message,
872 742 'attachments' => $this->attachments,
873 743 'plain_text' => $this->is_plain_text,
874 - 'email_key' => $this->email_key,
875 744 'form' => $this->form,
876 745 'entry' => $this->entry,
877 - 'email_style' => $this->settings['email_style'],
878 746 );
879 747 }
880 748
881 749 /**
@@ -881,10 +749,8 @@
881 749 /**
882 750 * Remove the Buddypress email filters
883 751 *
884 752 * @since 2.03.04
885 - *
886 - * @return void
887 753 */
888 754 private function remove_buddypress_filters() {
889 755 remove_filter( 'wp_mail_from', 'bp_core_email_from_address_filter' );
890 756 remove_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' );
@@ -894,10 +760,8 @@
894 760 * Add Mandrill line break filter
895 761 * Remove line breaks in HTML emails to prevent conflicts with Mandrill
896 762 *
897 763 * @since 2.03.04
898 - *
899 - * @return void
900 764 */
901 765 private function add_mandrill_filter() {
902 766 if ( ! $this->is_plain_text ) {
903 767 add_filter( 'mandrill_nl2br', 'FrmEmailHelper::remove_mandrill_br' );
@@ -907,10 +771,8 @@
907 771 /**
908 772 * Remove Mandrill line break filter
909 773 *
910 774 * @since 2.03.04
911 - *
912 - * @return void
913 775 */
914 776 private function remove_mandrill_filter() {
915 777 remove_filter( 'mandrill_nl2br', 'FrmEmailHelper::remove_mandrill_br' );
916 778 }
@@ -923,9 +785,9 @@
923 785 * @return string
924 786 */
925 787 private function encode_subject( $subject ) {
926 788 if ( apply_filters( 'frm_encode_subject', false, $subject ) ) {
927 - return '=?' . $this->charset . '?B?' . base64_encode( $subject ) . '?=';
789 + $subject = '=?' . $this->charset . '?B?' . base64_encode( $subject ) . '?=';
928 790 }
929 791
930 792 return $subject;
931 793 }