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

939 lines 20.1 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 ( $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 $prev_mail_body = $this->message;
395
396 // Make a copy to prevent changes by reference.
397 $pass_entry = clone $this->entry;
398 $mail_body = FrmEntriesHelper::replace_default_message(
399 $prev_mail_body,
400 array(
401 'id' => $this->entry->id,
402 'entry' => $pass_entry,
403 'plain_text' => $this->is_plain_text,
404 'user_info' => $this->include_user_info,
405 )
406 );
407
408 // Add the user info if it isn't already included
409 if ( $this->include_user_info && $prev_mail_body === $mail_body ) {
410 $data = $this->entry->description;
411 $mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) . "\r\n";
412 $this->maybe_add_ip( $mail_body );
413 $mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntriesHelper::get_browser( $data['browser'] ) . "\r\n";
414 $mail_body .= __( 'Referrer', 'formidable' ) . ': ' . $data['referrer'] . "\r\n";
415 }
416
417 $this->message = $mail_body;
418
419 $this->message = do_shortcode( $this->message );
420
421 if ( $this->is_plain_text ) {
422 $this->message = wp_specialchars_decode( strip_tags( $this->message ), ENT_QUOTES );
423 $this->message = str_replace( '&nbsp;', '', $this->message );
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 }
518 return true;
519 }
520
521 /**
522 * Send an email
523 *
524 * @since 2.03.04
525 *
526 * @return bool
527 */
528 public function send() {
529 $this->remove_buddypress_filters();
530 $this->add_mandrill_filter();
531
532 $sent = false;
533 if ( count( $this->to ) > 1 && $this->is_single_recipient ) {
534 foreach ( $this->to as $recipient ) {
535 $sent = $this->send_single( $recipient );
536 }
537 } else {
538 $sent = $this->send_single( $this->to );
539 }
540
541 $this->remove_mandrill_filter();
542
543 return $sent;
544 }
545
546 /**
547 * Send a single email
548 *
549 * @since 2.03.04
550 *
551 * @param array|string $recipient
552 *
553 * @return bool
554 */
555 private function send_single( $recipient ) {
556 $header = apply_filters(
557 'frm_email_header',
558 $this->package_header(),
559 array(
560 'to_email' => $recipient,
561 'subject' => $this->subject,
562 )
563 );
564
565 $subject = $this->encode_subject( $this->subject );
566
567 $sent = wp_mail( $recipient, $subject, $this->message, $header, $this->attachments );
568
569 if ( ! $sent ) {
570 if ( is_array( $header ) ) {
571 $header = implode( "\r\n", $header );
572 }
573 $recipient = implode( ',', (array) $recipient );
574 $sent = mail( $recipient, $subject, $this->message, $header );
575 }
576
577 do_action( 'frm_notification', $recipient, $subject, $this->message );
578
579 return $sent;
580 }
581
582 /**
583 * Package the email header
584 *
585 * @since 2.03.04
586 *
587 * @return array
588 */
589 private function package_header() {
590 $header = array();
591
592 if ( ! empty( $this->cc ) ) {
593 $header[] = 'CC: ' . implode( ',', $this->cc );
594 }
595
596 if ( ! empty( $this->bcc ) ) {
597 $header[] = 'BCC: ' . implode( ',', $this->bcc );
598 }
599
600 $header[] = 'From: ' . $this->from;
601 $header[] = 'Reply-To: ' . $this->reply_to;
602 $header[] = 'Content-Type: ' . $this->content_type . '; charset="' . esc_attr( $this->charset ) . '"';
603
604 return $header;
605 }
606
607 /**
608 * Get the userID field ID and key for email settings
609 *
610 * @since 2.03.04
611 *
612 * @param int $form_id
613 *
614 * @return array
615 */
616 private function get_user_id_args( $form_id ) {
617 $user_id_args = array(
618 'field_id' => '',
619 'field_key' => '',
620 );
621
622 $user_id_args['field_id'] = FrmEmailHelper::get_user_id_field_for_form( $form_id );
623 if ( $user_id_args['field_id'] ) {
624 $user_id_args['field_key'] = FrmField::get_key_by_id( $user_id_args['field_id'] );
625 }
626
627 return $user_id_args;
628 }
629
630 /**
631 * Prepare the to, cc, bcc, reply_to, and from setting
632 *
633 * @since 2.03.04
634 *
635 * @param string $value
636 * @param array $user_id_args
637 *
638 * @return string
639 */
640 private function prepare_email_setting( $value, $user_id_args ) {
641 if ( strpos( $value, '[' . $user_id_args['field_id'] . ']' ) !== false ) {
642 $value = str_replace( '[' . $user_id_args['field_id'] . ']', '[' . $user_id_args['field_id'] . ' show="user_email"]', $value );
643 } elseif ( strpos( $value, '[' . $user_id_args['field_key'] . ']' ) !== false ) {
644 $value = str_replace( '[' . $user_id_args['field_key'] . ']', '[' . $user_id_args['field_key'] . ' show="user_email"]', $value );
645 }
646
647 $value = FrmFieldsHelper::basic_replace_shortcodes( $value, $this->form, $this->entry );
648
649 // Remove brackets and add a space in case there isn't one
650 $value = str_replace( '<', ' ', $value );
651 $value = str_replace( array( '"', '>' ), '', $value );
652
653 return $value;
654 }
655
656 /**
657 * Extract the emails from cc and bcc. Allow separation by , or ;.
658 * Trim the emails here as well
659 *
660 * @since 2.03.04
661 *
662 * @param string $emails
663 *
664 * @return array|string $emails
665 */
666 private function explode_emails( $emails ) {
667 $emails = ( ! empty( $emails ) ? preg_split( '/(,|;)/', $emails ) : '' );
668 if ( is_array( $emails ) ) {
669 $emails = array_map( 'trim', $emails );
670 } else {
671 $emails = trim( $emails );
672 }
673
674 return $emails;
675 }
676
677 /**
678 * Format the recipients( to, cc, bcc)
679 *
680 * @param array $recipients
681 *
682 * @return array
683 */
684 private function format_recipients( $recipients ) {
685 if ( empty( $recipients ) ) {
686 return $recipients;
687 }
688
689 foreach ( $recipients as $key => $val ) {
690 $val = trim( $val );
691
692 if ( is_email( $val ) ) {
693 // If a plain email is used, no formatting is needed
694 continue;
695 }
696
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 $recipients[ $key ] = $this->format_from_email( $name, $email );
710 }//end foreach
711
712 return $recipients;
713 }
714
715 /**
716 * Format the From header
717 *
718 * @param string $from
719 *
720 * @return string
721 */
722 private function format_from( $from ) {
723 $from = trim( $from );
724
725 if ( is_email( $from ) ) {
726 // If a plain email is used, add the site name so "WordPress" doesn't get added
727 $from_name = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
728 $from_email = $from;
729 } else {
730 list( $from_name, $from_email ) = $this->get_name_and_email_for_sender( $from );
731 }
732
733 // if sending the email from a yahoo address, change it to the WordPress default
734 if ( strpos( $from_email, '@yahoo.com' ) ) {
735
736 // Get the site domain and get rid of www.
737 $sitename = strtolower( FrmAppHelper::get_server_value( 'SERVER_NAME' ) );
738 if ( substr( $sitename, 0, 4 ) === 'www.' ) {
739 $sitename = substr( $sitename, 4 );
740 }
741
742 $from_email = 'wordpress@' . $sitename;
743 }
744
745 return $this->format_from_email( $from_name, $from_email );
746 }
747
748 /**
749 * Format the Reply To property
750 *
751 * @since 2.03.04
752 *
753 * @param string $reply_to
754 *
755 * @return string
756 */
757 private function format_reply_to( $reply_to ) {
758 $reply_to = trim( $reply_to );
759
760 if ( ! is_email( $reply_to ) ) {
761 list( $name, $email ) = $this->get_name_and_email_for_sender( $reply_to );
762 $reply_to = $this->format_from_email( $name, $email );
763 }
764
765 return $reply_to;
766 }
767
768 /**
769 * Get only the email if the name and email have been combined
770 *
771 * @since 3.0.06
772 *
773 * @param string $name
774 *
775 * @return string
776 */
777 private function get_email_from_name( $name ) {
778 $email = trim( trim( $name, '>' ), '<' );
779 if ( strpos( $email, '<' ) !== false ) {
780 $parts = explode( '<', $email );
781 $email = trim( $parts[1], '>' );
782 }
783
784 return $email;
785 }
786
787 /**
788 * Get the name and email for the From or Reply To header
789 *
790 * @since 2.03.04
791 *
792 * @param string $sender
793 *
794 * @return array
795 */
796 private function get_name_and_email_for_sender( $sender ) {
797 $parts = explode( ' ', $sender );
798 $end = end( $parts );
799
800 if ( is_email( $end ) ) {
801 $name = trim( str_replace( $end, '', $sender ) );
802 } else {
803 // Only a name was entered in the From or Reply To field
804 $name = $sender;
805 $end = get_option( 'admin_email' );
806 }
807
808 return array( $name, $end );
809 }
810
811 /**
812 * @since 3.0.06
813 *
814 * @param string $name
815 * @param string $email
816 */
817 private function format_from_email( $name, $email ) {
818 if ( '' !== $name ) {
819 $email = $name . ' <' . $email . '>';
820 }
821
822 return $email;
823 }
824
825 /**
826 * Remove phone numbers from To addresses
827 * Send the phone numbers to the frm_send_to_not_email hook
828 *
829 * @since 2.03.04
830 *
831 * @return void
832 */
833 private function handle_phone_numbers() {
834
835 foreach ( $this->to as $key => $recipient ) {
836 if ( '[admin_email]' !== $recipient && ! is_email( $recipient ) ) {
837 $recipient = explode( ' ', $recipient );
838
839 if ( is_email( end( $recipient ) ) ) {
840 continue;
841 }
842
843 do_action(
844 'frm_send_to_not_email',
845 array(
846 'e' => $recipient,
847 'subject' => $this->subject,
848 'mail_body' => $this->message,
849 'reply_to' => $this->reply_to,
850 'from' => $this->from,
851 'plain_text' => $this->is_plain_text,
852 'attachments' => $this->attachments,
853 'form' => $this->form,
854 'email_key' => $key,
855 )
856 );
857
858 // Remove phone number from to addresses
859 unset( $this->to[ $key ] );
860 }//end if
861 }//end foreach
862 }
863
864 /**
865 * Package an array of FrmEmail properties
866 *
867 * @since 2.03.04
868 *
869 * @return array
870 */
871 public function package_atts() {
872 return array(
873 'to_email' => $this->to,
874 'cc' => $this->cc,
875 'bcc' => $this->bcc,
876 'from' => $this->from,
877 'reply_to' => $this->reply_to,
878 'subject' => $this->subject,
879 'message' => $this->message,
880 'attachments' => $this->attachments,
881 'plain_text' => $this->is_plain_text,
882 'form' => $this->form,
883 'entry' => $this->entry,
884 );
885 }
886
887 /**
888 * Remove the Buddypress email filters
889 *
890 * @since 2.03.04
891 *
892 * @return void
893 */
894 private function remove_buddypress_filters() {
895 remove_filter( 'wp_mail_from', 'bp_core_email_from_address_filter' );
896 remove_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' );
897 }
898
899 /**
900 * Add Mandrill line break filter
901 * Remove line breaks in HTML emails to prevent conflicts with Mandrill
902 *
903 * @since 2.03.04
904 *
905 * @return void
906 */
907 private function add_mandrill_filter() {
908 if ( ! $this->is_plain_text ) {
909 add_filter( 'mandrill_nl2br', 'FrmEmailHelper::remove_mandrill_br' );
910 }
911 }
912
913 /**
914 * Remove Mandrill line break filter
915 *
916 * @since 2.03.04
917 *
918 * @return void
919 */
920 private function remove_mandrill_filter() {
921 remove_filter( 'mandrill_nl2br', 'FrmEmailHelper::remove_mandrill_br' );
922 }
923
924 /**
925 * Encode the email subject
926 *
927 * @param string $subject
928 *
929 * @return string
930 */
931 private function encode_subject( $subject ) {
932 if ( apply_filters( 'frm_encode_subject', false, $subject ) ) {
933 $subject = '=?' . $this->charset . '?B?' . base64_encode( $subject ) . '?=';
934 }
935
936 return $subject;
937 }
938 }
939