PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.21
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.21
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 +47 -48 6.56.21 View file →
@@ -8,94 +8,94 @@
8 8 */
9 9 class FrmEmail {
10 10
11 11 /**
12 - * @var string $email_key
12 + * @var string
13 13 */
14 14 private $email_key = '';
15 15
16 16 /**
17 - * @var array $to
17 + * @var array
18 18 */
19 19 private $to = array();
20 20
21 21 /**
22 - * @var array $cc
22 + * @var array
23 23 */
24 24 private $cc = array();
25 25
26 26 /**
27 - * @var array $bcc
27 + * @var array
28 28 */
29 29 private $bcc = array();
30 30
31 31 /**
32 - * @var string $from
32 + * @var string
33 33 */
34 34 private $from = '';
35 35
36 36 /**
37 - * @var string $reply_to
37 + * @var string
38 38 */
39 39 private $reply_to = '';
40 40
41 41 /**
42 - * @var string $subject
42 + * @var string
43 43 */
44 44 private $subject = '';
45 45
46 46 /**
47 - * @var string $message
47 + * @var string
48 48 */
49 49 private $message = '';
50 50
51 51 /**
52 - * @var array $attachments
52 + * @var array
53 53 */
54 54 private $attachments = array();
55 55
56 56 /**
57 - * @var bool $is_plain_text
57 + * @var bool
58 58 */
59 59 private $is_plain_text = false;
60 60
61 61 /**
62 - * @var bool $is_single_recipient
62 + * @var bool
63 63 */
64 64 private $is_single_recipient = false;
65 65
66 66 /**
67 - * @var bool $include_user_info
67 + * @var bool
68 68 */
69 69 private $include_user_info = false;
70 70
71 71 /**
72 - * @var string $charset
72 + * @var string
73 73 */
74 74 private $charset = '';
75 75
76 76 /**
77 - * @var string $content_type
77 + * @var string
78 78 */
79 79 private $content_type = 'text/html';
80 80
81 81 /**
82 - * @var array $settings
82 + * @var array
83 83 */
84 84 private $settings = array();
85 85
86 86 /**
87 - * @var stdClass $entry
87 + * @var stdClass
88 88 */
89 89 private $entry;
90 90
91 91 /**
92 - * @var stdClass $form
92 + * @var stdClass
93 93 */
94 94 private $form;
95 95
96 96 /**
97 - * @var int $action_id
97 + * @var int
98 98 */
99 99 private $action_id = 0;
100 100
101 101 /**
@@ -216,9 +216,9 @@
216 216 *
217 217 * @since 2.03.04
218 218 *
219 219 * @param string $recipients
220 - * @param array $user_id_args
220 + * @param array $user_id_args
221 221 *
222 222 * @return array
223 223 */
224 224 private function prepare_additional_recipients( $recipients, $user_id_args ) {
@@ -240,9 +240,9 @@
240 240 * @return void
241 241 */
242 242 private function set_from( $user_id_args ) {
243 243 if ( empty( $this->settings['from'] ) ) {
244 - $from = get_option( 'admin_email' );
244 + $from = FrmEmailHelper::get_default_from_email();
245 245 } else {
246 246 $from = $this->prepare_email_setting( $this->settings['from'], $user_id_args );
247 247 }
248 248
@@ -304,9 +304,8 @@
304 304 * Set the is_single_recipient property
305 305 *
306 306 * @since 2.03.04
307 307 *
308 - * @param $action
309 308 * @param object $action
310 309 *
311 310 * @return void
312 311 */
@@ -386,16 +385,18 @@
386 385 private function set_message() {
387 386 $this->message = $this->settings['email_message'];
388 387
389 388 if ( ! $this->is_plain_text ) {
390 - $this->message = html_entity_decode( $this->message ); // The decode is to support [default-html] shortcodes.
389 + // The decode is to support [default-html] shortcodes.
390 + $this->message = html_entity_decode( $this->message );
391 391 }
392 392
393 - $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 + $prev_mail_body = $this->message;
394 395
395 - $prev_mail_body = $this->message;
396 - $pass_entry = clone $this->entry; // make a copy to prevent changes by reference
397 - $mail_body = FrmEntriesHelper::replace_default_message(
396 + // Make a copy to prevent changes by reference.
397 + $pass_entry = clone $this->entry;
398 + $mail_body = FrmEntriesHelper::replace_default_message(
398 399 $prev_mail_body,
399 400 array(
400 401 'id' => $this->entry->id,
401 402 'entry' => $pass_entry,
@@ -405,9 +406,9 @@
405 406 );
406 407
407 408 // Add the user info if it isn't already included
408 409 if ( $this->include_user_info && $prev_mail_body === $mail_body ) {
409 - $data = $this->entry->description;
410 + $data = $this->entry->description;
410 411 $mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) . "\r\n";
411 412 $this->maybe_add_ip( $mail_body );
412 413 $mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntriesHelper::get_browser( $data['browser'] ) . "\r\n";
413 414 $mail_body .= __( 'Referrer', 'formidable' ) . ': ' . $data['referrer'] . "\r\n";
@@ -414,12 +415,11 @@
414 415 }
415 416
416 417 $this->message = $mail_body;
417 418
418 - $this->message = do_shortcode( $this->message );
419 -
420 419 if ( $this->is_plain_text ) {
421 420 $this->message = wp_specialchars_decode( strip_tags( $this->message ), ENT_QUOTES );
421 + $this->message = str_replace( ' ', '', $this->message );
422 422 } else {
423 423 $this->add_autop();
424 424 }
425 425
@@ -511,11 +511,10 @@
511 511 */
512 512 private function has_recipients() {
513 513 if ( empty( $this->to ) && empty( $this->cc ) && empty( $this->bcc ) ) {
514 514 return false;
515 - } else {
516 - return true;
517 515 }
516 + return true;
518 517 }
519 518
520 519 /**
521 520 * Send an email
@@ -607,9 +606,9 @@
607 606 * Get the userID field ID and key for email settings
608 607 *
609 608 * @since 2.03.04
610 609 *
611 - * @param $form_id
610 + * @param int $form_id
612 611 *
613 612 * @return array
614 613 */
615 614 private function get_user_id_args( $form_id ) {
@@ -631,9 +630,9 @@
631 630 *
632 631 * @since 2.03.04
633 632 *
634 633 * @param string $value
635 - * @param array $user_id_args
634 + * @param array $user_id_args
636 635 *
637 636 * @return string
638 637 */
639 638 private function prepare_email_setting( $value, $user_id_args ) {
@@ -690,24 +689,24 @@
690 689
691 690 if ( is_email( $val ) ) {
692 691 // If a plain email is used, no formatting is needed
693 692 continue;
693 + }
694 +
695 + $parts = explode( ' ', $val );
696 + $email = end( $parts );
697 +
698 + if ( is_email( $email ) ) {
699 + // If user enters a name and email
700 + $name = trim( str_replace( $email, '', $val ) );
694 701 } else {
695 - $parts = explode( ' ', $val );
696 - $email = end( $parts );
697 -
698 - if ( is_email( $email ) ) {
699 - // If user enters a name and email
700 - $name = trim( str_replace( $email, '', $val ) );
701 - } else {
702 - // If user enters a name without an email
703 - unset( $recipients[ $key ] );
704 - continue;
705 - }
702 + // If user enters a name without an email
703 + unset( $recipients[ $key ] );
704 + continue;
706 705 }
707 706
708 707 $recipients[ $key ] = $this->format_from_email( $name, $email );
709 - }
708 + }//end foreach
710 709
711 710 return $recipients;
712 711 }
713 712
@@ -757,9 +756,9 @@
757 756 $reply_to = trim( $reply_to );
758 757
759 758 if ( ! is_email( $reply_to ) ) {
760 759 list( $name, $email ) = $this->get_name_and_email_for_sender( $reply_to );
761 - $reply_to = $this->format_from_email( $name, $email );
760 + $reply_to = $this->format_from_email( $name, $email );
762 761 }
763 762
764 763 return $reply_to;
765 764 }
@@ -855,10 +854,10 @@
855 854 );
856 855
857 856 // Remove phone number from to addresses
858 857 unset( $this->to[ $key ] );
859 - }
860 - }
858 + }//end if
859 + }//end foreach
861 860 }
862 861
863 862 /**
864 863 * Package an array of FrmEmail properties