PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.3
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.3
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
formidable / classes / models / FrmEmail.php

FrmEmail.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 6.3, at classes/models/FrmEmail.php

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