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

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