@@ -2,165 +2,165 @@ discard block |
||
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 | 12 | if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) { |
13 | - return; |
|
14 | - } |
|
15 | - |
|
16 | - global $wpdb; |
|
17 | - |
|
18 | - $notification = $action->post_content; |
|
19 | - $email_key = $action->ID; |
|
20 | - |
|
21 | - // Set the subject |
|
22 | - if ( empty($notification['email_subject']) ) { |
|
23 | - $notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]'); |
|
24 | - } |
|
25 | - |
|
26 | - $plain_text = $notification['plain_text'] ? true : false; |
|
27 | - |
|
28 | - //Filter these fields |
|
29 | - $filter_fields = array( |
|
30 | - 'email_to', 'cc', 'bcc', |
|
31 | - 'reply_to', 'from', |
|
32 | - 'email_subject', 'email_message', |
|
33 | - ); |
|
34 | - |
|
35 | - add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false')); |
|
36 | - |
|
37 | - //Get all values in entry in order to get User ID field ID |
|
38 | - $values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' ); |
|
39 | - $user_id_field = $user_id_key = ''; |
|
40 | - foreach ( $values as $value ) { |
|
41 | - if ( $value->field_type == 'user_id' ) { |
|
42 | - $user_id_field = $value->field_id; |
|
43 | - $user_id_key = $value->field_key; |
|
44 | - break; |
|
45 | - } |
|
46 | - unset($value); |
|
47 | - } |
|
48 | - |
|
49 | - //Filter and prepare the email fields |
|
50 | - foreach ( $filter_fields as $f ) { |
|
51 | - //Don't allow empty From |
|
13 | + return; |
|
14 | + } |
|
15 | + |
|
16 | + global $wpdb; |
|
17 | + |
|
18 | + $notification = $action->post_content; |
|
19 | + $email_key = $action->ID; |
|
20 | + |
|
21 | + // Set the subject |
|
22 | + if ( empty($notification['email_subject']) ) { |
|
23 | + $notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]'); |
|
24 | + } |
|
25 | + |
|
26 | + $plain_text = $notification['plain_text'] ? true : false; |
|
27 | + |
|
28 | + //Filter these fields |
|
29 | + $filter_fields = array( |
|
30 | + 'email_to', 'cc', 'bcc', |
|
31 | + 'reply_to', 'from', |
|
32 | + 'email_subject', 'email_message', |
|
33 | + ); |
|
34 | + |
|
35 | + add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false')); |
|
36 | + |
|
37 | + //Get all values in entry in order to get User ID field ID |
|
38 | + $values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' ); |
|
39 | + $user_id_field = $user_id_key = ''; |
|
40 | + foreach ( $values as $value ) { |
|
41 | + if ( $value->field_type == 'user_id' ) { |
|
42 | + $user_id_field = $value->field_id; |
|
43 | + $user_id_key = $value->field_key; |
|
44 | + break; |
|
45 | + } |
|
46 | + unset($value); |
|
47 | + } |
|
48 | + |
|
49 | + //Filter and prepare the email fields |
|
50 | + foreach ( $filter_fields as $f ) { |
|
51 | + //Don't allow empty From |
|
52 | 52 | if ( $f == 'from' && empty( $notification[ $f ] ) ) { |
53 | 53 | $notification[ $f ] = '[admin_email]'; |
54 | 54 | } else if ( in_array( $f, array( 'email_to', 'cc', 'bcc', 'reply_to', 'from' ) ) ) { |
55 | 55 | //Remove brackets |
56 | - //Add a space in case there isn't one |
|
56 | + //Add a space in case there isn't one |
|
57 | 57 | $notification[ $f ] = str_replace( '<', ' ', $notification[ $f ] ); |
58 | 58 | $notification[ $f ] = str_replace( array( '"', '>' ), '', $notification[ $f ] ); |
59 | 59 | |
60 | - //Switch userID shortcode to email address |
|
60 | + //Switch userID shortcode to email address |
|
61 | 61 | if ( strpos( $notification[ $f ], '[' . $user_id_field . ']' ) !== false || strpos( $notification[ $f ], '[' . $user_id_key . ']' ) !== false ) { |
62 | 62 | $user_data = get_userdata( $entry->metas[ $user_id_field ] ); |
63 | - $user_email = $user_data->user_email; |
|
63 | + $user_email = $user_data->user_email; |
|
64 | 64 | $notification[ $f ] = str_replace( array( '[' . $user_id_field . ']', '[' . $user_id_key . ']' ), $user_email, $notification[ $f ] ); |
65 | - } |
|
66 | - } |
|
65 | + } |
|
66 | + } |
|
67 | 67 | |
68 | 68 | $notification[ $f ] = FrmFieldsHelper::basic_replace_shortcodes( $notification[ $f ], $form, $entry ); |
69 | - } |
|
69 | + } |
|
70 | 70 | |
71 | - //Put recipients, cc, and bcc into an array if they aren't empty |
|
71 | + //Put recipients, cc, and bcc into an array if they aren't empty |
|
72 | 72 | $to_emails = self::explode_emails( $notification['email_to'] ); |
73 | 73 | $cc = self::explode_emails( $notification['cc'] ); |
74 | 74 | $bcc = self::explode_emails( $notification['bcc'] ); |
75 | 75 | |
76 | - $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form')); |
|
76 | + $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form')); |
|
77 | 77 | |
78 | - // Stop now if there aren't any recipients |
|
79 | - if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) { |
|
80 | - return; |
|
81 | - } |
|
78 | + // Stop now if there aren't any recipients |
|
79 | + if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) { |
|
80 | + return; |
|
81 | + } |
|
82 | 82 | |
83 | - $to_emails = array_unique( (array) $to_emails ); |
|
83 | + $to_emails = array_unique( (array) $to_emails ); |
|
84 | 84 | |
85 | - $prev_mail_body = $mail_body = $notification['email_message']; |
|
86 | - $mail_body = FrmEntriesHelper::replace_default_message($mail_body, array( |
|
87 | - 'id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text, |
|
88 | - 'user_info' => (isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false), |
|
89 | - ) ); |
|
85 | + $prev_mail_body = $mail_body = $notification['email_message']; |
|
86 | + $mail_body = FrmEntriesHelper::replace_default_message($mail_body, array( |
|
87 | + 'id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text, |
|
88 | + 'user_info' => (isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false), |
|
89 | + ) ); |
|
90 | 90 | |
91 | - // Add the user info if it isn't already included |
|
92 | - if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) { |
|
93 | - $data = maybe_unserialize($entry->description); |
|
94 | - $mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) ."\r\n"; |
|
95 | - $mail_body .= __( 'IP Address', 'formidable' ) . ': '. $entry->ip ."\r\n"; |
|
91 | + // Add the user info if it isn't already included |
|
92 | + if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) { |
|
93 | + $data = maybe_unserialize($entry->description); |
|
94 | + $mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) ."\r\n"; |
|
95 | + $mail_body .= __( 'IP Address', 'formidable' ) . ': '. $entry->ip ."\r\n"; |
|
96 | 96 | $mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntryFormat::get_browser( $data['browser'] ) . "\r\n"; |
97 | - $mail_body .= __( 'Referrer', 'formidable' ) . ': '. $data['referrer']."\r\n"; |
|
98 | - } |
|
99 | - unset($prev_mail_body); |
|
100 | - |
|
101 | - // Add attachments |
|
102 | - $attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') ); |
|
103 | - |
|
104 | - if ( ! empty($notification['email_subject']) ) { |
|
105 | - $notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key')); |
|
106 | - } |
|
107 | - |
|
108 | - // check for a phone number |
|
109 | - foreach ( (array) $to_emails as $email_key => $e ) { |
|
110 | - if ( $e != '[admin_email]' && ! is_email($e) ) { |
|
111 | - $e = explode(' ', $e); |
|
112 | - |
|
113 | - //If to_email has name <[email protected]> format |
|
114 | - if ( is_email(end($e)) ) { |
|
115 | - continue; |
|
116 | - } |
|
117 | - |
|
118 | - do_action('frm_send_to_not_email', array( |
|
119 | - 'e' => $e, |
|
120 | - 'subject' => $notification['email_subject'], |
|
121 | - 'mail_body' => $mail_body, |
|
122 | - 'reply_to' => $notification['reply_to'], |
|
123 | - 'from' => $notification['from'], |
|
124 | - 'plain_text' => $plain_text, |
|
125 | - 'attachments' => $attachments, |
|
126 | - 'form' => $form, |
|
127 | - 'email_key' => $email_key, |
|
128 | - ) ); |
|
97 | + $mail_body .= __( 'Referrer', 'formidable' ) . ': '. $data['referrer']."\r\n"; |
|
98 | + } |
|
99 | + unset($prev_mail_body); |
|
100 | + |
|
101 | + // Add attachments |
|
102 | + $attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') ); |
|
103 | + |
|
104 | + if ( ! empty($notification['email_subject']) ) { |
|
105 | + $notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key')); |
|
106 | + } |
|
107 | + |
|
108 | + // check for a phone number |
|
109 | + foreach ( (array) $to_emails as $email_key => $e ) { |
|
110 | + if ( $e != '[admin_email]' && ! is_email($e) ) { |
|
111 | + $e = explode(' ', $e); |
|
112 | + |
|
113 | + //If to_email has name <[email protected]> format |
|
114 | + if ( is_email(end($e)) ) { |
|
115 | + continue; |
|
116 | + } |
|
117 | + |
|
118 | + do_action('frm_send_to_not_email', array( |
|
119 | + 'e' => $e, |
|
120 | + 'subject' => $notification['email_subject'], |
|
121 | + 'mail_body' => $mail_body, |
|
122 | + 'reply_to' => $notification['reply_to'], |
|
123 | + 'from' => $notification['from'], |
|
124 | + 'plain_text' => $plain_text, |
|
125 | + 'attachments' => $attachments, |
|
126 | + 'form' => $form, |
|
127 | + 'email_key' => $email_key, |
|
128 | + ) ); |
|
129 | 129 | |
130 | 130 | unset( $to_emails[ $email_key ] ); |
131 | - } |
|
132 | - } |
|
133 | - |
|
134 | - // Send the email now |
|
135 | - $sent_to = self::send_email( array( |
|
136 | - 'to_email' => $to_emails, |
|
137 | - 'subject' => $notification['email_subject'], |
|
138 | - 'message' => $mail_body, |
|
139 | - 'from' => $notification['from'], |
|
140 | - 'plain_text' => $plain_text, |
|
141 | - 'reply_to' => $notification['reply_to'], |
|
142 | - 'attachments' => $attachments, |
|
143 | - 'cc' => $cc, |
|
144 | - 'bcc' => $bcc, |
|
145 | - ) ); |
|
146 | - |
|
147 | - return $sent_to; |
|
148 | - } |
|
131 | + } |
|
132 | + } |
|
133 | + |
|
134 | + // Send the email now |
|
135 | + $sent_to = self::send_email( array( |
|
136 | + 'to_email' => $to_emails, |
|
137 | + 'subject' => $notification['email_subject'], |
|
138 | + 'message' => $mail_body, |
|
139 | + 'from' => $notification['from'], |
|
140 | + 'plain_text' => $plain_text, |
|
141 | + 'reply_to' => $notification['reply_to'], |
|
142 | + 'attachments' => $attachments, |
|
143 | + 'cc' => $cc, |
|
144 | + 'bcc' => $bcc, |
|
145 | + ) ); |
|
146 | + |
|
147 | + return $sent_to; |
|
148 | + } |
|
149 | 149 | |
150 | 150 | public function entry_created( $entry_id, $form_id ) { |
151 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmFormActionsController::trigger_actions("create", '. $form_id .', '. $entry_id .', "email")'); |
|
152 | - FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email'); |
|
153 | - } |
|
151 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmFormActionsController::trigger_actions("create", '. $form_id .', '. $entry_id .', "email")'); |
|
152 | + FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email'); |
|
153 | + } |
|
154 | 154 | |
155 | 155 | public function send_notification_email( $to_email, $subject, $message, $from = '', $from_name = '', $plain_text = true, $attachments = array(), $reply_to = '' ) { |
156 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' ); |
|
156 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' ); |
|
157 | 157 | |
158 | - return self::send_email(compact( |
|
159 | - 'to_email', 'subject', 'message', |
|
160 | - 'from', 'from_name', 'plain_text', |
|
161 | - 'attachments', 'reply_to' |
|
162 | - )); |
|
163 | - } |
|
158 | + return self::send_email(compact( |
|
159 | + 'to_email', 'subject', 'message', |
|
160 | + 'from', 'from_name', 'plain_text', |
|
161 | + 'attachments', 'reply_to' |
|
162 | + )); |
|
163 | + } |
|
164 | 164 | |
165 | 165 | /** |
166 | 166 | * Extract the emails from cc and bcc. Allow separation by , or ;. |
@@ -178,53 +178,53 @@ discard block |
||
178 | 178 | return $emails; |
179 | 179 | } |
180 | 180 | |
181 | - /** |
|
182 | - * Put To, BCC, CC, Reply To, and From fields in Name <[email protected]> format |
|
183 | - * Formats that should work: Name, "Name", [email protected], <[email protected]>, Name <[email protected]>, |
|
184 | - * "Name" <[email protected]>, Name [email protected], "Name" [email protected], Name<[email protected]>, "Name"<[email protected]> |
|
185 | - * "First Last" <[email protected]> |
|
186 | - * |
|
187 | - * Things that won't work: First Last (with no email entered) |
|
188 | - * @since 2.0 |
|
189 | - * @param array $atts array of email fields, pass by reference |
|
190 | - * @param $admin_email |
|
191 | - */ |
|
192 | - private static function format_email_fields( &$atts, $admin_email ) { |
|
193 | - |
|
194 | - // If from is empty or is set to admin_email, set it now |
|
195 | - $atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from']; |
|
196 | - |
|
197 | - // Filter values in these fields |
|
181 | + /** |
|
182 | + * Put To, BCC, CC, Reply To, and From fields in Name <[email protected]> format |
|
183 | + * Formats that should work: Name, "Name", [email protected], <[email protected]>, Name <[email protected]>, |
|
184 | + * "Name" <[email protected]>, Name [email protected], "Name" [email protected], Name<[email protected]>, "Name"<[email protected]> |
|
185 | + * "First Last" <[email protected]> |
|
186 | + * |
|
187 | + * Things that won't work: First Last (with no email entered) |
|
188 | + * @since 2.0 |
|
189 | + * @param array $atts array of email fields, pass by reference |
|
190 | + * @param $admin_email |
|
191 | + */ |
|
192 | + private static function format_email_fields( &$atts, $admin_email ) { |
|
193 | + |
|
194 | + // If from is empty or is set to admin_email, set it now |
|
195 | + $atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from']; |
|
196 | + |
|
197 | + // Filter values in these fields |
|
198 | 198 | $filter_fields = array( 'to_email', 'bcc', 'cc', 'from', 'reply_to' ); |
199 | 199 | |
200 | - foreach ( $filter_fields as $f ) { |
|
201 | - // If empty, just skip it |
|
200 | + foreach ( $filter_fields as $f ) { |
|
201 | + // If empty, just skip it |
|
202 | 202 | if ( empty( $atts[ $f ] ) ) { |
203 | - continue; |
|
204 | - } |
|
203 | + continue; |
|
204 | + } |
|
205 | 205 | |
206 | - // to_email, cc, and bcc can be an array |
|
206 | + // to_email, cc, and bcc can be an array |
|
207 | 207 | if ( is_array( $atts[ $f ] ) ) { |
208 | 208 | foreach ( $atts[ $f ] as $key => $val ) { |
209 | - self::format_single_field( $atts, $f, $val, $key ); |
|
210 | - unset( $key, $val ); |
|
211 | - } |
|
212 | - unset($f); |
|
213 | - continue; |
|
214 | - } |
|
209 | + self::format_single_field( $atts, $f, $val, $key ); |
|
210 | + unset( $key, $val ); |
|
211 | + } |
|
212 | + unset($f); |
|
213 | + continue; |
|
214 | + } |
|
215 | 215 | |
216 | 216 | self::format_single_field( $atts, $f, $atts[ $f ] ); |
217 | - } |
|
217 | + } |
|
218 | 218 | |
219 | - // If reply-to isn't set, make it match the from settings |
|
220 | - if ( empty( $atts['reply_to'] ) ) { |
|
221 | - $atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] ); |
|
222 | - } |
|
219 | + // If reply-to isn't set, make it match the from settings |
|
220 | + if ( empty( $atts['reply_to'] ) ) { |
|
221 | + $atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] ); |
|
222 | + } |
|
223 | 223 | |
224 | - if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) { |
|
225 | - $atts['to_email'] = $admin_email; |
|
226 | - } |
|
227 | - } |
|
224 | + if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) { |
|
225 | + $atts['to_email'] = $admin_email; |
|
226 | + } |
|
227 | + } |
|
228 | 228 | |
229 | 229 | private static function get_email_from_formatted_string( $value ) { |
230 | 230 | if ( strpos( $value, '<' ) !== false ) { |
@@ -234,48 +234,48 @@ discard block |
||
234 | 234 | return $value; |
235 | 235 | } |
236 | 236 | |
237 | - /** |
|
238 | - * Format individual email fields |
|
239 | - * |
|
240 | - * @since 2.0 |
|
241 | - * @param array $atts pass by reference |
|
242 | - * @param string $f (to, from, reply_to, etc) |
|
243 | - * @param string $val value saved in field |
|
244 | - * @param int $key if in array, this will be set |
|
245 | - */ |
|
246 | - private static function format_single_field( &$atts, $f, $val, $key = false ) { |
|
247 | - $val = trim($val); |
|
248 | - |
|
249 | - // If just a plain email is used |
|
250 | - if ( is_email($val) ) { |
|
251 | - // add sender's name if not included in $from |
|
252 | - if ( $f == 'from' ) { |
|
237 | + /** |
|
238 | + * Format individual email fields |
|
239 | + * |
|
240 | + * @since 2.0 |
|
241 | + * @param array $atts pass by reference |
|
242 | + * @param string $f (to, from, reply_to, etc) |
|
243 | + * @param string $val value saved in field |
|
244 | + * @param int $key if in array, this will be set |
|
245 | + */ |
|
246 | + private static function format_single_field( &$atts, $f, $val, $key = false ) { |
|
247 | + $val = trim($val); |
|
248 | + |
|
249 | + // If just a plain email is used |
|
250 | + if ( is_email($val) ) { |
|
251 | + // add sender's name if not included in $from |
|
252 | + if ( $f == 'from' ) { |
|
253 | 253 | $part_2 = $atts[ $f ]; |
254 | - $part_1 = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
255 | - } else { |
|
256 | - return; |
|
257 | - } |
|
258 | - } else { |
|
259 | - $parts = explode(' ', $val); |
|
260 | - $part_2 = end($parts); |
|
261 | - |
|
262 | - // If inputted correcly, $part_2 should be an email |
|
263 | - if ( is_email( $part_2 ) ) { |
|
264 | - $part_1 = trim( str_replace( $part_2, '', $val ) ); |
|
265 | - } else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) { |
|
254 | + $part_1 = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
255 | + } else { |
|
256 | + return; |
|
257 | + } |
|
258 | + } else { |
|
259 | + $parts = explode(' ', $val); |
|
260 | + $part_2 = end($parts); |
|
261 | + |
|
262 | + // If inputted correcly, $part_2 should be an email |
|
263 | + if ( is_email( $part_2 ) ) { |
|
264 | + $part_1 = trim( str_replace( $part_2, '', $val ) ); |
|
265 | + } else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) { |
|
266 | 266 | // In case someone just puts a name in the From or Reply To field |
267 | 267 | $part_1 = $val; |
268 | - $part_2 = get_option('admin_email'); |
|
269 | - } else { |
|
268 | + $part_2 = get_option('admin_email'); |
|
269 | + } else { |
|
270 | 270 | // In case someone just puts a name in any other email field |
271 | - if ( false !== $key ) { |
|
271 | + if ( false !== $key ) { |
|
272 | 272 | unset( $atts[ $f ][ $key ] ); |
273 | - return; |
|
274 | - } |
|
273 | + return; |
|
274 | + } |
|
275 | 275 | $atts[ $f ] = ''; |
276 | - return; |
|
277 | - } |
|
278 | - } |
|
276 | + return; |
|
277 | + } |
|
278 | + } |
|
279 | 279 | |
280 | 280 | // if sending the email from a yahoo address, change it to the WordPress default |
281 | 281 | if ( $f == 'from' && strpos( $part_2, '@yahoo.com' ) ) { |
@@ -288,110 +288,110 @@ discard block |
||
288 | 288 | $part_2 = 'wordpress@' . $sitename; |
289 | 289 | } |
290 | 290 | |
291 | - // Set up formatted value |
|
291 | + // Set up formatted value |
|
292 | 292 | $final_val = str_replace( '"', '', $part_1 ) . ' <'. $part_2 .'>'; |
293 | 293 | |
294 | - // If value is an array |
|
295 | - if ( false !== $key ) { |
|
294 | + // If value is an array |
|
295 | + if ( false !== $key ) { |
|
296 | 296 | $atts[ $f ][ $key ] = $final_val; |
297 | - return; |
|
298 | - } |
|
297 | + return; |
|
298 | + } |
|
299 | 299 | $atts[ $f ] = $final_val; |
300 | - } |
|
300 | + } |
|
301 | 301 | |
302 | 302 | public static function send_email( $atts ) { |
303 | - $admin_email = get_option('admin_email'); |
|
304 | - $defaults = array( |
|
305 | - 'to_email' => $admin_email, |
|
306 | - 'subject' => '', |
|
307 | - 'message' => '', |
|
308 | - 'from' => $admin_email, |
|
309 | - 'from_name' => '', |
|
310 | - 'cc' => '', |
|
311 | - 'bcc' => '', |
|
312 | - 'plain_text' => true, |
|
313 | - 'reply_to' => $admin_email, |
|
314 | - 'attachments' => array(), |
|
315 | - ); |
|
316 | - $atts = wp_parse_args($atts, $defaults); |
|
317 | - |
|
318 | - // Put To, BCC, CC, Reply To, and From fields in the correct format |
|
319 | - self::format_email_fields( $atts, $admin_email ); |
|
320 | - |
|
321 | - $recipient = $atts['to_email']; //recipient |
|
322 | - $header = array(); |
|
323 | - $header[] = 'From: ' . $atts['from']; |
|
324 | - |
|
325 | - //Allow for cc and bcc arrays |
|
303 | + $admin_email = get_option('admin_email'); |
|
304 | + $defaults = array( |
|
305 | + 'to_email' => $admin_email, |
|
306 | + 'subject' => '', |
|
307 | + 'message' => '', |
|
308 | + 'from' => $admin_email, |
|
309 | + 'from_name' => '', |
|
310 | + 'cc' => '', |
|
311 | + 'bcc' => '', |
|
312 | + 'plain_text' => true, |
|
313 | + 'reply_to' => $admin_email, |
|
314 | + 'attachments' => array(), |
|
315 | + ); |
|
316 | + $atts = wp_parse_args($atts, $defaults); |
|
317 | + |
|
318 | + // Put To, BCC, CC, Reply To, and From fields in the correct format |
|
319 | + self::format_email_fields( $atts, $admin_email ); |
|
320 | + |
|
321 | + $recipient = $atts['to_email']; //recipient |
|
322 | + $header = array(); |
|
323 | + $header[] = 'From: ' . $atts['from']; |
|
324 | + |
|
325 | + //Allow for cc and bcc arrays |
|
326 | 326 | $array_fields = array( 'CC' => $atts['cc'], 'BCC' => $atts['bcc'] ); |
327 | 327 | $cc = array( 'CC' => array(), 'BCC' => array() ); |
328 | - foreach ( $array_fields as $key => $a_field ) { |
|
329 | - if ( empty($a_field) ) { |
|
330 | - continue; |
|
331 | - } |
|
328 | + foreach ( $array_fields as $key => $a_field ) { |
|
329 | + if ( empty($a_field) ) { |
|
330 | + continue; |
|
331 | + } |
|
332 | 332 | |
333 | 333 | foreach ( (array) $a_field as $email ) { |
334 | 334 | $cc[ $key ][] = $email; |
335 | - } |
|
336 | - unset($key, $a_field); |
|
337 | - } |
|
335 | + } |
|
336 | + unset($key, $a_field); |
|
337 | + } |
|
338 | 338 | $cc = array_filter( $cc ); // remove cc and bcc if they are empty |
339 | 339 | |
340 | 340 | foreach ( $cc as $k => $v ) { |
341 | 341 | $header[] = $k . ': '. implode( ',', $v ); |
342 | 342 | } |
343 | 343 | |
344 | - $content_type = $atts['plain_text'] ? 'text/plain' : 'text/html'; |
|
345 | - $charset = get_option('blog_charset'); |
|
344 | + $content_type = $atts['plain_text'] ? 'text/plain' : 'text/html'; |
|
345 | + $charset = get_option('blog_charset'); |
|
346 | 346 | |
347 | - $header[] = 'Reply-To: '. $atts['reply_to']; |
|
347 | + $header[] = 'Reply-To: '. $atts['reply_to']; |
|
348 | 348 | $header[] = 'Content-Type: ' . $content_type . '; charset="' . esc_attr( $charset ) . '"'; |
349 | - $atts['subject'] = wp_specialchars_decode(strip_tags(stripslashes($atts['subject'])), ENT_QUOTES ); |
|
349 | + $atts['subject'] = wp_specialchars_decode(strip_tags(stripslashes($atts['subject'])), ENT_QUOTES ); |
|
350 | 350 | |
351 | - $message = do_shortcode($atts['message']); |
|
351 | + $message = do_shortcode($atts['message']); |
|
352 | 352 | |
353 | - if ( $atts['plain_text'] ) { |
|
354 | - //$message = wordwrap($message, 70, "\r\n"); //in case any lines are longer than 70 chars |
|
355 | - $message = wp_specialchars_decode(strip_tags($message), ENT_QUOTES ); |
|
356 | - } else { |
|
353 | + if ( $atts['plain_text'] ) { |
|
354 | + //$message = wordwrap($message, 70, "\r\n"); //in case any lines are longer than 70 chars |
|
355 | + $message = wp_specialchars_decode(strip_tags($message), ENT_QUOTES ); |
|
356 | + } else { |
|
357 | 357 | // remove line breaks in HTML emails to prevent conflicts with Mandrill |
358 | - add_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' ); |
|
359 | - } |
|
358 | + add_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' ); |
|
359 | + } |
|
360 | 360 | $message = apply_filters( 'frm_email_message', $message, $atts ); |
361 | 361 | |
362 | - $header = apply_filters('frm_email_header', $header, array( |
|
362 | + $header = apply_filters('frm_email_header', $header, array( |
|
363 | 363 | 'to_email' => $atts['to_email'], 'subject' => $atts['subject'], |
364 | 364 | ) ); |
365 | 365 | |
366 | - if ( apply_filters('frm_encode_subject', 1, $atts['subject'] ) ) { |
|
367 | - $atts['subject'] = '=?'. $charset .'?B?'. base64_encode($atts['subject']) .'?='; |
|
368 | - } |
|
366 | + if ( apply_filters('frm_encode_subject', 1, $atts['subject'] ) ) { |
|
367 | + $atts['subject'] = '=?'. $charset .'?B?'. base64_encode($atts['subject']) .'?='; |
|
368 | + } |
|
369 | 369 | |
370 | - remove_filter('wp_mail_from', 'bp_core_email_from_address_filter' ); |
|
371 | - remove_filter('wp_mail_from_name', 'bp_core_email_from_name_filter'); |
|
370 | + remove_filter('wp_mail_from', 'bp_core_email_from_address_filter' ); |
|
371 | + remove_filter('wp_mail_from_name', 'bp_core_email_from_name_filter'); |
|
372 | 372 | |
373 | - $sent = wp_mail($recipient, $atts['subject'], $message, $header, $atts['attachments']); |
|
374 | - if ( ! $sent ) { |
|
375 | - $header = 'From: '. $atts['from'] ."\r\n"; |
|
376 | - $recipient = implode(',', (array) $recipient); |
|
377 | - $sent = mail($recipient, $atts['subject'], $message, $header); |
|
378 | - } |
|
373 | + $sent = wp_mail($recipient, $atts['subject'], $message, $header, $atts['attachments']); |
|
374 | + if ( ! $sent ) { |
|
375 | + $header = 'From: '. $atts['from'] ."\r\n"; |
|
376 | + $recipient = implode(',', (array) $recipient); |
|
377 | + $sent = mail($recipient, $atts['subject'], $message, $header); |
|
378 | + } |
|
379 | 379 | |
380 | 380 | // remove the filter now so other emails can still use it |
381 | 381 | remove_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' ); |
382 | 382 | |
383 | - do_action('frm_notification', $recipient, $atts['subject'], $message); |
|
383 | + do_action('frm_notification', $recipient, $atts['subject'], $message); |
|
384 | 384 | |
385 | - if ( $sent ) { |
|
385 | + if ( $sent ) { |
|
386 | 386 | $sent_to = array_merge( (array) $atts['to_email'], (array) $atts['cc'], (array) $atts['bcc'] ); |
387 | - $sent_to = array_filter( $sent_to ); |
|
388 | - if ( apply_filters('frm_echo_emails', false) ) { |
|
389 | - $temp = str_replace('<', '<', $sent_to); |
|
387 | + $sent_to = array_filter( $sent_to ); |
|
388 | + if ( apply_filters('frm_echo_emails', false) ) { |
|
389 | + $temp = str_replace('<', '<', $sent_to); |
|
390 | 390 | echo ' ' . FrmAppHelper::kses( implode(', ', (array) $temp ) ); |
391 | - } |
|
392 | - return $sent_to; |
|
393 | - } |
|
394 | - } |
|
391 | + } |
|
392 | + return $sent_to; |
|
393 | + } |
|
394 | + } |
|
395 | 395 | |
396 | 396 | /** |
397 | 397 | * This function should only be fired when Mandrill is sending an HTML email |
@@ -2,14 +2,14 @@ discard block |
||
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.'); |
|
5 | + if ( ! defined( 'ABSPATH' ) ) { |
|
6 | + die( 'You are not allowed to call this page directly.' ); |
|
7 | 7 | } |
8 | - add_action('frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3); |
|
8 | + add_action( 'frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3 ); |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | public static function trigger_email( $action, $entry, $form ) { |
12 | - if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) { |
|
12 | + if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) { |
|
13 | 13 | return; |
14 | 14 | } |
15 | 15 | |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | $email_key = $action->ID; |
20 | 20 | |
21 | 21 | // Set the subject |
22 | - if ( empty($notification['email_subject']) ) { |
|
23 | - $notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]'); |
|
22 | + if ( empty( $notification['email_subject'] ) ) { |
|
23 | + $notification['email_subject'] = sprintf( __( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]' ); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | $plain_text = $notification['plain_text'] ? true : false; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | 'email_subject', 'email_message', |
33 | 33 | ); |
34 | 34 | |
35 | - add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false')); |
|
35 | + add_filter( 'frm_plain_text_email', ( $plain_text ? '__return_true' : '__return_false' ) ); |
|
36 | 36 | |
37 | 37 | //Get all values in entry in order to get User ID field ID |
38 | 38 | $values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' ); |
@@ -43,29 +43,29 @@ discard block |
||
43 | 43 | $user_id_key = $value->field_key; |
44 | 44 | break; |
45 | 45 | } |
46 | - unset($value); |
|
46 | + unset( $value ); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | //Filter and prepare the email fields |
50 | 50 | foreach ( $filter_fields as $f ) { |
51 | 51 | //Don't allow empty From |
52 | - if ( $f == 'from' && empty( $notification[ $f ] ) ) { |
|
53 | - $notification[ $f ] = '[admin_email]'; |
|
52 | + if ( $f == 'from' && empty( $notification[$f] ) ) { |
|
53 | + $notification[$f] = '[admin_email]'; |
|
54 | 54 | } else if ( in_array( $f, array( 'email_to', 'cc', 'bcc', 'reply_to', 'from' ) ) ) { |
55 | 55 | //Remove brackets |
56 | 56 | //Add a space in case there isn't one |
57 | - $notification[ $f ] = str_replace( '<', ' ', $notification[ $f ] ); |
|
58 | - $notification[ $f ] = str_replace( array( '"', '>' ), '', $notification[ $f ] ); |
|
57 | + $notification[$f] = str_replace( '<', ' ', $notification[$f] ); |
|
58 | + $notification[$f] = str_replace( array( '"', '>' ), '', $notification[$f] ); |
|
59 | 59 | |
60 | 60 | //Switch userID shortcode to email address |
61 | - if ( strpos( $notification[ $f ], '[' . $user_id_field . ']' ) !== false || strpos( $notification[ $f ], '[' . $user_id_key . ']' ) !== false ) { |
|
62 | - $user_data = get_userdata( $entry->metas[ $user_id_field ] ); |
|
61 | + if ( strpos( $notification[$f], '[' . $user_id_field . ']' ) !== false || strpos( $notification[$f], '[' . $user_id_key . ']' ) !== false ) { |
|
62 | + $user_data = get_userdata( $entry->metas[$user_id_field] ); |
|
63 | 63 | $user_email = $user_data->user_email; |
64 | - $notification[ $f ] = str_replace( array( '[' . $user_id_field . ']', '[' . $user_id_key . ']' ), $user_email, $notification[ $f ] ); |
|
64 | + $notification[$f] = str_replace( array( '[' . $user_id_field . ']', '[' . $user_id_key . ']' ), $user_email, $notification[$f] ); |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | - $notification[ $f ] = FrmFieldsHelper::basic_replace_shortcodes( $notification[ $f ], $form, $entry ); |
|
68 | + $notification[$f] = FrmFieldsHelper::basic_replace_shortcodes( $notification[$f], $form, $entry ); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | //Put recipients, cc, and bcc into an array if they aren't empty |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $cc = self::explode_emails( $notification['cc'] ); |
74 | 74 | $bcc = self::explode_emails( $notification['bcc'] ); |
75 | 75 | |
76 | - $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form')); |
|
76 | + $to_emails = apply_filters( 'frm_to_email', $to_emails, $values, $form->id, compact( 'email_key', 'entry', 'form' ) ); |
|
77 | 77 | |
78 | 78 | // Stop now if there aren't any recipients |
79 | 79 | if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) { |
@@ -83,39 +83,39 @@ discard block |
||
83 | 83 | $to_emails = array_unique( (array) $to_emails ); |
84 | 84 | |
85 | 85 | $prev_mail_body = $mail_body = $notification['email_message']; |
86 | - $mail_body = FrmEntriesHelper::replace_default_message($mail_body, array( |
|
86 | + $mail_body = FrmEntriesHelper::replace_default_message( $mail_body, array( |
|
87 | 87 | 'id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text, |
88 | - 'user_info' => (isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false), |
|
88 | + 'user_info' => ( isset( $notification['inc_user_info'] ) ? $notification['inc_user_info'] : false ), |
|
89 | 89 | ) ); |
90 | 90 | |
91 | 91 | // Add the user info if it isn't already included |
92 | 92 | if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) { |
93 | - $data = maybe_unserialize($entry->description); |
|
94 | - $mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) ."\r\n"; |
|
95 | - $mail_body .= __( 'IP Address', 'formidable' ) . ': '. $entry->ip ."\r\n"; |
|
93 | + $data = maybe_unserialize( $entry->description ); |
|
94 | + $mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) . "\r\n"; |
|
95 | + $mail_body .= __( 'IP Address', 'formidable' ) . ': ' . $entry->ip . "\r\n"; |
|
96 | 96 | $mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntryFormat::get_browser( $data['browser'] ) . "\r\n"; |
97 | - $mail_body .= __( 'Referrer', 'formidable' ) . ': '. $data['referrer']."\r\n"; |
|
97 | + $mail_body .= __( 'Referrer', 'formidable' ) . ': ' . $data['referrer'] . "\r\n"; |
|
98 | 98 | } |
99 | - unset($prev_mail_body); |
|
99 | + unset( $prev_mail_body ); |
|
100 | 100 | |
101 | 101 | // Add attachments |
102 | - $attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') ); |
|
102 | + $attachments = apply_filters( 'frm_notification_attachment', array(), $form, compact( 'entry', 'email_key' ) ); |
|
103 | 103 | |
104 | - if ( ! empty($notification['email_subject']) ) { |
|
105 | - $notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key')); |
|
104 | + if ( ! empty( $notification['email_subject'] ) ) { |
|
105 | + $notification['email_subject'] = apply_filters( 'frm_email_subject', $notification['email_subject'], compact( 'form', 'entry', 'email_key' ) ); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | // check for a phone number |
109 | 109 | foreach ( (array) $to_emails as $email_key => $e ) { |
110 | - if ( $e != '[admin_email]' && ! is_email($e) ) { |
|
111 | - $e = explode(' ', $e); |
|
110 | + if ( $e != '[admin_email]' && ! is_email( $e ) ) { |
|
111 | + $e = explode( ' ', $e ); |
|
112 | 112 | |
113 | 113 | //If to_email has name <[email protected]> format |
114 | - if ( is_email(end($e)) ) { |
|
114 | + if ( is_email( end( $e ) ) ) { |
|
115 | 115 | continue; |
116 | 116 | } |
117 | 117 | |
118 | - do_action('frm_send_to_not_email', array( |
|
118 | + do_action( 'frm_send_to_not_email', array( |
|
119 | 119 | 'e' => $e, |
120 | 120 | 'subject' => $notification['email_subject'], |
121 | 121 | 'mail_body' => $mail_body, |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | 'email_key' => $email_key, |
128 | 128 | ) ); |
129 | 129 | |
130 | - unset( $to_emails[ $email_key ] ); |
|
130 | + unset( $to_emails[$email_key] ); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
@@ -148,18 +148,18 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | public function entry_created( $entry_id, $form_id ) { |
151 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmFormActionsController::trigger_actions("create", '. $form_id .', '. $entry_id .', "email")'); |
|
152 | - FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email'); |
|
151 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmFormActionsController::trigger_actions("create", ' . $form_id . ', ' . $entry_id . ', "email")' ); |
|
152 | + FrmFormActionsController::trigger_actions( 'create', $form_id, $entry_id, 'email' ); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | public function send_notification_email( $to_email, $subject, $message, $from = '', $from_name = '', $plain_text = true, $attachments = array(), $reply_to = '' ) { |
156 | 156 | _deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' ); |
157 | 157 | |
158 | - return self::send_email(compact( |
|
158 | + return self::send_email( compact( |
|
159 | 159 | 'to_email', 'subject', 'message', |
160 | 160 | 'from', 'from_name', 'plain_text', |
161 | 161 | 'attachments', 'reply_to' |
162 | - )); |
|
162 | + ) ); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -192,28 +192,28 @@ discard block |
||
192 | 192 | private static function format_email_fields( &$atts, $admin_email ) { |
193 | 193 | |
194 | 194 | // If from is empty or is set to admin_email, set it now |
195 | - $atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from']; |
|
195 | + $atts['from'] = ( empty( $atts['from'] ) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from']; |
|
196 | 196 | |
197 | 197 | // Filter values in these fields |
198 | 198 | $filter_fields = array( 'to_email', 'bcc', 'cc', 'from', 'reply_to' ); |
199 | 199 | |
200 | 200 | foreach ( $filter_fields as $f ) { |
201 | 201 | // If empty, just skip it |
202 | - if ( empty( $atts[ $f ] ) ) { |
|
202 | + if ( empty( $atts[$f] ) ) { |
|
203 | 203 | continue; |
204 | 204 | } |
205 | 205 | |
206 | 206 | // to_email, cc, and bcc can be an array |
207 | - if ( is_array( $atts[ $f ] ) ) { |
|
208 | - foreach ( $atts[ $f ] as $key => $val ) { |
|
207 | + if ( is_array( $atts[$f] ) ) { |
|
208 | + foreach ( $atts[$f] as $key => $val ) { |
|
209 | 209 | self::format_single_field( $atts, $f, $val, $key ); |
210 | 210 | unset( $key, $val ); |
211 | 211 | } |
212 | - unset($f); |
|
212 | + unset( $f ); |
|
213 | 213 | continue; |
214 | 214 | } |
215 | 215 | |
216 | - self::format_single_field( $atts, $f, $atts[ $f ] ); |
|
216 | + self::format_single_field( $atts, $f, $atts[$f] ); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | // If reply-to isn't set, make it match the from settings |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | $atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] ); |
222 | 222 | } |
223 | 223 | |
224 | - if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) { |
|
224 | + if ( ! is_array( $atts['to_email'] ) && '[admin_email]' == $atts['to_email'] ) { |
|
225 | 225 | $atts['to_email'] = $admin_email; |
226 | 226 | } |
227 | 227 | } |
@@ -244,20 +244,20 @@ discard block |
||
244 | 244 | * @param int $key if in array, this will be set |
245 | 245 | */ |
246 | 246 | private static function format_single_field( &$atts, $f, $val, $key = false ) { |
247 | - $val = trim($val); |
|
247 | + $val = trim( $val ); |
|
248 | 248 | |
249 | 249 | // If just a plain email is used |
250 | - if ( is_email($val) ) { |
|
250 | + if ( is_email( $val ) ) { |
|
251 | 251 | // add sender's name if not included in $from |
252 | 252 | if ( $f == 'from' ) { |
253 | - $part_2 = $atts[ $f ]; |
|
254 | - $part_1 = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
253 | + $part_2 = $atts[$f]; |
|
254 | + $part_1 = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
255 | 255 | } else { |
256 | 256 | return; |
257 | 257 | } |
258 | 258 | } else { |
259 | - $parts = explode(' ', $val); |
|
260 | - $part_2 = end($parts); |
|
259 | + $parts = explode( ' ', $val ); |
|
260 | + $part_2 = end( $parts ); |
|
261 | 261 | |
262 | 262 | // If inputted correcly, $part_2 should be an email |
263 | 263 | if ( is_email( $part_2 ) ) { |
@@ -265,14 +265,14 @@ discard block |
||
265 | 265 | } else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) { |
266 | 266 | // In case someone just puts a name in the From or Reply To field |
267 | 267 | $part_1 = $val; |
268 | - $part_2 = get_option('admin_email'); |
|
268 | + $part_2 = get_option( 'admin_email' ); |
|
269 | 269 | } else { |
270 | 270 | // In case someone just puts a name in any other email field |
271 | 271 | if ( false !== $key ) { |
272 | - unset( $atts[ $f ][ $key ] ); |
|
272 | + unset( $atts[$f][$key] ); |
|
273 | 273 | return; |
274 | 274 | } |
275 | - $atts[ $f ] = ''; |
|
275 | + $atts[$f] = ''; |
|
276 | 276 | return; |
277 | 277 | } |
278 | 278 | } |
@@ -289,18 +289,18 @@ discard block |
||
289 | 289 | } |
290 | 290 | |
291 | 291 | // Set up formatted value |
292 | - $final_val = str_replace( '"', '', $part_1 ) . ' <'. $part_2 .'>'; |
|
292 | + $final_val = str_replace( '"', '', $part_1 ) . ' <' . $part_2 . '>'; |
|
293 | 293 | |
294 | 294 | // If value is an array |
295 | 295 | if ( false !== $key ) { |
296 | - $atts[ $f ][ $key ] = $final_val; |
|
296 | + $atts[$f][$key] = $final_val; |
|
297 | 297 | return; |
298 | 298 | } |
299 | - $atts[ $f ] = $final_val; |
|
299 | + $atts[$f] = $final_val; |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | public static function send_email( $atts ) { |
303 | - $admin_email = get_option('admin_email'); |
|
303 | + $admin_email = get_option( 'admin_email' ); |
|
304 | 304 | $defaults = array( |
305 | 305 | 'to_email' => $admin_email, |
306 | 306 | 'subject' => '', |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | 'reply_to' => $admin_email, |
314 | 314 | 'attachments' => array(), |
315 | 315 | ); |
316 | - $atts = wp_parse_args($atts, $defaults); |
|
316 | + $atts = wp_parse_args( $atts, $defaults ); |
|
317 | 317 | |
318 | 318 | // Put To, BCC, CC, Reply To, and From fields in the correct format |
319 | 319 | self::format_email_fields( $atts, $admin_email ); |
@@ -326,68 +326,68 @@ discard block |
||
326 | 326 | $array_fields = array( 'CC' => $atts['cc'], 'BCC' => $atts['bcc'] ); |
327 | 327 | $cc = array( 'CC' => array(), 'BCC' => array() ); |
328 | 328 | foreach ( $array_fields as $key => $a_field ) { |
329 | - if ( empty($a_field) ) { |
|
329 | + if ( empty( $a_field ) ) { |
|
330 | 330 | continue; |
331 | 331 | } |
332 | 332 | |
333 | 333 | foreach ( (array) $a_field as $email ) { |
334 | - $cc[ $key ][] = $email; |
|
334 | + $cc[$key][] = $email; |
|
335 | 335 | } |
336 | - unset($key, $a_field); |
|
336 | + unset( $key, $a_field ); |
|
337 | 337 | } |
338 | 338 | $cc = array_filter( $cc ); // remove cc and bcc if they are empty |
339 | 339 | |
340 | 340 | foreach ( $cc as $k => $v ) { |
341 | - $header[] = $k . ': '. implode( ',', $v ); |
|
341 | + $header[] = $k . ': ' . implode( ',', $v ); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | $content_type = $atts['plain_text'] ? 'text/plain' : 'text/html'; |
345 | - $charset = get_option('blog_charset'); |
|
345 | + $charset = get_option( 'blog_charset' ); |
|
346 | 346 | |
347 | - $header[] = 'Reply-To: '. $atts['reply_to']; |
|
348 | - $header[] = 'Content-Type: ' . $content_type . '; charset="' . esc_attr( $charset ) . '"'; |
|
349 | - $atts['subject'] = wp_specialchars_decode(strip_tags(stripslashes($atts['subject'])), ENT_QUOTES ); |
|
347 | + $header[] = 'Reply-To: ' . $atts['reply_to']; |
|
348 | + $header[] = 'Content-Type: ' . $content_type . '; charset="' . esc_attr( $charset ) . '"'; |
|
349 | + $atts['subject'] = wp_specialchars_decode( strip_tags( stripslashes( $atts['subject'] ) ), ENT_QUOTES ); |
|
350 | 350 | |
351 | - $message = do_shortcode($atts['message']); |
|
351 | + $message = do_shortcode( $atts['message'] ); |
|
352 | 352 | |
353 | 353 | if ( $atts['plain_text'] ) { |
354 | 354 | //$message = wordwrap($message, 70, "\r\n"); //in case any lines are longer than 70 chars |
355 | - $message = wp_specialchars_decode(strip_tags($message), ENT_QUOTES ); |
|
355 | + $message = wp_specialchars_decode( strip_tags( $message ), ENT_QUOTES ); |
|
356 | 356 | } else { |
357 | 357 | // remove line breaks in HTML emails to prevent conflicts with Mandrill |
358 | 358 | add_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' ); |
359 | 359 | } |
360 | 360 | $message = apply_filters( 'frm_email_message', $message, $atts ); |
361 | 361 | |
362 | - $header = apply_filters('frm_email_header', $header, array( |
|
362 | + $header = apply_filters( 'frm_email_header', $header, array( |
|
363 | 363 | 'to_email' => $atts['to_email'], 'subject' => $atts['subject'], |
364 | 364 | ) ); |
365 | 365 | |
366 | - if ( apply_filters('frm_encode_subject', 1, $atts['subject'] ) ) { |
|
367 | - $atts['subject'] = '=?'. $charset .'?B?'. base64_encode($atts['subject']) .'?='; |
|
366 | + if ( apply_filters( 'frm_encode_subject', 1, $atts['subject'] ) ) { |
|
367 | + $atts['subject'] = '=?' . $charset . '?B?' . base64_encode( $atts['subject'] ) . '?='; |
|
368 | 368 | } |
369 | 369 | |
370 | - remove_filter('wp_mail_from', 'bp_core_email_from_address_filter' ); |
|
371 | - remove_filter('wp_mail_from_name', 'bp_core_email_from_name_filter'); |
|
370 | + remove_filter( 'wp_mail_from', 'bp_core_email_from_address_filter' ); |
|
371 | + remove_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' ); |
|
372 | 372 | |
373 | - $sent = wp_mail($recipient, $atts['subject'], $message, $header, $atts['attachments']); |
|
373 | + $sent = wp_mail( $recipient, $atts['subject'], $message, $header, $atts['attachments'] ); |
|
374 | 374 | if ( ! $sent ) { |
375 | - $header = 'From: '. $atts['from'] ."\r\n"; |
|
376 | - $recipient = implode(',', (array) $recipient); |
|
377 | - $sent = mail($recipient, $atts['subject'], $message, $header); |
|
375 | + $header = 'From: ' . $atts['from'] . "\r\n"; |
|
376 | + $recipient = implode( ',', (array) $recipient ); |
|
377 | + $sent = mail( $recipient, $atts['subject'], $message, $header ); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | // remove the filter now so other emails can still use it |
381 | 381 | remove_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' ); |
382 | 382 | |
383 | - do_action('frm_notification', $recipient, $atts['subject'], $message); |
|
383 | + do_action( 'frm_notification', $recipient, $atts['subject'], $message ); |
|
384 | 384 | |
385 | 385 | if ( $sent ) { |
386 | 386 | $sent_to = array_merge( (array) $atts['to_email'], (array) $atts['cc'], (array) $atts['bcc'] ); |
387 | 387 | $sent_to = array_filter( $sent_to ); |
388 | - if ( apply_filters('frm_echo_emails', false) ) { |
|
389 | - $temp = str_replace('<', '<', $sent_to); |
|
390 | - echo ' ' . FrmAppHelper::kses( implode(', ', (array) $temp ) ); |
|
388 | + if ( apply_filters( 'frm_echo_emails', false ) ) { |
|
389 | + $temp = str_replace( '<', '<', $sent_to ); |
|
390 | + echo ' ' . FrmAppHelper::kses( implode( ', ', (array) $temp ) ); |
|
391 | 391 | } |
392 | 392 | return $sent_to; |
393 | 393 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class FrmSettings{ |
|
3 | +class FrmSettings { |
|
4 | 4 | public $option_name = 'frm_options'; |
5 | 5 | public $menu; |
6 | 6 | public $mu_menu; |
@@ -28,19 +28,19 @@ discard block |
||
28 | 28 | public $re_msg; |
29 | 29 | |
30 | 30 | public function __construct() { |
31 | - if ( ! defined('ABSPATH') ) { |
|
32 | - die('You are not allowed to call this page directly.'); |
|
31 | + if ( ! defined( 'ABSPATH' ) ) { |
|
32 | + die( 'You are not allowed to call this page directly.' ); |
|
33 | 33 | } |
34 | 34 | |
35 | - $settings = get_transient($this->option_name); |
|
35 | + $settings = get_transient( $this->option_name ); |
|
36 | 36 | |
37 | - if ( ! is_object($settings) ) { |
|
38 | - $settings = $this->translate_settings($settings); |
|
37 | + if ( ! is_object( $settings ) ) { |
|
38 | + $settings = $this->translate_settings( $settings ); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | foreach ( $settings as $setting_name => $setting ) { |
42 | 42 | $this->{$setting_name} = $setting; |
43 | - unset($setting_name, $setting); |
|
43 | + unset( $setting_name, $setting ); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | $this->set_default_options(); |
@@ -48,24 +48,24 @@ discard block |
||
48 | 48 | |
49 | 49 | private function translate_settings( $settings ) { |
50 | 50 | if ( $settings ) { //workaround for W3 total cache conflict |
51 | - return unserialize(serialize($settings)); |
|
51 | + return unserialize( serialize( $settings ) ); |
|
52 | 52 | } |
53 | 53 | |
54 | - $settings = get_option($this->option_name); |
|
55 | - if ( is_object($settings) ) { |
|
56 | - set_transient($this->option_name, $settings); |
|
54 | + $settings = get_option( $this->option_name ); |
|
55 | + if ( is_object( $settings ) ) { |
|
56 | + set_transient( $this->option_name, $settings ); |
|
57 | 57 | return $settings; |
58 | 58 | } |
59 | 59 | |
60 | 60 | // If unserializing didn't work |
61 | 61 | if ( $settings ) { //workaround for W3 total cache conflict |
62 | - $settings = unserialize(serialize($settings)); |
|
62 | + $settings = unserialize( serialize( $settings ) ); |
|
63 | 63 | } else { |
64 | 64 | $settings = $this; |
65 | 65 | } |
66 | 66 | |
67 | - update_option($this->option_name, $settings); |
|
68 | - set_transient($this->option_name, $settings); |
|
67 | + update_option( $this->option_name, $settings ); |
|
68 | + set_transient( $this->option_name, $settings ); |
|
69 | 69 | |
70 | 70 | return $settings; |
71 | 71 | } |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | private function set_default_options() { |
99 | 99 | $this->fill_recaptcha_settings(); |
100 | 100 | |
101 | - if ( ! isset($this->load_style) ) { |
|
102 | - if ( ! isset($this->custom_style) ) { |
|
101 | + if ( ! isset( $this->load_style ) ) { |
|
102 | + if ( ! isset( $this->custom_style ) ) { |
|
103 | 103 | $this->custom_style = true; |
104 | 104 | } |
105 | 105 | |
@@ -109,16 +109,16 @@ discard block |
||
109 | 109 | $this->fill_with_defaults(); |
110 | 110 | |
111 | 111 | if ( is_multisite() && is_admin() ) { |
112 | - $mu_menu = get_site_option('frm_admin_menu_name'); |
|
113 | - if ( $mu_menu && ! empty($mu_menu) ) { |
|
112 | + $mu_menu = get_site_option( 'frm_admin_menu_name' ); |
|
113 | + if ( $mu_menu && ! empty( $mu_menu ) ) { |
|
114 | 114 | $this->menu = $mu_menu; |
115 | 115 | $this->mu_menu = 1; |
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
119 | - $frm_roles = FrmAppHelper::frm_capabilities('pro'); |
|
119 | + $frm_roles = FrmAppHelper::frm_capabilities( 'pro' ); |
|
120 | 120 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
121 | - if ( ! isset($this->$frm_role) ) { |
|
121 | + if ( ! isset( $this->$frm_role ) ) { |
|
122 | 122 | $this->$frm_role = 'administrator'; |
123 | 123 | } |
124 | 124 | } |
@@ -128,12 +128,12 @@ discard block |
||
128 | 128 | $settings = $this->default_options(); |
129 | 129 | |
130 | 130 | foreach ( $settings as $setting => $default ) { |
131 | - if ( isset( $params[ 'frm_' . $setting ] ) ) { |
|
132 | - $this->{$setting} = $params[ 'frm_' . $setting ]; |
|
133 | - } else if ( ! isset($this->{$setting}) ) { |
|
131 | + if ( isset( $params['frm_' . $setting] ) ) { |
|
132 | + $this->{$setting} = $params['frm_' . $setting]; |
|
133 | + } else if ( ! isset( $this->{$setting}) ) { |
|
134 | 134 | $this->{$setting} = $default; |
135 | 135 | } |
136 | - unset($setting, $default); |
|
136 | + unset( $setting, $default ); |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
@@ -141,23 +141,23 @@ discard block |
||
141 | 141 | $privkey = ''; |
142 | 142 | $re_lang = 'en'; |
143 | 143 | |
144 | - if ( ! isset($this->pubkey) ) { |
|
144 | + if ( ! isset( $this->pubkey ) ) { |
|
145 | 145 | // get the options from the database |
146 | - $recaptcha_opt = is_multisite() ? get_site_option('recaptcha') : get_option('recaptcha'); |
|
147 | - $this->pubkey = isset($recaptcha_opt['pubkey']) ? $recaptcha_opt['pubkey'] : ''; |
|
148 | - $privkey = isset($recaptcha_opt['privkey']) ? $recaptcha_opt['privkey'] : $privkey; |
|
149 | - $re_lang = isset($recaptcha_opt['re_lang']) ? $recaptcha_opt['re_lang'] : $re_lang; |
|
146 | + $recaptcha_opt = is_multisite() ? get_site_option( 'recaptcha' ) : get_option( 'recaptcha' ); |
|
147 | + $this->pubkey = isset( $recaptcha_opt['pubkey'] ) ? $recaptcha_opt['pubkey'] : ''; |
|
148 | + $privkey = isset( $recaptcha_opt['privkey'] ) ? $recaptcha_opt['privkey'] : $privkey; |
|
149 | + $re_lang = isset( $recaptcha_opt['re_lang'] ) ? $recaptcha_opt['re_lang'] : $re_lang; |
|
150 | 150 | } |
151 | 151 | |
152 | - if ( ! isset($this->re_msg) || empty($this->re_msg) ) { |
|
152 | + if ( ! isset( $this->re_msg ) || empty( $this->re_msg ) ) { |
|
153 | 153 | $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' ); |
154 | 154 | } |
155 | 155 | |
156 | - if ( ! isset($this->privkey) ) { |
|
156 | + if ( ! isset( $this->privkey ) ) { |
|
157 | 157 | $this->privkey = $privkey; |
158 | 158 | } |
159 | 159 | |
160 | - if ( ! isset($this->re_lang) ) { |
|
160 | + if ( ! isset( $this->re_lang ) ) { |
|
161 | 161 | $this->re_lang = $re_lang; |
162 | 162 | } |
163 | 163 | } |
@@ -168,31 +168,31 @@ discard block |
||
168 | 168 | } |
169 | 169 | |
170 | 170 | public function update( $params ) { |
171 | - $this->fill_with_defaults($params); |
|
172 | - $this->update_settings($params); |
|
171 | + $this->fill_with_defaults( $params ); |
|
172 | + $this->update_settings( $params ); |
|
173 | 173 | |
174 | 174 | if ( $this->mu_menu ) { |
175 | - update_site_option('frm_admin_menu_name', $this->menu); |
|
176 | - } else if ( current_user_can('administrator') ) { |
|
177 | - update_site_option('frm_admin_menu_name', false); |
|
175 | + update_site_option( 'frm_admin_menu_name', $this->menu ); |
|
176 | + } else if ( current_user_can( 'administrator' ) ) { |
|
177 | + update_site_option( 'frm_admin_menu_name', false ); |
|
178 | 178 | } |
179 | 179 | |
180 | - $this->update_roles($params); |
|
180 | + $this->update_roles( $params ); |
|
181 | 181 | |
182 | 182 | do_action( 'frm_update_settings', $params ); |
183 | 183 | } |
184 | 184 | |
185 | 185 | private function update_settings( $params ) { |
186 | - $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0; |
|
186 | + $this->mu_menu = isset( $params['frm_mu_menu'] ) ? $params['frm_mu_menu'] : 0; |
|
187 | 187 | |
188 | - $this->pubkey = trim($params['frm_pubkey']); |
|
188 | + $this->pubkey = trim( $params['frm_pubkey'] ); |
|
189 | 189 | $this->privkey = $params['frm_privkey']; |
190 | 190 | $this->re_lang = $params['frm_re_lang']; |
191 | 191 | |
192 | 192 | $this->load_style = $params['frm_load_style']; |
193 | 193 | $this->preview_page_id = (int) $params['frm-preview-page-id']; |
194 | 194 | |
195 | - $this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0; |
|
195 | + $this->use_html = isset( $params['frm_use_html'] ) ? $params['frm_use_html'] : 0; |
|
196 | 196 | //$this->custom_style = isset($params['frm_custom_style']) ? $params['frm_custom_style'] : 0; |
197 | 197 | $this->jquery_css = isset( $params['frm_jquery_css'] ) ? absint( $params['frm_jquery_css'] ) : 0; |
198 | 198 | $this->accordion_js = isset( $params['frm_accordion_js'] ) ? absint( $params['frm_accordion_js'] ) : 0; |
@@ -205,30 +205,30 @@ discard block |
||
205 | 205 | $frm_roles = FrmAppHelper::frm_capabilities(); |
206 | 206 | $roles = get_editable_roles(); |
207 | 207 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
208 | - $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' ); |
|
208 | + $this->$frm_role = (array) ( isset( $params[$frm_role] ) ? $params[$frm_role] : 'administrator' ); |
|
209 | 209 | |
210 | - if ( count($this->$frm_role) === 1 ) { |
|
211 | - $set_role = reset($this->$frm_role); |
|
210 | + if ( count( $this->$frm_role ) === 1 ) { |
|
211 | + $set_role = reset( $this->$frm_role ); |
|
212 | 212 | switch ( $set_role ) { |
213 | 213 | case 'subscriber': |
214 | - array_push($this->$frm_role, 'contributor'); |
|
214 | + array_push( $this->$frm_role, 'contributor' ); |
|
215 | 215 | case 'contributor': |
216 | - array_push($this->$frm_role, 'author'); |
|
216 | + array_push( $this->$frm_role, 'author' ); |
|
217 | 217 | case 'author': |
218 | - array_push($this->$frm_role, 'editor'); |
|
218 | + array_push( $this->$frm_role, 'editor' ); |
|
219 | 219 | case 'editor': |
220 | - array_push($this->$frm_role, 'administrator'); |
|
220 | + array_push( $this->$frm_role, 'administrator' ); |
|
221 | 221 | } |
222 | - unset($set_role); |
|
222 | + unset( $set_role ); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | foreach ( $roles as $role => $details ) { |
226 | - if ( in_array($role, $this->$frm_role) ) { |
|
226 | + if ( in_array( $role, $this->$frm_role ) ) { |
|
227 | 227 | $wp_roles->add_cap( $role, $frm_role ); |
228 | 228 | } else { |
229 | 229 | $wp_roles->remove_cap( $role, $frm_role ); |
230 | 230 | } |
231 | - unset($role, $details); |
|
231 | + unset( $role, $details ); |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | } |
@@ -236,10 +236,10 @@ discard block |
||
236 | 236 | public function store() { |
237 | 237 | // Save the posted value in the database |
238 | 238 | |
239 | - update_option('frm_options', $this); |
|
239 | + update_option( 'frm_options', $this ); |
|
240 | 240 | |
241 | - delete_transient('frm_options'); |
|
242 | - set_transient('frm_options', $this); |
|
241 | + delete_transient( 'frm_options' ); |
|
242 | + set_transient( 'frm_options', $this ); |
|
243 | 243 | |
244 | 244 | do_action( 'frm_store_settings' ); |
245 | 245 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class FrmSettings{ |
|
3 | +class FrmSettings { |
|
4 | 4 | public $option_name = 'frm_options'; |
5 | 5 | public $menu; |
6 | 6 | public $mu_menu; |
@@ -47,7 +47,8 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | private function translate_settings( $settings ) { |
50 | - if ( $settings ) { //workaround for W3 total cache conflict |
|
50 | + if ( $settings ) { |
|
51 | +//workaround for W3 total cache conflict |
|
51 | 52 | return unserialize(serialize($settings)); |
52 | 53 | } |
53 | 54 | |
@@ -58,7 +59,8 @@ discard block |
||
58 | 59 | } |
59 | 60 | |
60 | 61 | // If unserializing didn't work |
61 | - if ( $settings ) { //workaround for W3 total cache conflict |
|
62 | + if ( $settings ) { |
|
63 | +//workaround for W3 total cache conflict |
|
62 | 64 | $settings = unserialize(serialize($settings)); |
63 | 65 | } else { |
64 | 66 | $settings = $this; |
@@ -1,246 +1,246 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class FrmSettings{ |
4 | - public $option_name = 'frm_options'; |
|
5 | - public $menu; |
|
6 | - public $mu_menu; |
|
7 | - public $preview_page_id; |
|
8 | - public $use_html; |
|
9 | - public $jquery_css; |
|
10 | - public $accordion_js; |
|
11 | - |
|
12 | - public $success_msg; |
|
13 | - public $blank_msg; |
|
14 | - public $unique_msg; |
|
15 | - public $invalid_msg; |
|
16 | - public $failed_msg; |
|
17 | - public $submit_value; |
|
18 | - public $login_msg; |
|
19 | - public $admin_permission; |
|
20 | - |
|
21 | - public $email_to; |
|
22 | - public $load_style; |
|
23 | - public $custom_style; |
|
24 | - |
|
25 | - public $pubkey; |
|
26 | - public $privkey; |
|
27 | - public $re_lang; |
|
28 | - public $re_msg; |
|
29 | - |
|
30 | - public function __construct() { |
|
31 | - if ( ! defined('ABSPATH') ) { |
|
32 | - die('You are not allowed to call this page directly.'); |
|
33 | - } |
|
34 | - |
|
35 | - $settings = get_transient($this->option_name); |
|
36 | - |
|
37 | - if ( ! is_object($settings) ) { |
|
38 | - $settings = $this->translate_settings($settings); |
|
39 | - } |
|
40 | - |
|
41 | - foreach ( $settings as $setting_name => $setting ) { |
|
42 | - $this->{$setting_name} = $setting; |
|
43 | - unset($setting_name, $setting); |
|
44 | - } |
|
45 | - |
|
46 | - $this->set_default_options(); |
|
47 | - } |
|
4 | + public $option_name = 'frm_options'; |
|
5 | + public $menu; |
|
6 | + public $mu_menu; |
|
7 | + public $preview_page_id; |
|
8 | + public $use_html; |
|
9 | + public $jquery_css; |
|
10 | + public $accordion_js; |
|
11 | + |
|
12 | + public $success_msg; |
|
13 | + public $blank_msg; |
|
14 | + public $unique_msg; |
|
15 | + public $invalid_msg; |
|
16 | + public $failed_msg; |
|
17 | + public $submit_value; |
|
18 | + public $login_msg; |
|
19 | + public $admin_permission; |
|
20 | + |
|
21 | + public $email_to; |
|
22 | + public $load_style; |
|
23 | + public $custom_style; |
|
24 | + |
|
25 | + public $pubkey; |
|
26 | + public $privkey; |
|
27 | + public $re_lang; |
|
28 | + public $re_msg; |
|
29 | + |
|
30 | + public function __construct() { |
|
31 | + if ( ! defined('ABSPATH') ) { |
|
32 | + die('You are not allowed to call this page directly.'); |
|
33 | + } |
|
34 | + |
|
35 | + $settings = get_transient($this->option_name); |
|
36 | + |
|
37 | + if ( ! is_object($settings) ) { |
|
38 | + $settings = $this->translate_settings($settings); |
|
39 | + } |
|
40 | + |
|
41 | + foreach ( $settings as $setting_name => $setting ) { |
|
42 | + $this->{$setting_name} = $setting; |
|
43 | + unset($setting_name, $setting); |
|
44 | + } |
|
45 | + |
|
46 | + $this->set_default_options(); |
|
47 | + } |
|
48 | 48 | |
49 | 49 | private function translate_settings( $settings ) { |
50 | - if ( $settings ) { //workaround for W3 total cache conflict |
|
51 | - return unserialize(serialize($settings)); |
|
52 | - } |
|
53 | - |
|
54 | - $settings = get_option($this->option_name); |
|
55 | - if ( is_object($settings) ) { |
|
56 | - set_transient($this->option_name, $settings); |
|
57 | - return $settings; |
|
58 | - } |
|
59 | - |
|
60 | - // If unserializing didn't work |
|
61 | - if ( $settings ) { //workaround for W3 total cache conflict |
|
62 | - $settings = unserialize(serialize($settings)); |
|
63 | - } else { |
|
64 | - $settings = $this; |
|
65 | - } |
|
66 | - |
|
67 | - update_option($this->option_name, $settings); |
|
68 | - set_transient($this->option_name, $settings); |
|
69 | - |
|
70 | - return $settings; |
|
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * @return array |
|
75 | - */ |
|
50 | + if ( $settings ) { //workaround for W3 total cache conflict |
|
51 | + return unserialize(serialize($settings)); |
|
52 | + } |
|
53 | + |
|
54 | + $settings = get_option($this->option_name); |
|
55 | + if ( is_object($settings) ) { |
|
56 | + set_transient($this->option_name, $settings); |
|
57 | + return $settings; |
|
58 | + } |
|
59 | + |
|
60 | + // If unserializing didn't work |
|
61 | + if ( $settings ) { //workaround for W3 total cache conflict |
|
62 | + $settings = unserialize(serialize($settings)); |
|
63 | + } else { |
|
64 | + $settings = $this; |
|
65 | + } |
|
66 | + |
|
67 | + update_option($this->option_name, $settings); |
|
68 | + set_transient($this->option_name, $settings); |
|
69 | + |
|
70 | + return $settings; |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * @return array |
|
75 | + */ |
|
76 | 76 | public function default_options() { |
77 | - return array( |
|
78 | - 'menu' => __( 'Forms', 'formidable' ), |
|
79 | - 'mu_menu' => 0, |
|
80 | - 'preview_page_id' => 0, |
|
81 | - 'use_html' => true, |
|
82 | - 'jquery_css' => false, |
|
83 | - 'accordion_js' => false, |
|
84 | - |
|
85 | - 'success_msg' => __( 'Your responses were successfully submitted. Thank you!', 'formidable' ), |
|
86 | - 'blank_msg' => __( 'This field cannot be blank.', 'formidable' ), |
|
87 | - 'unique_msg' => __( 'This value must be unique.', 'formidable' ), |
|
88 | - 'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ), |
|
89 | - 'failed_msg' => __( 'We\'re sorry. It looks like you\'ve already submitted that.', 'formidable' ), |
|
90 | - 'submit_value' => __( 'Submit', 'formidable' ), |
|
91 | - 'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ), |
|
92 | - 'admin_permission' => __( 'You do not have permission to do that', 'formidable' ), |
|
93 | - |
|
94 | - 'email_to' => '[admin_email]', |
|
95 | - ); |
|
96 | - } |
|
77 | + return array( |
|
78 | + 'menu' => __( 'Forms', 'formidable' ), |
|
79 | + 'mu_menu' => 0, |
|
80 | + 'preview_page_id' => 0, |
|
81 | + 'use_html' => true, |
|
82 | + 'jquery_css' => false, |
|
83 | + 'accordion_js' => false, |
|
84 | + |
|
85 | + 'success_msg' => __( 'Your responses were successfully submitted. Thank you!', 'formidable' ), |
|
86 | + 'blank_msg' => __( 'This field cannot be blank.', 'formidable' ), |
|
87 | + 'unique_msg' => __( 'This value must be unique.', 'formidable' ), |
|
88 | + 'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ), |
|
89 | + 'failed_msg' => __( 'We\'re sorry. It looks like you\'ve already submitted that.', 'formidable' ), |
|
90 | + 'submit_value' => __( 'Submit', 'formidable' ), |
|
91 | + 'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ), |
|
92 | + 'admin_permission' => __( 'You do not have permission to do that', 'formidable' ), |
|
93 | + |
|
94 | + 'email_to' => '[admin_email]', |
|
95 | + ); |
|
96 | + } |
|
97 | 97 | |
98 | 98 | private function set_default_options() { |
99 | - $this->fill_recaptcha_settings(); |
|
100 | - |
|
101 | - if ( ! isset($this->load_style) ) { |
|
102 | - if ( ! isset($this->custom_style) ) { |
|
103 | - $this->custom_style = true; |
|
104 | - } |
|
105 | - |
|
106 | - $this->load_style = 'all'; |
|
107 | - } |
|
108 | - |
|
109 | - $this->fill_with_defaults(); |
|
110 | - |
|
111 | - if ( is_multisite() && is_admin() ) { |
|
112 | - $mu_menu = get_site_option('frm_admin_menu_name'); |
|
113 | - if ( $mu_menu && ! empty($mu_menu) ) { |
|
114 | - $this->menu = $mu_menu; |
|
115 | - $this->mu_menu = 1; |
|
116 | - } |
|
117 | - } |
|
118 | - |
|
119 | - $frm_roles = FrmAppHelper::frm_capabilities('pro'); |
|
120 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
121 | - if ( ! isset($this->$frm_role) ) { |
|
122 | - $this->$frm_role = 'administrator'; |
|
123 | - } |
|
124 | - } |
|
125 | - } |
|
99 | + $this->fill_recaptcha_settings(); |
|
100 | + |
|
101 | + if ( ! isset($this->load_style) ) { |
|
102 | + if ( ! isset($this->custom_style) ) { |
|
103 | + $this->custom_style = true; |
|
104 | + } |
|
105 | + |
|
106 | + $this->load_style = 'all'; |
|
107 | + } |
|
108 | + |
|
109 | + $this->fill_with_defaults(); |
|
110 | + |
|
111 | + if ( is_multisite() && is_admin() ) { |
|
112 | + $mu_menu = get_site_option('frm_admin_menu_name'); |
|
113 | + if ( $mu_menu && ! empty($mu_menu) ) { |
|
114 | + $this->menu = $mu_menu; |
|
115 | + $this->mu_menu = 1; |
|
116 | + } |
|
117 | + } |
|
118 | + |
|
119 | + $frm_roles = FrmAppHelper::frm_capabilities('pro'); |
|
120 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
121 | + if ( ! isset($this->$frm_role) ) { |
|
122 | + $this->$frm_role = 'administrator'; |
|
123 | + } |
|
124 | + } |
|
125 | + } |
|
126 | 126 | |
127 | 127 | public function fill_with_defaults( $params = array() ) { |
128 | - $settings = $this->default_options(); |
|
128 | + $settings = $this->default_options(); |
|
129 | 129 | |
130 | - foreach ( $settings as $setting => $default ) { |
|
130 | + foreach ( $settings as $setting => $default ) { |
|
131 | 131 | if ( isset( $params[ 'frm_' . $setting ] ) ) { |
132 | 132 | $this->{$setting} = $params[ 'frm_' . $setting ]; |
133 | - } else if ( ! isset($this->{$setting}) ) { |
|
134 | - $this->{$setting} = $default; |
|
135 | - } |
|
136 | - unset($setting, $default); |
|
137 | - } |
|
138 | - } |
|
139 | - |
|
140 | - private function fill_recaptcha_settings() { |
|
141 | - $privkey = ''; |
|
142 | - $re_lang = 'en'; |
|
143 | - |
|
144 | - if ( ! isset($this->pubkey) ) { |
|
145 | - // get the options from the database |
|
146 | - $recaptcha_opt = is_multisite() ? get_site_option('recaptcha') : get_option('recaptcha'); |
|
147 | - $this->pubkey = isset($recaptcha_opt['pubkey']) ? $recaptcha_opt['pubkey'] : ''; |
|
148 | - $privkey = isset($recaptcha_opt['privkey']) ? $recaptcha_opt['privkey'] : $privkey; |
|
149 | - $re_lang = isset($recaptcha_opt['re_lang']) ? $recaptcha_opt['re_lang'] : $re_lang; |
|
150 | - } |
|
151 | - |
|
152 | - if ( ! isset($this->re_msg) || empty($this->re_msg) ) { |
|
153 | - $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' ); |
|
154 | - } |
|
155 | - |
|
156 | - if ( ! isset($this->privkey) ) { |
|
157 | - $this->privkey = $privkey; |
|
158 | - } |
|
159 | - |
|
160 | - if ( ! isset($this->re_lang) ) { |
|
161 | - $this->re_lang = $re_lang; |
|
162 | - } |
|
163 | - } |
|
164 | - |
|
165 | - public function validate( $params, $errors ) { |
|
166 | - $errors = apply_filters( 'frm_validate_settings', $errors, $params ); |
|
167 | - return $errors; |
|
168 | - } |
|
133 | + } else if ( ! isset($this->{$setting}) ) { |
|
134 | + $this->{$setting} = $default; |
|
135 | + } |
|
136 | + unset($setting, $default); |
|
137 | + } |
|
138 | + } |
|
139 | + |
|
140 | + private function fill_recaptcha_settings() { |
|
141 | + $privkey = ''; |
|
142 | + $re_lang = 'en'; |
|
143 | + |
|
144 | + if ( ! isset($this->pubkey) ) { |
|
145 | + // get the options from the database |
|
146 | + $recaptcha_opt = is_multisite() ? get_site_option('recaptcha') : get_option('recaptcha'); |
|
147 | + $this->pubkey = isset($recaptcha_opt['pubkey']) ? $recaptcha_opt['pubkey'] : ''; |
|
148 | + $privkey = isset($recaptcha_opt['privkey']) ? $recaptcha_opt['privkey'] : $privkey; |
|
149 | + $re_lang = isset($recaptcha_opt['re_lang']) ? $recaptcha_opt['re_lang'] : $re_lang; |
|
150 | + } |
|
151 | + |
|
152 | + if ( ! isset($this->re_msg) || empty($this->re_msg) ) { |
|
153 | + $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' ); |
|
154 | + } |
|
155 | + |
|
156 | + if ( ! isset($this->privkey) ) { |
|
157 | + $this->privkey = $privkey; |
|
158 | + } |
|
159 | + |
|
160 | + if ( ! isset($this->re_lang) ) { |
|
161 | + $this->re_lang = $re_lang; |
|
162 | + } |
|
163 | + } |
|
164 | + |
|
165 | + public function validate( $params, $errors ) { |
|
166 | + $errors = apply_filters( 'frm_validate_settings', $errors, $params ); |
|
167 | + return $errors; |
|
168 | + } |
|
169 | 169 | |
170 | 170 | public function update( $params ) { |
171 | - $this->fill_with_defaults($params); |
|
172 | - $this->update_settings($params); |
|
171 | + $this->fill_with_defaults($params); |
|
172 | + $this->update_settings($params); |
|
173 | 173 | |
174 | - if ( $this->mu_menu ) { |
|
175 | - update_site_option('frm_admin_menu_name', $this->menu); |
|
176 | - } else if ( current_user_can('administrator') ) { |
|
177 | - update_site_option('frm_admin_menu_name', false); |
|
178 | - } |
|
174 | + if ( $this->mu_menu ) { |
|
175 | + update_site_option('frm_admin_menu_name', $this->menu); |
|
176 | + } else if ( current_user_can('administrator') ) { |
|
177 | + update_site_option('frm_admin_menu_name', false); |
|
178 | + } |
|
179 | 179 | |
180 | - $this->update_roles($params); |
|
180 | + $this->update_roles($params); |
|
181 | 181 | |
182 | - do_action( 'frm_update_settings', $params ); |
|
183 | - } |
|
182 | + do_action( 'frm_update_settings', $params ); |
|
183 | + } |
|
184 | 184 | |
185 | 185 | private function update_settings( $params ) { |
186 | - $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0; |
|
186 | + $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0; |
|
187 | 187 | |
188 | - $this->pubkey = trim($params['frm_pubkey']); |
|
189 | - $this->privkey = $params['frm_privkey']; |
|
190 | - $this->re_lang = $params['frm_re_lang']; |
|
188 | + $this->pubkey = trim($params['frm_pubkey']); |
|
189 | + $this->privkey = $params['frm_privkey']; |
|
190 | + $this->re_lang = $params['frm_re_lang']; |
|
191 | 191 | |
192 | - $this->load_style = $params['frm_load_style']; |
|
193 | - $this->preview_page_id = (int) $params['frm-preview-page-id']; |
|
192 | + $this->load_style = $params['frm_load_style']; |
|
193 | + $this->preview_page_id = (int) $params['frm-preview-page-id']; |
|
194 | 194 | |
195 | - $this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0; |
|
196 | - //$this->custom_style = isset($params['frm_custom_style']) ? $params['frm_custom_style'] : 0; |
|
195 | + $this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0; |
|
196 | + //$this->custom_style = isset($params['frm_custom_style']) ? $params['frm_custom_style'] : 0; |
|
197 | 197 | $this->jquery_css = isset( $params['frm_jquery_css'] ) ? absint( $params['frm_jquery_css'] ) : 0; |
198 | 198 | $this->accordion_js = isset( $params['frm_accordion_js'] ) ? absint( $params['frm_accordion_js'] ) : 0; |
199 | - } |
|
199 | + } |
|
200 | 200 | |
201 | 201 | private function update_roles( $params ) { |
202 | - //update roles |
|
203 | - global $wp_roles; |
|
204 | - |
|
205 | - $frm_roles = FrmAppHelper::frm_capabilities(); |
|
206 | - $roles = get_editable_roles(); |
|
207 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
208 | - $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' ); |
|
209 | - |
|
210 | - if ( count($this->$frm_role) === 1 ) { |
|
211 | - $set_role = reset($this->$frm_role); |
|
212 | - switch ( $set_role ) { |
|
213 | - case 'subscriber': |
|
214 | - array_push($this->$frm_role, 'contributor'); |
|
215 | - case 'contributor': |
|
216 | - array_push($this->$frm_role, 'author'); |
|
217 | - case 'author': |
|
218 | - array_push($this->$frm_role, 'editor'); |
|
219 | - case 'editor': |
|
220 | - array_push($this->$frm_role, 'administrator'); |
|
221 | - } |
|
222 | - unset($set_role); |
|
223 | - } |
|
224 | - |
|
225 | - foreach ( $roles as $role => $details ) { |
|
226 | - if ( in_array($role, $this->$frm_role) ) { |
|
227 | - $wp_roles->add_cap( $role, $frm_role ); |
|
228 | - } else { |
|
229 | - $wp_roles->remove_cap( $role, $frm_role ); |
|
230 | - } |
|
231 | - unset($role, $details); |
|
232 | - } |
|
233 | - } |
|
234 | - } |
|
202 | + //update roles |
|
203 | + global $wp_roles; |
|
204 | + |
|
205 | + $frm_roles = FrmAppHelper::frm_capabilities(); |
|
206 | + $roles = get_editable_roles(); |
|
207 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
208 | + $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' ); |
|
209 | + |
|
210 | + if ( count($this->$frm_role) === 1 ) { |
|
211 | + $set_role = reset($this->$frm_role); |
|
212 | + switch ( $set_role ) { |
|
213 | + case 'subscriber': |
|
214 | + array_push($this->$frm_role, 'contributor'); |
|
215 | + case 'contributor': |
|
216 | + array_push($this->$frm_role, 'author'); |
|
217 | + case 'author': |
|
218 | + array_push($this->$frm_role, 'editor'); |
|
219 | + case 'editor': |
|
220 | + array_push($this->$frm_role, 'administrator'); |
|
221 | + } |
|
222 | + unset($set_role); |
|
223 | + } |
|
224 | + |
|
225 | + foreach ( $roles as $role => $details ) { |
|
226 | + if ( in_array($role, $this->$frm_role) ) { |
|
227 | + $wp_roles->add_cap( $role, $frm_role ); |
|
228 | + } else { |
|
229 | + $wp_roles->remove_cap( $role, $frm_role ); |
|
230 | + } |
|
231 | + unset($role, $details); |
|
232 | + } |
|
233 | + } |
|
234 | + } |
|
235 | 235 | |
236 | 236 | public function store() { |
237 | - // Save the posted value in the database |
|
237 | + // Save the posted value in the database |
|
238 | 238 | |
239 | - update_option('frm_options', $this); |
|
239 | + update_option('frm_options', $this); |
|
240 | 240 | |
241 | - delete_transient('frm_options'); |
|
242 | - set_transient('frm_options', $this); |
|
241 | + delete_transient('frm_options'); |
|
242 | + set_transient('frm_options', $this); |
|
243 | 243 | |
244 | - do_action( 'frm_store_settings' ); |
|
245 | - } |
|
244 | + do_action( 'frm_store_settings' ); |
|
245 | + } |
|
246 | 246 | } |
@@ -4,8 +4,8 @@ |
||
4 | 4 | <?php |
5 | 5 | |
6 | 6 | foreach ( $plugins as $slug => $plugin ) { |
7 | - $license = get_option( 'edd_'. $slug .'_license_key' ); |
|
8 | - $status = get_option( 'edd_'. $slug .'_license_active' ); |
|
7 | + $license = get_option( 'edd_' . $slug . '_license_key' ); |
|
8 | + $status = get_option( 'edd_' . $slug . '_license_active' ); |
|
9 | 9 | $activate = ( false !== $license && $status == 'valid' ) ? 'deactivate' : 'activate'; |
10 | 10 | $icon_class = ( empty( $license ) ) ? 'frm_hidden' : ''; |
11 | 11 | ?> |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | if ( ! isset( $entry) ) { |
3 | - $entry = $record; |
|
3 | + $entry = $record; |
|
4 | 4 | } ?> |
5 | 5 | |
6 | 6 | <div class="misc-pub-section curtime misc-pub-curtime"> |
7 | 7 | <span id="timestamp"> |
8 | 8 | <?php |
9 | - $date_format = __( 'M j, Y @ G:i' ); |
|
9 | + $date_format = __( 'M j, Y @ G:i' ); |
|
10 | 10 | printf( __( 'Published on: <b>%1$s</b>' ), FrmAppHelper::get_localized_date( $date_format, $entry->created_at ) ); ?> |
11 | 11 | </span> |
12 | 12 | </div> |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! isset( $entry) ) { |
|
2 | +if ( ! isset( $entry ) ) { |
|
3 | 3 | $entry = $record; |
4 | 4 | } ?> |
5 | 5 | |
@@ -18,4 +18,4 @@ discard block |
||
18 | 18 | </div> |
19 | 19 | <?php } ?> |
20 | 20 | |
21 | -<?php do_action('frm_entry_shared_sidebar', $entry); ?> |
|
21 | +<?php do_action( 'frm_entry_shared_sidebar', $entry ); ?> |
@@ -4,30 +4,30 @@ |
||
4 | 4 | <?php |
5 | 5 | } |
6 | 6 | if ( isset( $message ) && $message != '' ) { |
7 | - if ( FrmAppHelper::is_admin() ) { |
|
7 | + if ( FrmAppHelper::is_admin() ) { |
|
8 | 8 | ?><div id="message" class="frm_message updated frm_msg_padding"><?php echo wp_kses_post( $message ) ?></div><?php |
9 | 9 | } else { |
10 | - FrmFormsHelper::get_scroll_js($form->id); |
|
10 | + FrmFormsHelper::get_scroll_js($form->id); |
|
11 | 11 | |
12 | 12 | // we need to allow scripts here for javascript in the success message |
13 | 13 | echo $message; |
14 | - } |
|
14 | + } |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | if ( isset($errors) && is_array( $errors ) && ! empty( $errors ) ) { |
18 | 18 | |
19 | 19 | if ( isset( $form ) && is_object( $form ) ) { |
20 | - FrmFormsHelper::get_scroll_js( $form->id ); |
|
20 | + FrmFormsHelper::get_scroll_js( $form->id ); |
|
21 | 21 | } ?> |
22 | 22 | <div class="frm_error_style"> |
23 | 23 | <?php |
24 | 24 | $img = ''; |
25 | 25 | if ( ! FrmAppHelper::is_admin() ) { |
26 | - $img = apply_filters('frm_error_icon', $img); |
|
27 | - if ( $img && ! empty($img) ) { |
|
28 | - ?><img src="<?php echo esc_attr( $img ) ?>" alt="" /> |
|
26 | + $img = apply_filters('frm_error_icon', $img); |
|
27 | + if ( $img && ! empty($img) ) { |
|
28 | + ?><img src="<?php echo esc_attr( $img ) ?>" alt="" /> |
|
29 | 29 | <?php |
30 | - } |
|
30 | + } |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | FrmFormsHelper::show_errors( compact( 'img', 'errors' ) ); |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( isset($include_extra_container) ) { ?> |
|
2 | +if ( isset( $include_extra_container ) ) { ?> |
|
3 | 3 | <div class="<?php echo esc_attr( $include_extra_container ) ?>" id="frm_form_<?php echo esc_attr( $form->id ) ?>_container"> |
4 | 4 | <?php |
5 | 5 | } |
@@ -7,14 +7,14 @@ discard block |
||
7 | 7 | if ( FrmAppHelper::is_admin() ) { |
8 | 8 | ?><div id="message" class="frm_message updated frm_msg_padding"><?php echo wp_kses_post( $message ) ?></div><?php |
9 | 9 | } else { |
10 | - FrmFormsHelper::get_scroll_js($form->id); |
|
10 | + FrmFormsHelper::get_scroll_js( $form->id ); |
|
11 | 11 | |
12 | 12 | // we need to allow scripts here for javascript in the success message |
13 | 13 | echo $message; |
14 | 14 | } |
15 | 15 | } |
16 | 16 | |
17 | -if ( isset($errors) && is_array( $errors ) && ! empty( $errors ) ) { |
|
17 | +if ( isset( $errors ) && is_array( $errors ) && ! empty( $errors ) ) { |
|
18 | 18 | |
19 | 19 | if ( isset( $form ) && is_object( $form ) ) { |
20 | 20 | FrmFormsHelper::get_scroll_js( $form->id ); |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | <?php |
24 | 24 | $img = ''; |
25 | 25 | if ( ! FrmAppHelper::is_admin() ) { |
26 | - $img = apply_filters('frm_error_icon', $img); |
|
27 | - if ( $img && ! empty($img) ) { |
|
26 | + $img = apply_filters( 'frm_error_icon', $img ); |
|
27 | + if ( $img && ! empty( $img ) ) { |
|
28 | 28 | ?><img src="<?php echo esc_attr( $img ) ?>" alt="" /> |
29 | 29 | <?php |
30 | 30 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | <?php |
38 | 38 | } |
39 | 39 | |
40 | -if ( isset($include_extra_container) ) { ?> |
|
40 | +if ( isset( $include_extra_container ) ) { ?> |
|
41 | 41 | </div> |
42 | 42 | <?php |
43 | 43 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | </div> |
6 | 6 | </div> |
7 | 7 | <?php |
8 | - return; |
|
8 | + return; |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | global $frm_vars; |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | } else { |
39 | 39 | do_action( 'frm_show_other_field_type', $field, $form, array( 'action' => $form_action ) ); |
40 | 40 | } |
41 | - do_action('frm_get_field_scripts', $field, $form, $form->id); |
|
41 | + do_action('frm_get_field_scripts', $field, $form, $form->id); |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | |
64 | 64 | // close open collapsible toggle div |
65 | 65 | if ( isset($frm_vars['collapse_div']) && $frm_vars['collapse_div'] ) { |
66 | - echo "</div>\n"; |
|
67 | - unset($frm_vars['collapse_div']); |
|
66 | + echo "</div>\n"; |
|
67 | + unset($frm_vars['collapse_div']); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | echo FrmFormsHelper::replace_shortcodes($values['after_html'], $form); |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | } |
78 | 78 | |
79 | 79 | if ( FrmForm::show_submit( $form ) ) { |
80 | - unset($values['fields']); |
|
81 | - FrmFormsHelper::get_custom_submit($values['submit_html'], $form, $submit, $form_action, $values); |
|
80 | + unset($values['fields']); |
|
81 | + FrmFormsHelper::get_custom_submit($values['submit_html'], $form, $submit, $form_action, $values); |
|
82 | 82 | } |
83 | 83 | ?> |
84 | 84 | </fieldset> |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( empty($values) || ! isset($values['fields']) || empty($values['fields']) ) { ?> |
|
3 | -<div class="frm_forms <?php echo FrmFormsHelper::get_form_style_class($form); ?>" id="frm_form_<?php echo esc_attr( $form->id ) ?>_container"> |
|
2 | +if ( empty( $values ) || ! isset( $values['fields'] ) || empty( $values['fields'] ) ) { ?> |
|
3 | +<div class="frm_forms <?php echo FrmFormsHelper::get_form_style_class( $form ); ?>" id="frm_form_<?php echo esc_attr( $form->id ) ?>_container"> |
|
4 | 4 | <div class="frm_error_style"><strong><?php _e( 'Oops!', 'formidable' ) ?></strong> <?php printf( __( 'You did not add any fields to your form. %1$sGo back%2$s and add some.', 'formidable' ), '<a href="' . esc_url( admin_url( '?page=formidable&frm_action=edit&id=' . $form->id ) ) . '">', '</a>' ) ?> |
5 | 5 | </div> |
6 | 6 | </div> |
@@ -21,11 +21,11 @@ discard block |
||
21 | 21 | <div class="frm_form_fields <?php echo esc_attr( apply_filters( 'frm_form_fields_class', '', $values ) ); ?>"> |
22 | 22 | <fieldset> |
23 | 23 | <?php echo FrmFormsHelper::replace_shortcodes( $values['before_html'], $form, $title, $description ); ?> |
24 | -<input type="hidden" name="frm_action" value="<?php echo esc_attr($form_action) ?>" /> |
|
25 | -<input type="hidden" name="form_id" value="<?php echo esc_attr($form->id) ?>" /> |
|
26 | -<input type="hidden" name="frm_hide_fields_<?php echo esc_attr( $form->id ) ?>" id="frm_hide_fields_<?php echo esc_attr( $form->id ) ?>" value="<?php echo esc_attr($frm_hide_fields) ?>" /> |
|
24 | +<input type="hidden" name="frm_action" value="<?php echo esc_attr( $form_action ) ?>" /> |
|
25 | +<input type="hidden" name="form_id" value="<?php echo esc_attr( $form->id ) ?>" /> |
|
26 | +<input type="hidden" name="frm_hide_fields_<?php echo esc_attr( $form->id ) ?>" id="frm_hide_fields_<?php echo esc_attr( $form->id ) ?>" value="<?php echo esc_attr( $frm_hide_fields ) ?>" /> |
|
27 | 27 | <input type="hidden" name="frm_helpers_<?php echo esc_attr( $form->id ) ?>" id="frm_helpers_<?php echo esc_attr( $form->id ) ?>" value="<?php echo esc_attr( $frm_helpers ) ?>" /> |
28 | -<input type="hidden" name="form_key" value="<?php echo esc_attr($form->form_key) ?>" /> |
|
28 | +<input type="hidden" name="form_key" value="<?php echo esc_attr( $form->form_key ) ?>" /> |
|
29 | 29 | <input type="hidden" name="item_meta[0]" value="" /> |
30 | 30 | <?php wp_nonce_field( 'frm_submit_entry_nonce', 'frm_submit_entry_' . $form->id ); ?> |
31 | 31 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | } else { |
39 | 39 | do_action( 'frm_show_other_field_type', $field, $form, array( 'action' => $form_action ) ); |
40 | 40 | } |
41 | - do_action('frm_get_field_scripts', $field, $form, $form->id); |
|
41 | + do_action( 'frm_get_field_scripts', $field, $form, $form->id ); |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
@@ -46,13 +46,13 @@ discard block |
||
46 | 46 | if ( FrmAppHelper::is_admin() ) { ?> |
47 | 47 | <div class="frm_form_field form-field"> |
48 | 48 | <label class="frm_primary_label"><?php _e( 'Entry Key', 'formidable' ) ?></label> |
49 | -<input type="text" name="item_key" value="<?php echo esc_attr($values['item_key']) ?>" /> |
|
49 | +<input type="text" name="item_key" value="<?php echo esc_attr( $values['item_key'] ) ?>" /> |
|
50 | 50 | </div> |
51 | 51 | <?php } else { ?> |
52 | -<input type="hidden" name="item_key" value="<?php echo esc_attr($values['item_key']) ?>" /> |
|
52 | +<input type="hidden" name="item_key" value="<?php echo esc_attr( $values['item_key'] ) ?>" /> |
|
53 | 53 | <?php } |
54 | 54 | |
55 | -do_action('frm_entry_form', $form, $form_action, $errors); |
|
55 | +do_action( 'frm_entry_form', $form, $form_action, $errors ); |
|
56 | 56 | |
57 | 57 | global $frm_vars; |
58 | 58 | // close open section div |
@@ -62,23 +62,23 @@ discard block |
||
62 | 62 | } |
63 | 63 | |
64 | 64 | // close open collapsible toggle div |
65 | -if ( isset($frm_vars['collapse_div']) && $frm_vars['collapse_div'] ) { |
|
65 | +if ( isset( $frm_vars['collapse_div'] ) && $frm_vars['collapse_div'] ) { |
|
66 | 66 | echo "</div>\n"; |
67 | - unset($frm_vars['collapse_div']); |
|
67 | + unset( $frm_vars['collapse_div'] ); |
|
68 | 68 | } |
69 | 69 | |
70 | -echo FrmFormsHelper::replace_shortcodes($values['after_html'], $form); |
|
70 | +echo FrmFormsHelper::replace_shortcodes( $values['after_html'], $form ); |
|
71 | 71 | |
72 | 72 | |
73 | -if ( has_action('frm_entries_footer_scripts') ) { ?> |
|
73 | +if ( has_action( 'frm_entries_footer_scripts' ) ) { ?> |
|
74 | 74 | <script type="text/javascript"> |
75 | -<?php do_action('frm_entries_footer_scripts', $values['fields'], $form); ?> |
|
75 | +<?php do_action( 'frm_entries_footer_scripts', $values['fields'], $form ); ?> |
|
76 | 76 | </script><?php |
77 | 77 | } |
78 | 78 | |
79 | 79 | if ( FrmForm::show_submit( $form ) ) { |
80 | - unset($values['fields']); |
|
81 | - FrmFormsHelper::get_custom_submit($values['submit_html'], $form, $submit, $form_action, $values); |
|
80 | + unset( $values['fields'] ); |
|
81 | + FrmFormsHelper::get_custom_submit( $values['submit_html'], $form, $submit, $form_action, $values ); |
|
82 | 82 | } |
83 | 83 | ?> |
84 | 84 | </fieldset> |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <div id="form_entries_page" class="wrap"> |
2 | 2 | <div class="frmicon icon32"><br/></div> |
3 | 3 | <h2><?php _e( 'Entries', 'formidable' ); ?> |
4 | - <?php do_action('frm_entry_inside_h2', $form); ?> |
|
4 | + <?php do_action( 'frm_entry_inside_h2', $form ); ?> |
|
5 | 5 | </h2> |
6 | 6 | |
7 | - <?php require(FrmAppHelper::plugin_path() .'/classes/views/shared/errors.php'); ?> |
|
7 | + <?php require( FrmAppHelper::plugin_path() . '/classes/views/shared/errors.php' ); ?> |
|
8 | 8 | |
9 | 9 | <form id="posts-filter" method="get"> |
10 | 10 | <div id="poststuff"> |
11 | 11 | <div id="post-body" class="metabox-holder columns-2"> |
12 | 12 | <div id="post-body-content"> |
13 | - <?php FrmAppController::get_form_nav($form, true, 'hide'); ?> |
|
13 | + <?php FrmAppController::get_form_nav( $form, true, 'hide' ); ?> |
|
14 | 14 | </div> |
15 | 15 | <div id="postbox-container-1" class="postbox-container"> |
16 | 16 | <input type="hidden" name="page" value="formidable-entries" /> |
@@ -1,17 +1,17 @@ |
||
1 | -<div class="frm_forms <?php echo FrmFormsHelper::get_form_style_class($values); ?>" id="frm_form_<?php echo esc_attr( $form->id ) ?>_container"> |
|
1 | +<div class="frm_forms <?php echo FrmFormsHelper::get_form_style_class( $values ); ?>" id="frm_form_<?php echo esc_attr( $form->id ) ?>_container"> |
|
2 | 2 | <?php |
3 | 3 | if ( ! isset( $include_form_tag ) || $include_form_tag ) { |
4 | 4 | ?> |
5 | -<form enctype="<?php echo esc_attr( apply_filters( 'frm_form_enctype', 'multipart/form-data', $form ) ) ?>" method="post" class="frm-show-form <?php do_action('frm_form_classes', $form) ?>" id="form_<?php echo esc_attr( $form->form_key ) ?>" <?php echo $frm_settings->use_html ? '' : 'action=""'; ?>> |
|
5 | +<form enctype="<?php echo esc_attr( apply_filters( 'frm_form_enctype', 'multipart/form-data', $form ) ) ?>" method="post" class="frm-show-form <?php do_action( 'frm_form_classes', $form ) ?>" id="form_<?php echo esc_attr( $form->form_key ) ?>" <?php echo $frm_settings->use_html ? '' : 'action=""'; ?>> |
|
6 | 6 | <?php |
7 | 7 | } else { ?> |
8 | -<div id="form_<?php echo esc_attr( $form->form_key ) ?>" class="frm-show-form <?php do_action('frm_form_classes', $form) ?>" > |
|
8 | +<div id="form_<?php echo esc_attr( $form->form_key ) ?>" class="frm-show-form <?php do_action( 'frm_form_classes', $form ) ?>" > |
|
9 | 9 | <?php |
10 | 10 | } |
11 | 11 | |
12 | -include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/errors.php'); |
|
12 | +include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php' ); |
|
13 | 13 | $form_action = 'create'; |
14 | -require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/form.php'); |
|
14 | +require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/form.php' ); |
|
15 | 15 | |
16 | 16 | if ( ! isset( $include_form_tag ) || $include_form_tag ) { |
17 | 17 | ?> |
@@ -1,18 +1,18 @@ |
||
1 | 1 | <div class="frmcenter frm_no_entries_form"> |
2 | 2 | <?php |
3 | -if ( $form && isset($form->options['no_save']) && $form->options['no_save'] ) { ?> |
|
3 | +if ( $form && isset( $form->options['no_save'] ) && $form->options['no_save'] ) { ?> |
|
4 | 4 | <h3><?php _e( 'This form is not set to save any entries.', 'formidable' ) ?></h3> |
5 | -<p>If you would like entries in this form to be saved, go to the <a href="<?php echo esc_url(admin_url('admin.php?page=formidable') . '&frm_action=settings&id='. $form->id) ?>">form Settings</a> page and uncheck the "Do not store any entries submitted from this form" box.</p> |
|
5 | +<p>If you would like entries in this form to be saved, go to the <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable' ) . '&frm_action=settings&id=' . $form->id ) ?>">form Settings</a> page and uncheck the "Do not store any entries submitted from this form" box.</p> |
|
6 | 6 | <?php |
7 | 7 | } else if ( $form ) { |
8 | 8 | ?> |
9 | -<div class="frm_no_entries_header"><?php printf(__( 'No Entries for form: %s', 'formidable' ), $form->name); ?></div> |
|
10 | -<p class="frm_no_entries_text"><?php printf( __( 'For instructions on publishing your form see %1$sthis page%2$s <br/> or click "%3$sAdd New%4$s" above to add an entry from here (Requires License)', 'formidable' ), '<a href="https://formidablepro.com/knowledgebase/publish-your-forms/" target="_blank">', '</a>', '<a href="' . esc_url( admin_url('admin.php?page=formidable-entries&frm_action=new&form=' . $form->id ) ) . '">', '</a>' ); ?></p> |
|
9 | +<div class="frm_no_entries_header"><?php printf( __( 'No Entries for form: %s', 'formidable' ), $form->name ); ?></div> |
|
10 | +<p class="frm_no_entries_text"><?php printf( __( 'For instructions on publishing your form see %1$sthis page%2$s <br/> or click "%3$sAdd New%4$s" above to add an entry from here (Requires License)', 'formidable' ), '<a href="https://formidablepro.com/knowledgebase/publish-your-forms/" target="_blank">', '</a>', '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&frm_action=new&form=' . $form->id ) ) . '">', '</a>' ); ?></p> |
|
11 | 11 | <?php |
12 | 12 | } else { |
13 | 13 | ?> |
14 | 14 | <div class="frm_no_entries_header"><?php _e( 'You have not created any forms yet.', 'formidable' ); ?></div> |
15 | -<p class="frm_no_entries_text"><?php printf( __( 'To view entries, you must first %1$sbuild a form%2$s', 'formidable' ), '<a href="'. esc_url( admin_url( 'admin.php?page=formidable&frm_action=new' ) ) . '">', '</a>' ); ?></p> |
|
15 | +<p class="frm_no_entries_text"><?php printf( __( 'To view entries, you must first %1$sbuild a form%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=new' ) ) . '">', '</a>' ); ?></p> |
|
16 | 16 | <?php |
17 | 17 | } ?> |
18 | 18 | </div> |