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

940 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 object $action
309 *
310 * @return void
311 */
312 private function set_is_single_recipient( $action ) {
313 $args = array(
314 'form' => $this->form,
315 'entry' => $this->entry,
316 'action' => $action,
317 );
318
319 /**
320 * Send a separate email for email address in the "to" section
321 *
322 * @since 2.2.13
323 */
324 $this->is_single_recipient = apply_filters( 'frm_send_separate_emails', false, $args );
325 }
326
327 /**
328 * Set the charset
329 *
330 * @since 2.03.04
331 *
332 * @return void
333 */
334 private function set_charset() {
335 $this->charset = get_option( 'blog_charset' );
336 }
337
338 /**
339 * Set the content type
340 *
341 * @since 2.03.04
342 *
343 * @return void
344 */
345 private function set_content_type() {
346 if ( $this->is_plain_text ) {
347 $this->content_type = 'text/plain';
348 }
349 }
350
351 /**
352 * Set the subject
353 *
354 * @since 2.03.04
355 *
356 * @return void
357 */
358 private function set_subject() {
359 if ( empty( $this->settings['email_subject'] ) ) {
360 /* translators: %1$s: Form name, %2$s: Site name */
361 $this->subject = sprintf( __( '%1$s Form submitted on %2$s', 'formidable' ), $this->form->name, '[sitename]' );
362 } else {
363 $this->subject = $this->settings['email_subject'];
364 }
365
366 // This also replaces [sitename] shortcode in default.
367 $this->subject = FrmFieldsHelper::basic_replace_shortcodes( $this->subject, $this->form, $this->entry );
368
369 $args = array(
370 'form' => $this->form,
371 'entry' => $this->entry,
372 'email_key' => $this->email_key,
373 );
374 $this->subject = apply_filters( 'frm_email_subject', $this->subject, $args );
375 $this->subject = wp_specialchars_decode( strip_tags( stripslashes( $this->subject ) ), ENT_QUOTES );
376 }
377
378 /**
379 * Set the email message
380 *
381 * @since 2.03.04
382 *
383 * @return void
384 */
385 private function set_message() {
386 $this->message = $this->settings['email_message'];
387
388 if ( ! $this->is_plain_text ) {
389 // The decode is to support [default-html] shortcodes.
390 $this->message = html_entity_decode( $this->message );
391 }
392
393 $this->message = FrmFieldsHelper::basic_replace_shortcodes( $this->message, $this->form, $this->entry );
394
395 $prev_mail_body = $this->message;
396
397 // Make a copy to prevent changes by reference.
398 $pass_entry = clone $this->entry;
399 $mail_body = FrmEntriesHelper::replace_default_message(
400 $prev_mail_body,
401 array(
402 'id' => $this->entry->id,
403 'entry' => $pass_entry,
404 'plain_text' => $this->is_plain_text,
405 'user_info' => $this->include_user_info,
406 )
407 );
408
409 // Add the user info if it isn't already included
410 if ( $this->include_user_info && $prev_mail_body === $mail_body ) {
411 $data = $this->entry->description;
412 $mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) . "\r\n";
413 $this->maybe_add_ip( $mail_body );
414 $mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntriesHelper::get_browser( $data['browser'] ) . "\r\n";
415 $mail_body .= __( 'Referrer', 'formidable' ) . ': ' . $data['referrer'] . "\r\n";
416 }
417
418 $this->message = $mail_body;
419
420 $this->message = do_shortcode( $this->message );
421
422 if ( $this->is_plain_text ) {
423 $this->message = wp_specialchars_decode( strip_tags( $this->message ), ENT_QUOTES );
424 } else {
425 $this->add_autop();
426 }
427
428 $this->message = apply_filters( 'frm_email_message', $this->message, $this->package_atts() );
429 }
430
431 /**
432 * Runs message through autop, extracting the content inside body tag if it has <body>.
433 *
434 * @return void
435 */
436 private function add_autop() {
437 $message = $this->message;
438 $result = preg_match( '/<body[^>]*>([\s\S]*?)<\/body>/', $message, $match );
439 if ( ! empty( $match[1] ) ) {
440 $this->message = str_replace( $match[1], trim( wpautop( $match[1] ) ), $message );
441 } else {
442 $this->message = trim( wpautop( $message ) );
443 }
444 }
445
446 /**
447 * @param string $mail_body
448 *
449 * @return void
450 */
451 private function maybe_add_ip( &$mail_body ) {
452 if ( ! empty( $this->entry->ip ) ) {
453 $mail_body .= __( 'IP Address', 'formidable' ) . ': ' . $this->entry->ip . "\r\n";
454 }
455 }
456
457 /**
458 * Set the attachments for an email message
459 *
460 * @since 2.03.04
461 * @since 5.0.16 added new action_id key to $args.
462 *
463 * @return void
464 */
465 private function set_attachments() {
466 $args = array(
467 'entry' => $this->entry,
468 'email_key' => $this->email_key,
469 'settings' => $this->settings,
470 'action_id' => $this->action_id,
471 );
472
473 $this->attachments = apply_filters( 'frm_notification_attachment', array(), $this->form, $args );
474 }
475
476 /**
477 * Check if an email should send
478 *
479 * @since 2.03.04
480 *
481 * @return bool|mixed|void
482 */
483 public function should_send() {
484 if ( ! $this->has_recipients() ) {
485 $send = false;
486 } else {
487
488 $filter_args = array(
489 'message' => $this->message,
490 'subject' => $this->subject,
491 'recipient' => $this->to,
492 'header' => $this->package_header(),
493 );
494
495 /**
496 * Stop an email based on the message, subject, recipient,
497 * or any information included in the email header
498 *
499 * @since 2.2.8
500 */
501 $send = apply_filters( 'frm_send_email', true, $filter_args );
502 }
503
504 return $send;
505 }
506
507 /**
508 * Check if an email has any recipients
509 *
510 * @since 2.03.04
511 *
512 * @return bool
513 */
514 private function has_recipients() {
515 if ( empty( $this->to ) && empty( $this->cc ) && empty( $this->bcc ) ) {
516 return false;
517 } else {
518 return true;
519 }
520 }
521
522 /**
523 * Send an email
524 *
525 * @since 2.03.04
526 *
527 * @return bool
528 */
529 public function send() {
530 $this->remove_buddypress_filters();
531 $this->add_mandrill_filter();
532
533 $sent = false;
534 if ( count( $this->to ) > 1 && $this->is_single_recipient ) {
535 foreach ( $this->to as $recipient ) {
536 $sent = $this->send_single( $recipient );
537 }
538 } else {
539 $sent = $this->send_single( $this->to );
540 }
541
542 $this->remove_mandrill_filter();
543
544 return $sent;
545 }
546
547 /**
548 * Send a single email
549 *
550 * @since 2.03.04
551 *
552 * @param array|string $recipient
553 *
554 * @return bool
555 */
556 private function send_single( $recipient ) {
557 $header = apply_filters(
558 'frm_email_header',
559 $this->package_header(),
560 array(
561 'to_email' => $recipient,
562 'subject' => $this->subject,
563 )
564 );
565
566 $subject = $this->encode_subject( $this->subject );
567
568 $sent = wp_mail( $recipient, $subject, $this->message, $header, $this->attachments );
569
570 if ( ! $sent ) {
571 if ( is_array( $header ) ) {
572 $header = implode( "\r\n", $header );
573 }
574 $recipient = implode( ',', (array) $recipient );
575 $sent = mail( $recipient, $subject, $this->message, $header );
576 }
577
578 do_action( 'frm_notification', $recipient, $subject, $this->message );
579
580 return $sent;
581 }
582
583 /**
584 * Package the email header
585 *
586 * @since 2.03.04
587 *
588 * @return array
589 */
590 private function package_header() {
591 $header = array();
592
593 if ( ! empty( $this->cc ) ) {
594 $header[] = 'CC: ' . implode( ',', $this->cc );
595 }
596
597 if ( ! empty( $this->bcc ) ) {
598 $header[] = 'BCC: ' . implode( ',', $this->bcc );
599 }
600
601 $header[] = 'From: ' . $this->from;
602 $header[] = 'Reply-To: ' . $this->reply_to;
603 $header[] = 'Content-Type: ' . $this->content_type . '; charset="' . esc_attr( $this->charset ) . '"';
604
605 return $header;
606 }
607
608 /**
609 * Get the userID field ID and key for email settings
610 *
611 * @since 2.03.04
612 *
613 * @param int $form_id
614 *
615 * @return array
616 */
617 private function get_user_id_args( $form_id ) {
618 $user_id_args = array(
619 'field_id' => '',
620 'field_key' => '',
621 );
622
623 $user_id_args['field_id'] = FrmEmailHelper::get_user_id_field_for_form( $form_id );
624 if ( $user_id_args['field_id'] ) {
625 $user_id_args['field_key'] = FrmField::get_key_by_id( $user_id_args['field_id'] );
626 }
627
628 return $user_id_args;
629 }
630
631 /**
632 * Prepare the to, cc, bcc, reply_to, and from setting
633 *
634 * @since 2.03.04
635 *
636 * @param string $value
637 * @param array $user_id_args
638 *
639 * @return string
640 */
641 private function prepare_email_setting( $value, $user_id_args ) {
642 if ( strpos( $value, '[' . $user_id_args['field_id'] . ']' ) !== false ) {
643 $value = str_replace( '[' . $user_id_args['field_id'] . ']', '[' . $user_id_args['field_id'] . ' show="user_email"]', $value );
644 } elseif ( strpos( $value, '[' . $user_id_args['field_key'] . ']' ) !== false ) {
645 $value = str_replace( '[' . $user_id_args['field_key'] . ']', '[' . $user_id_args['field_key'] . ' show="user_email"]', $value );
646 }
647
648 $value = FrmFieldsHelper::basic_replace_shortcodes( $value, $this->form, $this->entry );
649
650 // Remove brackets and add a space in case there isn't one
651 $value = str_replace( '<', ' ', $value );
652 $value = str_replace( array( '"', '>' ), '', $value );
653
654 return $value;
655 }
656
657 /**
658 * Extract the emails from cc and bcc. Allow separation by , or ;.
659 * Trim the emails here as well
660 *
661 * @since 2.03.04
662 *
663 * @param string $emails
664 *
665 * @return array|string $emails
666 */
667 private function explode_emails( $emails ) {
668 $emails = ( ! empty( $emails ) ? preg_split( '/(,|;)/', $emails ) : '' );
669 if ( is_array( $emails ) ) {
670 $emails = array_map( 'trim', $emails );
671 } else {
672 $emails = trim( $emails );
673 }
674
675 return $emails;
676 }
677
678 /**
679 * Format the recipients( to, cc, bcc)
680 *
681 * @param array $recipients
682 *
683 * @return array
684 */
685 private function format_recipients( $recipients ) {
686 if ( empty( $recipients ) ) {
687 return $recipients;
688 }
689
690 foreach ( $recipients as $key => $val ) {
691 $val = trim( $val );
692
693 if ( is_email( $val ) ) {
694 // If a plain email is used, no formatting is needed
695 continue;
696 } else {
697 $parts = explode( ' ', $val );
698 $email = end( $parts );
699
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 }
708 }
709
710 $recipients[ $key ] = $this->format_from_email( $name, $email );
711 }//end foreach
712
713 return $recipients;
714 }
715
716 /**
717 * Format the From header
718 *
719 * @param string $from
720 *
721 * @return string
722 */
723 private function format_from( $from ) {
724 $from = trim( $from );
725
726 if ( is_email( $from ) ) {
727 // If a plain email is used, add the site name so "WordPress" doesn't get added
728 $from_name = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
729 $from_email = $from;
730 } else {
731 list( $from_name, $from_email ) = $this->get_name_and_email_for_sender( $from );
732 }
733
734 // if sending the email from a yahoo address, change it to the WordPress default
735 if ( strpos( $from_email, '@yahoo.com' ) ) {
736
737 // Get the site domain and get rid of www.
738 $sitename = strtolower( FrmAppHelper::get_server_value( 'SERVER_NAME' ) );
739 if ( substr( $sitename, 0, 4 ) === 'www.' ) {
740 $sitename = substr( $sitename, 4 );
741 }
742
743 $from_email = 'wordpress@' . $sitename;
744 }
745
746 return $this->format_from_email( $from_name, $from_email );
747 }
748
749 /**
750 * Format the Reply To property
751 *
752 * @since 2.03.04
753 *
754 * @param string $reply_to
755 *
756 * @return string
757 */
758 private function format_reply_to( $reply_to ) {
759 $reply_to = trim( $reply_to );
760
761 if ( ! is_email( $reply_to ) ) {
762 list( $name, $email ) = $this->get_name_and_email_for_sender( $reply_to );
763 $reply_to = $this->format_from_email( $name, $email );
764 }
765
766 return $reply_to;
767 }
768
769 /**
770 * Get only the email if the name and email have been combined
771 *
772 * @since 3.0.06
773 *
774 * @param string $name
775 *
776 * @return string
777 */
778 private function get_email_from_name( $name ) {
779 $email = trim( trim( $name, '>' ), '<' );
780 if ( strpos( $email, '<' ) !== false ) {
781 $parts = explode( '<', $email );
782 $email = trim( $parts[1], '>' );
783 }
784
785 return $email;
786 }
787
788 /**
789 * Get the name and email for the From or Reply To header
790 *
791 * @since 2.03.04
792 *
793 * @param string $sender
794 *
795 * @return array
796 */
797 private function get_name_and_email_for_sender( $sender ) {
798 $parts = explode( ' ', $sender );
799 $end = end( $parts );
800
801 if ( is_email( $end ) ) {
802 $name = trim( str_replace( $end, '', $sender ) );
803 } else {
804 // Only a name was entered in the From or Reply To field
805 $name = $sender;
806 $end = get_option( 'admin_email' );
807 }
808
809 return array( $name, $end );
810 }
811
812 /**
813 * @since 3.0.06
814 *
815 * @param string $name
816 * @param string $email
817 */
818 private function format_from_email( $name, $email ) {
819 if ( '' !== $name ) {
820 $email = $name . ' <' . $email . '>';
821 }
822
823 return $email;
824 }
825
826 /**
827 * Remove phone numbers from To addresses
828 * Send the phone numbers to the frm_send_to_not_email hook
829 *
830 * @since 2.03.04
831 *
832 * @return void
833 */
834 private function handle_phone_numbers() {
835
836 foreach ( $this->to as $key => $recipient ) {
837 if ( '[admin_email]' !== $recipient && ! is_email( $recipient ) ) {
838 $recipient = explode( ' ', $recipient );
839
840 if ( is_email( end( $recipient ) ) ) {
841 continue;
842 }
843
844 do_action(
845 'frm_send_to_not_email',
846 array(
847 'e' => $recipient,
848 'subject' => $this->subject,
849 'mail_body' => $this->message,
850 'reply_to' => $this->reply_to,
851 'from' => $this->from,
852 'plain_text' => $this->is_plain_text,
853 'attachments' => $this->attachments,
854 'form' => $this->form,
855 'email_key' => $key,
856 )
857 );
858
859 // Remove phone number from to addresses
860 unset( $this->to[ $key ] );
861 }//end if
862 }//end foreach
863 }
864
865 /**
866 * Package an array of FrmEmail properties
867 *
868 * @since 2.03.04
869 *
870 * @return array
871 */
872 public function package_atts() {
873 return array(
874 'to_email' => $this->to,
875 'cc' => $this->cc,
876 'bcc' => $this->bcc,
877 'from' => $this->from,
878 'reply_to' => $this->reply_to,
879 'subject' => $this->subject,
880 'message' => $this->message,
881 'attachments' => $this->attachments,
882 'plain_text' => $this->is_plain_text,
883 'form' => $this->form,
884 'entry' => $this->entry,
885 );
886 }
887
888 /**
889 * Remove the Buddypress email filters
890 *
891 * @since 2.03.04
892 *
893 * @return void
894 */
895 private function remove_buddypress_filters() {
896 remove_filter( 'wp_mail_from', 'bp_core_email_from_address_filter' );
897 remove_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' );
898 }
899
900 /**
901 * Add Mandrill line break filter
902 * Remove line breaks in HTML emails to prevent conflicts with Mandrill
903 *
904 * @since 2.03.04
905 *
906 * @return void
907 */
908 private function add_mandrill_filter() {
909 if ( ! $this->is_plain_text ) {
910 add_filter( 'mandrill_nl2br', 'FrmEmailHelper::remove_mandrill_br' );
911 }
912 }
913
914 /**
915 * Remove Mandrill line break filter
916 *
917 * @since 2.03.04
918 *
919 * @return void
920 */
921 private function remove_mandrill_filter() {
922 remove_filter( 'mandrill_nl2br', 'FrmEmailHelper::remove_mandrill_br' );
923 }
924
925 /**
926 * Encode the email subject
927 *
928 * @param string $subject
929 *
930 * @return string
931 */
932 private function encode_subject( $subject ) {
933 if ( apply_filters( 'frm_encode_subject', false, $subject ) ) {
934 $subject = '=?' . $this->charset . '?B?' . base64_encode( $subject ) . '?=';
935 }
936
937 return $subject;
938 }
939 }
940