PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 4.02.04
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v4.02.04
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 / FrmNotification.php

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

88 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // TODO: change class name to FrmEmailController by 08/2017 or later
4 class FrmNotification {
5 public function __construct() {
6 if ( ! defined( 'ABSPATH' ) ) {
7 die( 'You are not allowed to call this page directly.' );
8 }
9
10 self::hook_emails_to_action();
11 }
12
13 /**
14 * Trigger an email action
15 *
16 * @param object $action
17 * @param object $entry
18 * @param object $form
19 */
20 public static function trigger_email( $action, $entry, $form ) {
21 $email = new FrmEmail( $action, $entry, $form );
22
23 if ( ! $email->should_send() ) {
24 return;
25 }
26
27 $sent = $email->send();
28
29 if ( $sent ) {
30 self::print_recipients( $email->package_atts() );
31 }
32 }
33
34 /**
35 * Remove the trigger_email function from the frm_trigger_email_action hook
36 *
37 * @since 2.03.04
38 */
39 public static function stop_emails() {
40 remove_action( 'frm_trigger_email_action', 'FrmNotification::trigger_email', 10 );
41 }
42
43 /**
44 * Hook the trigger_email function to frm_trigger_email_action action
45 *
46 * @since 2.03.04
47 */
48 public static function hook_emails_to_action() {
49 add_action( 'frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3 );
50 }
51
52 /**
53 * Print the recipients
54 *
55 * @since 2.03.04
56 *
57 * @param array $atts
58 */
59 private static function print_recipients( $atts ) {
60 if ( apply_filters( 'frm_echo_emails', false ) ) {
61
62 $sent_to = array_merge( (array) $atts['to_email'], (array) $atts['cc'], (array) $atts['bcc'] );
63 $sent_to = array_filter( $sent_to );
64
65 $temp = str_replace( '<', '&lt;', $sent_to );
66 echo ' ' . FrmAppHelper::kses( implode( ', ', (array) $temp ) ); // WPCS: XSS ok.
67 }
68 }
69
70 /**
71 * @deprecated 2.03.04
72 * @codeCoverageIgnore
73 */
74 public static function remove_mandrill_br() {
75 _deprecated_function( __FUNCTION__, '2.03.04', 'FrmEmailHelper::remove_mandrill_br' );
76
77 return FrmEmailHelper::remove_mandrill_br();
78 }
79
80 /**
81 * @deprecated 2.03.04
82 * @codeCoverageIgnore
83 */
84 public static function send_email() {
85 _deprecated_function( __FUNCTION__, '2.03.04', 'FrmEmail::send' );
86 }
87 }
88