PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.22
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.22
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 +52 -49 6.276.22 View file →
@@ -223,11 +223,13 @@
223 223 */
224 224 private function prepare_additional_recipients( $recipients, $user_id_args ) {
225 225 $recipients = $this->prepare_email_setting( $recipients, $user_id_args );
226 226 $recipients = $this->explode_emails( $recipients );
227 +
227 228 $recipients = array_unique( (array) $recipients );
229 + $recipients = $this->format_recipients( $recipients );
228 230
229 - return $this->format_recipients( $recipients );
231 + return $recipients;
230 232 }
231 233
232 234 /**
233 235 * Set the From addresses
@@ -234,9 +236,8 @@
234 236 *
235 237 * @since 2.03.04
236 238 *
237 239 * @param array $user_id_args
238 - *
239 240 * @return void
240 241 */
241 242 private function set_from( $user_id_args ) {
242 243 if ( empty( $this->settings['from'] ) ) {
@@ -279,15 +280,11 @@
279 280 *
280 281 * @return void
281 282 */
282 283 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;
284 + if ( $this->settings['plain_text'] ) {
285 + $this->is_plain_text = true;
287 286 }
288 -
289 - $this->is_plain_text = 'plain' === $this->settings['email_style'];
290 287 }
291 288
292 289 /**
293 290 * Set the include_user_info property
@@ -400,13 +397,12 @@
400 397 $pass_entry = clone $this->entry;
401 398 $mail_body = FrmEntriesHelper::replace_default_message(
402 399 $prev_mail_body,
403 400 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'],
401 + 'id' => $this->entry->id,
402 + 'entry' => $pass_entry,
403 + 'plain_text' => $this->is_plain_text,
404 + 'user_info' => $this->include_user_info,
409 405 )
410 406 );
411 407
412 408 // Add the user info if it isn't already included
@@ -436,10 +432,9 @@
436 432 * @return void
437 433 */
438 434 private function add_autop() {
439 435 $message = $this->message;
440 - preg_match( '/<body[^>]*>([\s\S]*?)<\/body>/', $message, $match );
441 -
436 + $result = preg_match( '/<body[^>]*>([\s\S]*?)<\/body>/', $message, $match );
442 437 if ( ! empty( $match[1] ) ) {
443 438 $this->message = str_replace( $match[1], trim( wpautop( $match[1] ) ), $message );
444 439 } else {
445 440 $this->message = trim( wpautop( $message ) );
@@ -484,24 +479,28 @@
484 479 * @return bool|mixed|void
485 480 */
486 481 public function should_send() {
487 482 if ( ! $this->has_recipients() ) {
488 - return false;
483 + $send = false;
484 + } else {
485 +
486 + $filter_args = array(
487 + 'message' => $this->message,
488 + 'subject' => $this->subject,
489 + 'recipient' => $this->to,
490 + 'header' => $this->package_header(),
491 + );
492 +
493 + /**
494 + * Stop an email based on the message, subject, recipient,
495 + * or any information included in the email header
496 + *
497 + * @since 2.2.8
498 + */
499 + $send = apply_filters( 'frm_send_email', true, $filter_args );
489 500 }
490 501
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 );
502 + return $send;
504 503 }
505 504
506 505 /**
507 506 * Check if an email has any recipients
@@ -510,9 +509,12 @@
510 509 *
511 510 * @return bool
512 511 */
513 512 private function has_recipients() {
514 - return ! ( empty( $this->to ) && empty( $this->cc ) && empty( $this->bcc ) );
513 + if ( empty( $this->to ) && empty( $this->cc ) && empty( $this->bcc ) ) {
514 + return false;
515 + }
516 + return true;
515 517 }
516 518
517 519 /**
518 520 * Send an email
@@ -525,9 +527,8 @@
525 527 $this->remove_buddypress_filters();
526 528 $this->add_mandrill_filter();
527 529
528 530 $sent = false;
529 -
530 531 if ( count( $this->to ) > 1 && $this->is_single_recipient ) {
531 532 foreach ( $this->to as $recipient ) {
532 533 $sent = $this->send_single( $recipient );
533 534 }
@@ -559,15 +560,15 @@
559 560 )
560 561 );
561 562
562 563 $subject = $this->encode_subject( $this->subject );
563 - $sent = wp_mail( $recipient, $subject, $this->message, $header, $this->attachments );
564 564
565 + $sent = wp_mail( $recipient, $subject, $this->message, $header, $this->attachments );
566 +
565 567 if ( ! $sent ) {
566 568 if ( is_array( $header ) ) {
567 569 $header = implode( "\r\n", $header );
568 570 }
569 -
570 571 $recipient = implode( ',', (array) $recipient );
571 572 $sent = mail( $recipient, $subject, $this->message, $header );
572 573 }
573 574
@@ -616,9 +617,8 @@
616 617 'field_key' => '',
617 618 );
618 619
619 620 $user_id_args['field_id'] = FrmEmailHelper::get_user_id_field_for_form( $form_id );
620 -
621 621 if ( $user_id_args['field_id'] ) {
622 622 $user_id_args['field_key'] = FrmField::get_key_by_id( $user_id_args['field_id'] );
623 623 }
624 624
@@ -635,11 +635,11 @@
635 635 *
636 636 * @return string
637 637 */
638 638 private function prepare_email_setting( $value, $user_id_args ) {
639 - if ( str_contains( $value, '[' . $user_id_args['field_id'] . ']' ) ) {
639 + if ( strpos( $value, '[' . $user_id_args['field_id'] . ']' ) !== false ) {
640 640 $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'] . ']' ) ) {
641 + } elseif ( strpos( $value, '[' . $user_id_args['field_key'] . ']' ) !== false ) {
642 642 $value = str_replace( '[' . $user_id_args['field_key'] . ']', '[' . $user_id_args['field_key'] . ' show="user_email"]', $value );
643 643 }
644 644
645 645 $value = FrmFieldsHelper::basic_replace_shortcodes( $value, $this->form, $this->entry );
@@ -645,10 +645,11 @@
645 645 $value = FrmFieldsHelper::basic_replace_shortcodes( $value, $this->form, $this->entry );
646 646
647 647 // Remove brackets and add a space in case there isn't one
648 648 $value = str_replace( '<', ' ', $value );
649 + $value = str_replace( array( '"', '>' ), '', $value );
649 650
650 - return str_replace( array( '"', '>' ), '', $value );
651 + return $value;
651 652 }
652 653
653 654 /**
654 655 * Extract the emails from cc and bcc. Allow separation by , or ;.
@@ -660,10 +661,16 @@
660 661 *
661 662 * @return array|string $emails
662 663 */
663 664 private function explode_emails( $emails ) {
664 - $emails = ! empty( $emails ) ? preg_split( '/(,|;)/', $emails ) : '';
665 - return is_array( $emails ) ? array_map( 'trim', $emails ) : trim( $emails );
665 + $emails = ( ! empty( $emails ) ? preg_split( '/(,|;)/', $emails ) : '' );
666 + if ( is_array( $emails ) ) {
667 + $emails = array_map( 'trim', $emails );
668 + } else {
669 + $emails = trim( $emails );
670 + }
671 +
672 + return $emails;
666 673 }
667 674
668 675 /**
669 676 * Format the recipients( to, cc, bcc)
@@ -672,9 +679,9 @@
672 679 *
673 680 * @return array
674 681 */
675 682 private function format_recipients( $recipients ) {
676 - if ( ! $recipients ) {
683 + if ( empty( $recipients ) ) {
677 684 return $recipients;
678 685 }
679 686
680 687 foreach ( $recipients as $key => $val ) {
@@ -721,13 +728,13 @@
721 728 list( $from_name, $from_email ) = $this->get_name_and_email_for_sender( $from );
722 729 }
723 730
724 731 // if sending the email from a yahoo address, change it to the WordPress default
725 - if ( str_contains( $from_email, '@yahoo.com' ) ) {
732 + if ( strpos( $from_email, '@yahoo.com' ) ) {
733 +
726 734 // Get the site domain and get rid of www.
727 735 $sitename = strtolower( FrmAppHelper::get_server_value( 'SERVER_NAME' ) );
728 -
729 - if ( str_starts_with( $sitename, 'www.' ) ) {
736 + if ( substr( $sitename, 0, 4 ) === 'www.' ) {
730 737 $sitename = substr( $sitename, 4 );
731 738 }
732 739
733 740 $from_email = 'wordpress@' . $sitename;
@@ -766,10 +773,9 @@
766 773 * @return string
767 774 */
768 775 private function get_email_from_name( $name ) {
769 776 $email = trim( trim( $name, '>' ), '<' );
770 -
771 - if ( str_contains( $email, '<' ) ) {
777 + if ( strpos( $email, '<' ) !== false ) {
772 778 $parts = explode( '<', $email );
773 779 $email = trim( $parts[1], '>' );
774 780 }
775 781
@@ -804,10 +810,8 @@
804 810 * @since 3.0.06
805 811 *
806 812 * @param string $name
807 813 * @param string $email
808 - *
809 - * @return string
810 814 */
811 815 private function format_from_email( $name, $email ) {
812 816 if ( '' !== $name ) {
813 817 $email = $name . ' <' . $email . '>';
@@ -824,8 +828,9 @@
824 828 *
825 829 * @return void
826 830 */
827 831 private function handle_phone_numbers() {
832 +
828 833 foreach ( $this->to as $key => $recipient ) {
829 834 if ( '[admin_email]' !== $recipient && ! is_email( $recipient ) ) {
830 835 $recipient = explode( ' ', $recipient );
831 836
@@ -871,12 +876,10 @@
871 876 'subject' => $this->subject,
872 877 'message' => $this->message,
873 878 'attachments' => $this->attachments,
874 879 'plain_text' => $this->is_plain_text,
875 - 'email_key' => $this->email_key,
876 880 'form' => $this->form,
877 881 'entry' => $this->entry,
878 - 'email_style' => $this->settings['email_style'],
879 882 );
880 883 }
881 884
882 885 /**