Completed
Push — master ( 5fe043...600d7a )
by Jamie
04:01
created
classes/models/FrmNotification.php 1 patch
Indentation   +256 added lines, -256 removed lines patch added patch discarded remove patch
@@ -2,160 +2,160 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmNotification {
4 4
 	public function __construct() {
5
-        if ( ! defined('ABSPATH') ) {
6
-            die('You are not allowed to call this page directly.');
7
-        }
8
-        add_action('frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3);
9
-    }
5
+		if ( ! defined('ABSPATH') ) {
6
+			die('You are not allowed to call this page directly.');
7
+		}
8
+		add_action('frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3);
9
+	}
10 10
 
11 11
 	public static function trigger_email( $action, $entry, $form ) {
12
-        $notification = $action->post_content;
13
-        $email_key = $action->ID;
14
-
15
-        // Set the subject
16
-        if ( empty($notification['email_subject']) ) {
17
-            $notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]');
18
-        }
19
-
20
-        $plain_text = $notification['plain_text'] ? true : false;
21
-
22
-        //Filter these fields
23
-        $filter_fields = array(
24
-            'email_to', 'cc', 'bcc',
25
-            'reply_to', 'from',
26
-            'email_subject', 'email_message',
27
-        );
28
-
29
-        add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false'));
30
-
31
-        //Get all values in entry in order to get User ID field ID
32
-        $values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' );
33
-        $user_id_field = $user_id_key = '';
34
-        foreach ( $values as $value ) {
35
-            if ( $value->field_type == 'user_id' ) {
36
-                $user_id_field = $value->field_id;
37
-                $user_id_key = $value->field_key;
38
-                break;
39
-            }
40
-            unset($value);
41
-        }
42
-
43
-        //Filter and prepare the email fields
44
-        foreach ( $filter_fields as $f ) {
45
-            //Don't allow empty From
12
+		$notification = $action->post_content;
13
+		$email_key = $action->ID;
14
+
15
+		// Set the subject
16
+		if ( empty($notification['email_subject']) ) {
17
+			$notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]');
18
+		}
19
+
20
+		$plain_text = $notification['plain_text'] ? true : false;
21
+
22
+		//Filter these fields
23
+		$filter_fields = array(
24
+			'email_to', 'cc', 'bcc',
25
+			'reply_to', 'from',
26
+			'email_subject', 'email_message',
27
+		);
28
+
29
+		add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false'));
30
+
31
+		//Get all values in entry in order to get User ID field ID
32
+		$values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' );
33
+		$user_id_field = $user_id_key = '';
34
+		foreach ( $values as $value ) {
35
+			if ( $value->field_type == 'user_id' ) {
36
+				$user_id_field = $value->field_id;
37
+				$user_id_key = $value->field_key;
38
+				break;
39
+			}
40
+			unset($value);
41
+		}
42
+
43
+		//Filter and prepare the email fields
44
+		foreach ( $filter_fields as $f ) {
45
+			//Don't allow empty From
46 46
 			if ( $f == 'from' && empty( $notification[ $f ] ) ) {
47 47
 				$notification[ $f ] = '[admin_email]';
48 48
 			} else if ( in_array( $f, array( 'email_to', 'cc', 'bcc', 'reply_to', 'from' ) ) ) {
49 49
 				//Remove brackets
50
-                //Add a space in case there isn't one
50
+				//Add a space in case there isn't one
51 51
 				$notification[ $f ] = str_replace( '<', ' ', $notification[ $f ] );
52 52
 				$notification[ $f ] = str_replace( array( '"', '>' ), '', $notification[ $f ] );
53 53
 
54
-                //Switch userID shortcode to email address
54
+				//Switch userID shortcode to email address
55 55
 				if ( strpos( $notification[ $f ], '[' . $user_id_field . ']' ) !== false || strpos( $notification[ $f ], '[' . $user_id_key . ']' ) !== false ) {
56 56
 					$user_data = get_userdata( $entry->metas[ $user_id_field ] );
57
-                    $user_email = $user_data->user_email;
57
+					$user_email = $user_data->user_email;
58 58
 					$notification[ $f ] = str_replace( array( '[' . $user_id_field . ']', '[' . $user_id_key . ']' ), $user_email, $notification[ $f ] );
59
-                }
60
-            }
59
+				}
60
+			}
61 61
 
62 62
 			$notification[ $f ] = FrmFieldsHelper::basic_replace_shortcodes( $notification[ $f ], $form, $entry );
63
-        }
63
+		}
64 64
 
65
-        //Put recipients, cc, and bcc into an array if they aren't empty
65
+		//Put recipients, cc, and bcc into an array if they aren't empty
66 66
 		$to_emails = self::explode_emails( $notification['email_to'] );
67 67
 		$cc = self::explode_emails( $notification['cc'] );
68 68
 		$bcc = self::explode_emails( $notification['bcc'] );
69 69
 
70
-        $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form'));
70
+		$to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form'));
71 71
 
72
-        // Stop now if there aren't any recipients
73
-        if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) {
74
-            return;
75
-        }
72
+		// Stop now if there aren't any recipients
73
+		if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) {
74
+			return;
75
+		}
76 76
 
77
-        $to_emails = array_unique( (array) $to_emails );
77
+		$to_emails = array_unique( (array) $to_emails );
78 78
 
79
-        $prev_mail_body = $mail_body = $notification['email_message'];
80
-        $mail_body = FrmEntriesHelper::replace_default_message($mail_body, array(
81
-            'id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text,
82
-            'user_info' => (isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false),
83
-        ) );
79
+		$prev_mail_body = $mail_body = $notification['email_message'];
80
+		$mail_body = FrmEntriesHelper::replace_default_message($mail_body, array(
81
+			'id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text,
82
+			'user_info' => (isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false),
83
+		) );
84 84
 
85
-        // Add the user info if it isn't already included
86
-        if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) {
87
-            $data = maybe_unserialize($entry->description);
85
+		// Add the user info if it isn't already included
86
+		if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) {
87
+			$data = maybe_unserialize($entry->description);
88 88
 			$mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) . "\r\n";
89 89
 			$mail_body .= __( 'IP Address', 'formidable' ) . ': ' . $entry->ip . "\r\n";
90 90
 			$mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntryFormat::get_browser( $data['browser'] ) . "\r\n";
91 91
 			$mail_body .= __( 'Referrer', 'formidable' ) . ': ' . $data['referrer'] . "\r\n";
92
-        }
93
-        unset($prev_mail_body);
94
-
95
-        // Add attachments
96
-        $attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') );
97
-
98
-        if ( ! empty($notification['email_subject']) ) {
99
-            $notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key'));
100
-        }
101
-
102
-        // check for a phone number
103
-        foreach ( (array) $to_emails as $email_key => $e ) {
104
-            if ( $e != '[admin_email]' && ! is_email($e) ) {
105
-                $e = explode(' ', $e);
106
-
107
-                //If to_email has name <[email protected]> format
108
-                if ( is_email(end($e)) ) {
109
-                    continue;
110
-                }
111
-
112
-                do_action('frm_send_to_not_email', array(
113
-                    'e'         => $e,
114
-                    'subject'   => $notification['email_subject'],
115
-                    'mail_body' => $mail_body,
116
-                    'reply_to'  => $notification['reply_to'],
117
-                    'from'      => $notification['from'],
118
-                    'plain_text' => $plain_text,
119
-                    'attachments' => $attachments,
120
-                    'form'      => $form,
121
-                    'email_key' => $email_key,
122
-                ) );
92
+		}
93
+		unset($prev_mail_body);
94
+
95
+		// Add attachments
96
+		$attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') );
97
+
98
+		if ( ! empty($notification['email_subject']) ) {
99
+			$notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key'));
100
+		}
101
+
102
+		// check for a phone number
103
+		foreach ( (array) $to_emails as $email_key => $e ) {
104
+			if ( $e != '[admin_email]' && ! is_email($e) ) {
105
+				$e = explode(' ', $e);
106
+
107
+				//If to_email has name <[email protected]> format
108
+				if ( is_email(end($e)) ) {
109
+					continue;
110
+				}
111
+
112
+				do_action('frm_send_to_not_email', array(
113
+					'e'         => $e,
114
+					'subject'   => $notification['email_subject'],
115
+					'mail_body' => $mail_body,
116
+					'reply_to'  => $notification['reply_to'],
117
+					'from'      => $notification['from'],
118
+					'plain_text' => $plain_text,
119
+					'attachments' => $attachments,
120
+					'form'      => $form,
121
+					'email_key' => $email_key,
122
+				) );
123 123
 
124 124
 				unset( $to_emails[ $email_key ] );
125
-            }
126
-        }
127
-
128
-        // Send the email now
129
-        $sent_to = self::send_email( array(
130
-            'to_email'      => $to_emails,
131
-            'subject'       => $notification['email_subject'],
132
-            'message'       => $mail_body,
133
-            'from'          => $notification['from'],
134
-            'plain_text'    => $plain_text,
135
-            'reply_to'      => $notification['reply_to'],
136
-            'attachments'   => $attachments,
137
-            'cc'            => $cc,
138
-            'bcc'           => $bcc,
139
-        ) );
140
-
141
-        return $sent_to;
142
-    }
125
+			}
126
+		}
127
+
128
+		// Send the email now
129
+		$sent_to = self::send_email( array(
130
+			'to_email'      => $to_emails,
131
+			'subject'       => $notification['email_subject'],
132
+			'message'       => $mail_body,
133
+			'from'          => $notification['from'],
134
+			'plain_text'    => $plain_text,
135
+			'reply_to'      => $notification['reply_to'],
136
+			'attachments'   => $attachments,
137
+			'cc'            => $cc,
138
+			'bcc'           => $bcc,
139
+		) );
140
+
141
+		return $sent_to;
142
+	}
143 143
 
144 144
 	public function entry_created( $entry_id, $form_id ) {
145 145
 		$new_function = 'FrmFormActionsController::trigger_actions("create", ' . $form_id . ', ' . $entry_id . ', "email")';
146 146
 		_deprecated_function( __FUNCTION__, '2.0', $new_function );
147
-        FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email');
148
-    }
147
+		FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email');
148
+	}
149 149
 
150 150
 	public function send_notification_email( $to_email, $subject, $message, $from = '', $from_name = '', $plain_text = true, $attachments = array(), $reply_to = '' ) {
151
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' );
151
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' );
152 152
 
153
-        return self::send_email(compact(
154
-            'to_email', 'subject', 'message',
155
-            'from', 'from_name', 'plain_text',
156
-            'attachments', 'reply_to'
157
-        ));
158
-    }
153
+		return self::send_email(compact(
154
+			'to_email', 'subject', 'message',
155
+			'from', 'from_name', 'plain_text',
156
+			'attachments', 'reply_to'
157
+		));
158
+	}
159 159
 
160 160
 	/**
161 161
 	 * Extract the emails from cc and bcc. Allow separation by , or ;.
@@ -173,53 +173,53 @@  discard block
 block discarded – undo
173 173
 		return $emails;
174 174
 	}
175 175
 
176
-    /**
177
-    * Put To, BCC, CC, Reply To, and From fields in Name <[email protected]> format
178
-    * Formats that should work: Name, "Name", [email protected], <[email protected]>, Name <[email protected]>,
179
-    * "Name" <[email protected]>, Name [email protected], "Name" [email protected], Name<[email protected]>, "Name"<[email protected]>
180
-    * "First Last" <[email protected]>
181
-    *
182
-    * Things that won't work: First Last (with no email entered)
183
-    * @since 2.0
184
-    * @param array $atts array of email fields, pass by reference
185
-    * @param $admin_email
186
-    */
187
-    private static function format_email_fields( &$atts, $admin_email ) {
188
-
189
-        // If from is empty or is set to admin_email, set it now
190
-        $atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from'];
191
-
192
-        // Filter values in these fields
176
+	/**
177
+	 * Put To, BCC, CC, Reply To, and From fields in Name <[email protected]> format
178
+	 * Formats that should work: Name, "Name", [email protected], <[email protected]>, Name <[email protected]>,
179
+	 * "Name" <[email protected]>, Name [email protected], "Name" [email protected], Name<[email protected]>, "Name"<[email protected]>
180
+	 * "First Last" <[email protected]>
181
+	 *
182
+	 * Things that won't work: First Last (with no email entered)
183
+	 * @since 2.0
184
+	 * @param array $atts array of email fields, pass by reference
185
+	 * @param $admin_email
186
+	 */
187
+	private static function format_email_fields( &$atts, $admin_email ) {
188
+
189
+		// If from is empty or is set to admin_email, set it now
190
+		$atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from'];
191
+
192
+		// Filter values in these fields
193 193
 		$filter_fields = array( 'to_email', 'bcc', 'cc', 'from', 'reply_to' );
194 194
 
195
-        foreach ( $filter_fields as $f ) {
196
-            // If empty, just skip it
195
+		foreach ( $filter_fields as $f ) {
196
+			// If empty, just skip it
197 197
 			if ( empty( $atts[ $f ] ) ) {
198
-                continue;
199
-            }
198
+				continue;
199
+			}
200 200
 
201
-            // to_email, cc, and bcc can be an array
201
+			// to_email, cc, and bcc can be an array
202 202
 			if ( is_array( $atts[ $f ] ) ) {
203 203
 				foreach ( $atts[ $f ] as $key => $val ) {
204
-                    self::format_single_field( $atts, $f, $val, $key );
205
-                    unset( $key, $val );
206
-                }
207
-                unset($f);
208
-                continue;
209
-            }
204
+					self::format_single_field( $atts, $f, $val, $key );
205
+					unset( $key, $val );
206
+				}
207
+				unset($f);
208
+				continue;
209
+			}
210 210
 
211 211
 			self::format_single_field( $atts, $f, $atts[ $f ] );
212
-        }
212
+		}
213 213
 
214
-        // If reply-to isn't set, make it match the from settings
215
-        if ( empty( $atts['reply_to'] ) ) {
216
-            $atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] );
217
-        }
214
+		// If reply-to isn't set, make it match the from settings
215
+		if ( empty( $atts['reply_to'] ) ) {
216
+			$atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] );
217
+		}
218 218
 
219
-        if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) {
220
-            $atts['to_email'] = $admin_email;
221
-        }
222
-    }
219
+		if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) {
220
+			$atts['to_email'] = $admin_email;
221
+		}
222
+	}
223 223
 
224 224
 	private static function get_email_from_formatted_string( $value ) {
225 225
 		if ( strpos( $value, '<' ) !== false ) {
@@ -229,48 +229,48 @@  discard block
 block discarded – undo
229 229
 		return $value;
230 230
 	}
231 231
 
232
-    /**
233
-    * Format individual email fields
234
-    *
235
-    * @since 2.0
236
-    * @param array $atts pass by reference
237
-    * @param string $f (to, from, reply_to, etc)
238
-    * @param string $val value saved in field
239
-    * @param int $key if in array, this will be set
240
-    */
241
-    private static function format_single_field( &$atts, $f, $val, $key = false ) {
242
-        $val = trim($val);
243
-
244
-        // If just a plain email is used
245
-        if ( is_email($val) ) {
246
-            // add sender's name if not included in $from
247
-            if ( $f == 'from' ) {
232
+	/**
233
+	 * Format individual email fields
234
+	 *
235
+	 * @since 2.0
236
+	 * @param array $atts pass by reference
237
+	 * @param string $f (to, from, reply_to, etc)
238
+	 * @param string $val value saved in field
239
+	 * @param int $key if in array, this will be set
240
+	 */
241
+	private static function format_single_field( &$atts, $f, $val, $key = false ) {
242
+		$val = trim($val);
243
+
244
+		// If just a plain email is used
245
+		if ( is_email($val) ) {
246
+			// add sender's name if not included in $from
247
+			if ( $f == 'from' ) {
248 248
 				$part_2 = $atts[ $f ];
249
-                $part_1  = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
250
-            } else {
251
-                return;
252
-            }
253
-        } else {
254
-            $parts = explode(' ', $val);
255
-            $part_2 = end($parts);
256
-
257
-            // If inputted correcly, $part_2 should be an email
258
-            if ( is_email( $part_2 ) ) {
259
-                $part_1 = trim( str_replace( $part_2, '', $val ) );
260
-            } else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) {
249
+				$part_1  = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
250
+			} else {
251
+				return;
252
+			}
253
+		} else {
254
+			$parts = explode(' ', $val);
255
+			$part_2 = end($parts);
256
+
257
+			// If inputted correcly, $part_2 should be an email
258
+			if ( is_email( $part_2 ) ) {
259
+				$part_1 = trim( str_replace( $part_2, '', $val ) );
260
+			} else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) {
261 261
 				// In case someone just puts a name in the From or Reply To field
262 262
 				$part_1 = $val;
263
-                $part_2 = get_option('admin_email');
264
-            } else {
263
+				$part_2 = get_option('admin_email');
264
+			} else {
265 265
 				// In case someone just puts a name in any other email field
266
-                if ( false !== $key ) {
266
+				if ( false !== $key ) {
267 267
 					unset( $atts[ $f ][ $key ] );
268
-                    return;
269
-                }
268
+					return;
269
+				}
270 270
 				$atts[ $f ] = '';
271
-                return;
272
-            }
273
-        }
271
+				return;
272
+			}
273
+		}
274 274
 
275 275
 		// if sending the email from a yahoo address, change it to the WordPress default
276 276
 		if ( $f == 'from' && strpos( $part_2, '@yahoo.com' ) ) {
@@ -283,110 +283,110 @@  discard block
 block discarded – undo
283 283
 			$part_2 = 'wordpress@' . $sitename;
284 284
 		}
285 285
 
286
-        // Set up formatted value
286
+		// Set up formatted value
287 287
 		$final_val = str_replace( '"', '', $part_1 ) . ' <' . $part_2 . '>';
288 288
 
289
-        // If value is an array
290
-        if ( false !== $key ) {
289
+		// If value is an array
290
+		if ( false !== $key ) {
291 291
 			$atts[ $f ][ $key ] = $final_val;
292
-            return;
293
-        }
292
+			return;
293
+		}
294 294
 		$atts[ $f ] = $final_val;
295
-    }
295
+	}
296 296
 
297 297
 	public static function send_email( $atts ) {
298
-        $admin_email = get_option('admin_email');
299
-        $defaults = array(
300
-            'to_email'      => $admin_email,
301
-            'subject'       => '',
302
-            'message'       => '',
303
-            'from'          => $admin_email,
304
-            'from_name'     => '',
305
-            'cc'            => '',
306
-            'bcc'           => '',
307
-            'plain_text'    => true,
308
-            'reply_to'      => $admin_email,
309
-            'attachments'   => array(),
310
-        );
311
-        $atts = wp_parse_args($atts, $defaults);
312
-
313
-        // Put To, BCC, CC, Reply To, and From fields in the correct format
314
-        self::format_email_fields( $atts, $admin_email );
315
-
316
-        $recipient      = $atts['to_email']; //recipient
317
-        $header         = array();
318
-        $header[]       = 'From: ' . $atts['from'];
319
-
320
-        //Allow for cc and bcc arrays
298
+		$admin_email = get_option('admin_email');
299
+		$defaults = array(
300
+			'to_email'      => $admin_email,
301
+			'subject'       => '',
302
+			'message'       => '',
303
+			'from'          => $admin_email,
304
+			'from_name'     => '',
305
+			'cc'            => '',
306
+			'bcc'           => '',
307
+			'plain_text'    => true,
308
+			'reply_to'      => $admin_email,
309
+			'attachments'   => array(),
310
+		);
311
+		$atts = wp_parse_args($atts, $defaults);
312
+
313
+		// Put To, BCC, CC, Reply To, and From fields in the correct format
314
+		self::format_email_fields( $atts, $admin_email );
315
+
316
+		$recipient      = $atts['to_email']; //recipient
317
+		$header         = array();
318
+		$header[]       = 'From: ' . $atts['from'];
319
+
320
+		//Allow for cc and bcc arrays
321 321
 		$array_fields = array( 'CC' => $atts['cc'], 'BCC' => $atts['bcc'] );
322 322
 		$cc = array( 'CC' => array(), 'BCC' => array() );
323
-        foreach ( $array_fields as $key => $a_field ) {
324
-            if ( empty($a_field) ) {
325
-                continue;
326
-            }
323
+		foreach ( $array_fields as $key => $a_field ) {
324
+			if ( empty($a_field) ) {
325
+				continue;
326
+			}
327 327
 
328 328
 			foreach ( (array) $a_field as $email ) {
329 329
 				$cc[ $key ][] = $email;
330
-            }
331
-            unset($key, $a_field);
332
-        }
330
+			}
331
+			unset($key, $a_field);
332
+		}
333 333
 		$cc = array_filter( $cc ); // remove cc and bcc if they are empty
334 334
 
335 335
 		foreach ( $cc as $k => $v ) {
336 336
 			$header[] = $k . ': ' . implode( ',', $v );
337 337
 		}
338 338
 
339
-        $content_type   = $atts['plain_text'] ? 'text/plain' : 'text/html';
340
-        $charset        = get_option('blog_charset');
339
+		$content_type   = $atts['plain_text'] ? 'text/plain' : 'text/html';
340
+		$charset        = get_option('blog_charset');
341 341
 
342 342
 		$header[]       = 'Reply-To: ' . $atts['reply_to'];
343 343
 		$header[]       = 'Content-Type: ' . $content_type . '; charset="' . esc_attr( $charset ) . '"';
344
-        $atts['subject'] = wp_specialchars_decode(strip_tags(stripslashes($atts['subject'])), ENT_QUOTES );
344
+		$atts['subject'] = wp_specialchars_decode(strip_tags(stripslashes($atts['subject'])), ENT_QUOTES );
345 345
 
346
-        $message        = do_shortcode($atts['message']);
346
+		$message        = do_shortcode($atts['message']);
347 347
 
348
-        if ( $atts['plain_text'] ) {
349
-            //$message    = wordwrap($message, 70, "\r\n"); //in case any lines are longer than 70 chars
350
-            $message    = wp_specialchars_decode(strip_tags($message), ENT_QUOTES );
351
-        } else {
348
+		if ( $atts['plain_text'] ) {
349
+			//$message    = wordwrap($message, 70, "\r\n"); //in case any lines are longer than 70 chars
350
+			$message    = wp_specialchars_decode(strip_tags($message), ENT_QUOTES );
351
+		} else {
352 352
 			// remove line breaks in HTML emails to prevent conflicts with Mandrill
353
-        	add_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' );
354
-        }
353
+			add_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' );
354
+		}
355 355
 		$message = apply_filters( 'frm_email_message', $message, $atts );
356 356
 
357
-        $header         = apply_filters('frm_email_header', $header, array(
357
+		$header         = apply_filters('frm_email_header', $header, array(
358 358
 			'to_email' => $atts['to_email'], 'subject' => $atts['subject'],
359 359
 		) );
360 360
 
361
-        if ( apply_filters('frm_encode_subject', 1, $atts['subject'] ) ) {
361
+		if ( apply_filters('frm_encode_subject', 1, $atts['subject'] ) ) {
362 362
 			$atts['subject'] = '=?' . $charset . '?B?' . base64_encode( $atts['subject'] ) . '?=';
363
-        }
363
+		}
364 364
 
365
-        remove_filter('wp_mail_from', 'bp_core_email_from_address_filter' );
366
-        remove_filter('wp_mail_from_name', 'bp_core_email_from_name_filter');
365
+		remove_filter('wp_mail_from', 'bp_core_email_from_address_filter' );
366
+		remove_filter('wp_mail_from_name', 'bp_core_email_from_name_filter');
367 367
 
368
-        $sent = wp_mail($recipient, $atts['subject'], $message, $header, $atts['attachments']);
369
-        if ( ! $sent ) {
368
+		$sent = wp_mail($recipient, $atts['subject'], $message, $header, $atts['attachments']);
369
+		if ( ! $sent ) {
370 370
 			$header = 'From: ' . $atts['from'] . "\r\n";
371
-            $recipient = implode(',', (array) $recipient);
372
-            $sent = mail($recipient, $atts['subject'], $message, $header);
373
-        }
371
+			$recipient = implode(',', (array) $recipient);
372
+			$sent = mail($recipient, $atts['subject'], $message, $header);
373
+		}
374 374
 
375 375
 		// remove the filter now so other emails can still use it
376 376
 		remove_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' );
377 377
 
378
-        do_action('frm_notification', $recipient, $atts['subject'], $message);
378
+		do_action('frm_notification', $recipient, $atts['subject'], $message);
379 379
 
380
-        if ( $sent ) {
380
+		if ( $sent ) {
381 381
 			$sent_to = array_merge( (array) $atts['to_email'], (array) $atts['cc'], (array) $atts['bcc'] );
382
-            $sent_to = array_filter( $sent_to );
383
-            if ( apply_filters('frm_echo_emails', false) ) {
384
-                $temp = str_replace('<', '&lt;', $sent_to);
382
+			$sent_to = array_filter( $sent_to );
383
+			if ( apply_filters('frm_echo_emails', false) ) {
384
+				$temp = str_replace('<', '&lt;', $sent_to);
385 385
 				echo ' ' . FrmAppHelper::kses( implode(', ', (array) $temp ) );
386
-            }
387
-            return $sent_to;
388
-        }
389
-    }
386
+			}
387
+			return $sent_to;
388
+		}
389
+	}
390 390
 
391 391
 	/**
392 392
 	 * This function should only be fired when Mandrill is sending an HTML email
Please login to merge, or discard this patch.