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

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