PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.8
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.8
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 +45 -59 6.266.8 View file →
@@ -8,94 +8,94 @@
8 8 */
9 9 class FrmEmail {
10 10
11 11 /**
12 - * @var string
12 + * @var string $email_key
13 13 */
14 14 private $email_key = '';
15 15
16 16 /**
17 - * @var array
17 + * @var array $to
18 18 */
19 19 private $to = array();
20 20
21 21 /**
22 - * @var array
22 + * @var array $cc
23 23 */
24 24 private $cc = array();
25 25
26 26 /**
27 - * @var array
27 + * @var array $bcc
28 28 */
29 29 private $bcc = array();
30 30
31 31 /**
32 - * @var string
32 + * @var string $from
33 33 */
34 34 private $from = '';
35 35
36 36 /**
37 - * @var string
37 + * @var string $reply_to
38 38 */
39 39 private $reply_to = '';
40 40
41 41 /**
42 - * @var string
42 + * @var string $subject
43 43 */
44 44 private $subject = '';
45 45
46 46 /**
47 - * @var string
47 + * @var string $message
48 48 */
49 49 private $message = '';
50 50
51 51 /**
52 - * @var array
52 + * @var array $attachments
53 53 */
54 54 private $attachments = array();
55 55
56 56 /**
57 - * @var bool
57 + * @var bool $is_plain_text
58 58 */
59 59 private $is_plain_text = false;
60 60
61 61 /**
62 - * @var bool
62 + * @var bool $is_single_recipient
63 63 */
64 64 private $is_single_recipient = false;
65 65
66 66 /**
67 - * @var bool
67 + * @var bool $include_user_info
68 68 */
69 69 private $include_user_info = false;
70 70
71 71 /**
72 - * @var string
72 + * @var string $charset
73 73 */
74 74 private $charset = '';
75 75
76 76 /**
77 - * @var string
77 + * @var string $content_type
78 78 */
79 79 private $content_type = 'text/html';
80 80
81 81 /**
82 - * @var array
82 + * @var array $settings
83 83 */
84 84 private $settings = array();
85 85
86 86 /**
87 - * @var stdClass
87 + * @var stdClass $entry
88 88 */
89 89 private $entry;
90 90
91 91 /**
92 - * @var stdClass
92 + * @var stdClass $form
93 93 */
94 94 private $form;
95 95
96 96 /**
97 - * @var int
97 + * @var int $action_id
98 98 */
99 99 private $action_id = 0;
100 100
101 101 /**
@@ -236,14 +236,13 @@
236 236 *
237 237 * @since 2.03.04
238 238 *
239 239 * @param array $user_id_args
240 - *
241 240 * @return void
242 241 */
243 242 private function set_from( $user_id_args ) {
244 243 if ( empty( $this->settings['from'] ) ) {
245 - $from = FrmEmailHelper::get_default_from_email();
244 + $from = get_option( 'admin_email' );
246 245 } else {
247 246 $from = $this->prepare_email_setting( $this->settings['from'], $user_id_args );
248 247 }
249 248
@@ -281,15 +280,11 @@
281 280 *
282 281 * @return void
283 282 */
284 283 private function set_is_plain_text() {
285 - if ( empty( $this->settings['email_style'] ) ) {
286 - // If `email_style` isn't set, use the `plain_text` checkbox.
287 - $this->is_plain_text = ! empty( $this->settings['plain_text'] );
288 - return;
284 + if ( $this->settings['plain_text'] ) {
285 + $this->is_plain_text = true;
289 286 }
290 -
291 - $this->is_plain_text = 'plain' === $this->settings['email_style'];
292 287 }
293 288
294 289 /**
295 290 * Set the include_user_info property
@@ -394,9 +389,10 @@
394 389 // The decode is to support [default-html] shortcodes.
395 390 $this->message = html_entity_decode( $this->message );
396 391 }
397 392
398 - $this->message = FrmFieldsHelper::basic_replace_shortcodes( $this->message, $this->form, $this->entry );
393 + $this->message = FrmFieldsHelper::basic_replace_shortcodes( $this->message, $this->form, $this->entry );
394 +
399 395 $prev_mail_body = $this->message;
400 396
401 397 // Make a copy to prevent changes by reference.
402 398 $pass_entry = clone $this->entry;
@@ -402,19 +398,18 @@
402 398 $pass_entry = clone $this->entry;
403 399 $mail_body = FrmEntriesHelper::replace_default_message(
404 400 $prev_mail_body,
405 401 array(
406 - 'id' => $this->entry->id,
407 - 'entry' => $pass_entry,
408 - 'plain_text' => $this->is_plain_text,
409 - 'user_info' => $this->include_user_info,
410 - 'table_style' => $this->settings['email_style'],
402 + 'id' => $this->entry->id,
403 + 'entry' => $pass_entry,
404 + 'plain_text' => $this->is_plain_text,
405 + 'user_info' => $this->include_user_info,
411 406 )
412 407 );
413 408
414 409 // Add the user info if it isn't already included
415 410 if ( $this->include_user_info && $prev_mail_body === $mail_body ) {
416 - $data = $this->entry->description;
411 + $data = $this->entry->description;
417 412 $mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) . "\r\n";
418 413 $this->maybe_add_ip( $mail_body );
419 414 $mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntriesHelper::get_browser( $data['browser'] ) . "\r\n";
420 415 $mail_body .= __( 'Referrer', 'formidable' ) . ': ' . $data['referrer'] . "\r\n";
@@ -421,11 +416,12 @@
421 416 }
422 417
423 418 $this->message = $mail_body;
424 419
420 + $this->message = do_shortcode( $this->message );
421 +
425 422 if ( $this->is_plain_text ) {
426 423 $this->message = wp_specialchars_decode( strip_tags( $this->message ), ENT_QUOTES );
427 - $this->message = str_replace( ' ', '', $this->message );
428 424 } else {
429 425 $this->add_autop();
430 426 }
431 427
@@ -438,10 +434,9 @@
438 434 * @return void
439 435 */
440 436 private function add_autop() {
441 437 $message = $this->message;
442 - preg_match( '/<body[^>]*>([\s\S]*?)<\/body>/', $message, $match );
443 -
438 + $result = preg_match( '/<body[^>]*>([\s\S]*?)<\/body>/', $message, $match );
444 439 if ( ! empty( $match[1] ) ) {
445 440 $this->message = str_replace( $match[1], trim( wpautop( $match[1] ) ), $message );
446 441 } else {
447 442 $this->message = trim( wpautop( $message ) );
@@ -518,10 +513,11 @@
518 513 */
519 514 private function has_recipients() {
520 515 if ( empty( $this->to ) && empty( $this->cc ) && empty( $this->bcc ) ) {
521 516 return false;
517 + } else {
518 + return true;
522 519 }
523 - return true;
524 520 }
525 521
526 522 /**
527 523 * Send an email
@@ -534,9 +530,8 @@
534 530 $this->remove_buddypress_filters();
535 531 $this->add_mandrill_filter();
536 532
537 533 $sent = false;
538 -
539 534 if ( count( $this->to ) > 1 && $this->is_single_recipient ) {
540 535 foreach ( $this->to as $recipient ) {
541 536 $sent = $this->send_single( $recipient );
542 537 }
@@ -575,9 +570,8 @@
575 570 if ( ! $sent ) {
576 571 if ( is_array( $header ) ) {
577 572 $header = implode( "\r\n", $header );
578 573 }
579 -
580 574 $recipient = implode( ',', (array) $recipient );
581 575 $sent = mail( $recipient, $subject, $this->message, $header );
582 576 }
583 577
@@ -626,9 +620,8 @@
626 620 'field_key' => '',
627 621 );
628 622
629 623 $user_id_args['field_id'] = FrmEmailHelper::get_user_id_field_for_form( $form_id );
630 -
631 624 if ( $user_id_args['field_id'] ) {
632 625 $user_id_args['field_key'] = FrmField::get_key_by_id( $user_id_args['field_id'] );
633 626 }
634 627
@@ -672,9 +665,8 @@
672 665 * @return array|string $emails
673 666 */
674 667 private function explode_emails( $emails ) {
675 668 $emails = ( ! empty( $emails ) ? preg_split( '/(,|;)/', $emails ) : '' );
676 -
677 669 if ( is_array( $emails ) ) {
678 670 $emails = array_map( 'trim', $emails );
679 671 } else {
680 672 $emails = trim( $emails );
@@ -700,20 +692,20 @@
700 692
701 693 if ( is_email( $val ) ) {
702 694 // If a plain email is used, no formatting is needed
703 695 continue;
704 - }
696 + } else {
697 + $parts = explode( ' ', $val );
698 + $email = end( $parts );
705 699
706 - $parts = explode( ' ', $val );
707 - $email = end( $parts );
708 -
709 - if ( is_email( $email ) ) {
710 - // If user enters a name and email
711 - $name = trim( str_replace( $email, '', $val ) );
712 - } else {
713 - // If user enters a name without an email
714 - unset( $recipients[ $key ] );
715 - continue;
700 + if ( is_email( $email ) ) {
701 + // If user enters a name and email
702 + $name = trim( str_replace( $email, '', $val ) );
703 + } else {
704 + // If user enters a name without an email
705 + unset( $recipients[ $key ] );
706 + continue;
707 + }
716 708 }
717 709
718 710 $recipients[ $key ] = $this->format_from_email( $name, $email );
719 711 }//end foreach
@@ -743,9 +735,8 @@
743 735 if ( strpos( $from_email, '@yahoo.com' ) ) {
744 736
745 737 // Get the site domain and get rid of www.
746 738 $sitename = strtolower( FrmAppHelper::get_server_value( 'SERVER_NAME' ) );
747 -
748 739 if ( substr( $sitename, 0, 4 ) === 'www.' ) {
749 740 $sitename = substr( $sitename, 4 );
750 741 }
751 742
@@ -768,9 +759,9 @@
768 759 $reply_to = trim( $reply_to );
769 760
770 761 if ( ! is_email( $reply_to ) ) {
771 762 list( $name, $email ) = $this->get_name_and_email_for_sender( $reply_to );
772 - $reply_to = $this->format_from_email( $name, $email );
763 + $reply_to = $this->format_from_email( $name, $email );
773 764 }
774 765
775 766 return $reply_to;
776 767 }
@@ -785,9 +776,8 @@
785 776 * @return string
786 777 */
787 778 private function get_email_from_name( $name ) {
788 779 $email = trim( trim( $name, '>' ), '<' );
789 -
790 780 if ( strpos( $email, '<' ) !== false ) {
791 781 $parts = explode( '<', $email );
792 782 $email = trim( $parts[1], '>' );
793 783 }
@@ -823,10 +813,8 @@
823 813 * @since 3.0.06
824 814 *
825 815 * @param string $name
826 816 * @param string $email
827 - *
828 - * @return string
829 817 */
830 818 private function format_from_email( $name, $email ) {
831 819 if ( '' !== $name ) {
832 820 $email = $name . ' <' . $email . '>';
@@ -891,12 +879,10 @@
891 879 'subject' => $this->subject,
892 880 'message' => $this->message,
893 881 'attachments' => $this->attachments,
894 882 'plain_text' => $this->is_plain_text,
895 - 'email_key' => $this->email_key,
896 883 'form' => $this->form,
897 884 'entry' => $this->entry,
898 - 'email_style' => $this->settings['email_style'],
899 885 );
900 886 }
901 887
902 888 /**