@@ -143,8 +143,8 @@ |
||
143 | 143 | add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); |
144 | 144 | |
145 | 145 | // Addons Controller |
146 | - add_action('wp_ajax_frm_addon_activate', 'FrmAddon::activate' ); |
|
147 | - add_action('wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' ); |
|
146 | + add_action( 'wp_ajax_frm_addon_activate', 'FrmAddon::activate' ); |
|
147 | + add_action( 'wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' ); |
|
148 | 148 | |
149 | 149 | // Fields Controller |
150 | 150 | add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined('ABSPATH') ) { |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | 3 | die( 'You are not allowed to call this page directly.' ); |
4 | 4 | } |
5 | 5 | |
@@ -9,12 +9,12 @@ discard block |
||
9 | 9 | global $frm_vars; |
10 | 10 | $values = array(); |
11 | 11 | foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) { |
12 | - $values[ $var ] = FrmAppHelper::get_post_param( $var, $default ); |
|
12 | + $values[$var] = FrmAppHelper::get_post_param( $var, $default ); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | $values['fields'] = array(); |
16 | - if ( empty($fields) ) { |
|
17 | - return apply_filters('frm_setup_new_entry', $values); |
|
16 | + if ( empty( $fields ) ) { |
|
17 | + return apply_filters( 'frm_setup_new_entry', $values ); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | foreach ( (array) $fields as $field ) { |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | 'default_value' => $field->default_value, |
27 | 27 | 'name' => $field->name, |
28 | 28 | 'description' => $field->description, |
29 | - 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), |
|
29 | + 'type' => apply_filters( 'frm_field_type', $field->type, $field, $new_value ), |
|
30 | 30 | 'options' => $field->options, |
31 | 31 | 'required' => $field->required, |
32 | 32 | 'field_key' => $field->field_key, |
@@ -35,43 +35,43 @@ discard block |
||
35 | 35 | 'parent_form_id' => isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id, |
36 | 36 | ); |
37 | 37 | |
38 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
38 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true ); |
|
39 | 39 | $opt_defaults['required_indicator'] = ''; |
40 | 40 | $opt_defaults['original_type'] = $field->type; |
41 | 41 | |
42 | 42 | foreach ( $opt_defaults as $opt => $default_opt ) { |
43 | - $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt; |
|
44 | - unset($opt, $default_opt); |
|
43 | + $field_array[$opt] = ( isset( $field->field_options[$opt] ) && $field->field_options[$opt] != '' ) ? $field->field_options[$opt] : $default_opt; |
|
44 | + unset( $opt, $default_opt ); |
|
45 | 45 | } |
46 | 46 | |
47 | - unset($opt_defaults); |
|
47 | + unset( $opt_defaults ); |
|
48 | 48 | |
49 | 49 | if ( $field_array['custom_html'] == '' ) { |
50 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type); |
|
50 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $field->type ); |
|
51 | 51 | } |
52 | 52 | |
53 | - $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field); |
|
53 | + $field_array = apply_filters( 'frm_setup_new_fields_vars', $field_array, $field ); |
|
54 | 54 | $field_array = array_merge( $field->field_options, $field_array ); |
55 | 55 | |
56 | 56 | $values['fields'][] = $field_array; |
57 | 57 | |
58 | - if ( ! $form || ! isset($form->id) ) { |
|
59 | - $form = FrmForm::getOne($field->form_id); |
|
58 | + if ( ! $form || ! isset( $form->id ) ) { |
|
59 | + $form = FrmForm::getOne( $field->form_id ); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | - $form->options = maybe_unserialize($form->options); |
|
64 | - if ( is_array($form->options) ) { |
|
63 | + $form->options = maybe_unserialize( $form->options ); |
|
64 | + if ( is_array( $form->options ) ) { |
|
65 | 65 | foreach ( $form->options as $opt => $value ) { |
66 | - $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value ); |
|
67 | - unset($opt, $value); |
|
66 | + $values[$opt] = FrmAppHelper::get_post_param( $opt, $value ); |
|
67 | + unset( $opt, $value ); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | 71 | $form_defaults = FrmFormsHelper::get_default_opts(); |
72 | 72 | |
73 | 73 | $frm_settings = FrmAppHelper::get_settings(); |
74 | - $form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' ); |
|
74 | + $form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' ); |
|
75 | 75 | |
76 | 76 | $values = array_merge( $form_defaults, $values ); |
77 | 77 | |
@@ -93,15 +93,15 @@ discard block |
||
93 | 93 | $return_array = FrmField::is_field_with_multiple_values( $field ); |
94 | 94 | |
95 | 95 | // Do any shortcodes in default value and allow customization of default value |
96 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true, $return_array); |
|
96 | + $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true, $return_array ); |
|
97 | 97 | // Calls FrmProFieldsHelper::get_default_value |
98 | 98 | |
99 | 99 | $new_value = $field->default_value; |
100 | 100 | |
101 | - if ( ! $reset && $_POST && isset( $_POST['item_meta'][ $field->id ] ) ) { |
|
101 | + if ( ! $reset && $_POST && isset( $_POST['item_meta'][$field->id] ) ) { |
|
102 | 102 | // If value was posted, get it |
103 | 103 | |
104 | - $new_value = stripslashes_deep( $_POST['item_meta'][ $field->id ] ); |
|
104 | + $new_value = stripslashes_deep( $_POST['item_meta'][$field->id] ); |
|
105 | 105 | |
106 | 106 | } else if ( FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
107 | 107 | // If clear on focus is selected, the value should be blank (unless it was posted, of course) |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | } |
111 | 111 | |
112 | 112 | if ( ! is_array( $new_value ) ) { |
113 | - $new_value = str_replace('"', '"', $new_value); |
|
113 | + $new_value = str_replace( '"', '"', $new_value ); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | return $new_value; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' ); |
121 | 121 | $values['form_id'] = $record->form_id; |
122 | 122 | $values['is_draft'] = $record->is_draft; |
123 | - return apply_filters('frm_setup_edit_entry_vars', $values, $record); |
|
123 | + return apply_filters( 'frm_setup_edit_entry_vars', $values, $record ); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | public static function get_admin_params( $form = null ) { |
@@ -149,22 +149,22 @@ discard block |
||
149 | 149 | } |
150 | 150 | |
151 | 151 | public static function replace_default_message( $message, $atts ) { |
152 | - if ( strpos($message, '[default-message') === false && |
|
153 | - strpos($message, '[default_message') === false && |
|
152 | + if ( strpos( $message, '[default-message' ) === false && |
|
153 | + strpos( $message, '[default_message' ) === false && |
|
154 | 154 | ! empty( $message ) ) { |
155 | 155 | return $message; |
156 | 156 | } |
157 | 157 | |
158 | - if ( empty($message) ) { |
|
158 | + if ( empty( $message ) ) { |
|
159 | 159 | $message = '[default-message]'; |
160 | 160 | } |
161 | 161 | |
162 | - preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER); |
|
162 | + preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER ); |
|
163 | 163 | |
164 | 164 | foreach ( $shortcodes[0] as $short_key => $tag ) { |
165 | - $add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] ); |
|
165 | + $add_atts = shortcode_parse_atts( $shortcodes[2][$short_key] ); |
|
166 | 166 | if ( $add_atts ) { |
167 | - $this_atts = array_merge($atts, $add_atts); |
|
167 | + $this_atts = array_merge( $atts, $add_atts ); |
|
168 | 168 | } else { |
169 | 169 | $this_atts = $atts; |
170 | 170 | } |
@@ -172,31 +172,31 @@ discard block |
||
172 | 172 | $default = FrmEntryFormat::show_entry( $this_atts ); |
173 | 173 | |
174 | 174 | // Add the default message |
175 | - $message = str_replace( $shortcodes[0][ $short_key ], $default, $message ); |
|
175 | + $message = str_replace( $shortcodes[0][$short_key], $default, $message ); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | return $message; |
179 | 179 | } |
180 | 180 | |
181 | 181 | public static function prepare_display_value( $entry, $field, $atts ) { |
182 | - $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false; |
|
182 | + $field_value = isset( $entry->metas[$field->id] ) ? $entry->metas[$field->id] : false; |
|
183 | 183 | if ( FrmAppHelper::pro_is_installed() ) { |
184 | 184 | FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value ); |
185 | 185 | } |
186 | 186 | |
187 | - if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) { |
|
188 | - return self::display_value($field_value, $field, $atts); |
|
187 | + if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) { |
|
188 | + return self::display_value( $field_value, $field, $atts ); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | // this is an embeded form |
192 | 192 | $val = ''; |
193 | 193 | |
194 | - if ( strpos($atts['embedded_field_id'], 'form') === 0 ) { |
|
194 | + if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) { |
|
195 | 195 | //this is a repeating section |
196 | 196 | $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) ); |
197 | 197 | } else { |
198 | 198 | // get all values for this field |
199 | - $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; |
|
199 | + $child_values = isset( $entry->metas[$atts['embedded_field_id']] ) ? $entry->metas[$atts['embedded_field_id']] : false; |
|
200 | 200 | |
201 | 201 | if ( $child_values ) { |
202 | 202 | $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | |
206 | 206 | $field_value = array(); |
207 | 207 | |
208 | - if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
208 | + if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
209 | 209 | return $val; |
210 | 210 | } |
211 | 211 | |
@@ -214,17 +214,17 @@ discard block |
||
214 | 214 | $atts['post_id'] = $child_entry->post_id; |
215 | 215 | |
216 | 216 | // get the value for this field -- check for post values as well |
217 | - $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field); |
|
217 | + $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field ); |
|
218 | 218 | |
219 | 219 | if ( $entry_val ) { |
220 | 220 | // foreach entry get display_value |
221 | - $field_value[] = self::display_value($entry_val, $field, $atts); |
|
221 | + $field_value[] = self::display_value( $entry_val, $field, $atts ); |
|
222 | 222 | } |
223 | 223 | |
224 | - unset($child_entry); |
|
224 | + unset( $child_entry ); |
|
225 | 225 | } |
226 | 226 | |
227 | - $val = implode(', ', (array) $field_value ); |
|
227 | + $val = implode( ', ', (array) $field_value ); |
|
228 | 228 | $val = wp_kses_post( $val ); |
229 | 229 | |
230 | 230 | return $val; |
@@ -244,22 +244,22 @@ discard block |
||
244 | 244 | ); |
245 | 245 | |
246 | 246 | $atts = wp_parse_args( $atts, $defaults ); |
247 | - $atts = apply_filters('frm_display_value_atts', $atts, $field, $value); |
|
247 | + $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value ); |
|
248 | 248 | |
249 | - if ( ! isset($field->field_options['post_field']) ) { |
|
249 | + if ( ! isset( $field->field_options['post_field'] ) ) { |
|
250 | 250 | $field->field_options['post_field'] = ''; |
251 | 251 | } |
252 | 252 | |
253 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
253 | + if ( ! isset( $field->field_options['custom_field'] ) ) { |
|
254 | 254 | $field->field_options['custom_field'] = ''; |
255 | 255 | } |
256 | 256 | |
257 | 257 | if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) { |
258 | 258 | $atts['pre_truncate'] = $atts['truncate']; |
259 | 259 | $atts['truncate'] = true; |
260 | - $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; |
|
260 | + $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0; |
|
261 | 261 | |
262 | - $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); |
|
262 | + $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts ); |
|
263 | 263 | $atts['truncate'] = $atts['pre_truncate']; |
264 | 264 | } |
265 | 265 | |
@@ -267,38 +267,38 @@ discard block |
||
267 | 267 | return $value; |
268 | 268 | } |
269 | 269 | |
270 | - $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts); |
|
270 | + $value = apply_filters( 'frm_display_value_custom', maybe_unserialize( $value ), $field, $atts ); |
|
271 | 271 | |
272 | 272 | $new_value = ''; |
273 | 273 | |
274 | - if ( is_array($value) && $atts['type'] != 'file' ) { |
|
274 | + if ( is_array( $value ) && $atts['type'] != 'file' ) { |
|
275 | 275 | foreach ( $value as $val ) { |
276 | - if ( is_array($val) ) { |
|
276 | + if ( is_array( $val ) ) { |
|
277 | 277 | //TODO: add options for display (li or ,) |
278 | - $new_value .= implode($atts['sep'], $val); |
|
278 | + $new_value .= implode( $atts['sep'], $val ); |
|
279 | 279 | if ( $atts['type'] != 'data' ) { |
280 | 280 | $new_value .= '<br/>'; |
281 | 281 | } |
282 | 282 | } |
283 | - unset($val); |
|
283 | + unset( $val ); |
|
284 | 284 | } |
285 | 285 | } |
286 | 286 | |
287 | - if ( ! empty($new_value) ) { |
|
287 | + if ( ! empty( $new_value ) ) { |
|
288 | 288 | $value = $new_value; |
289 | - } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) { |
|
290 | - $value = implode($atts['sep'], $value); |
|
289 | + } else if ( is_array( $value ) && $atts['type'] != 'file' && ! $atts['return_array'] ) { |
|
290 | + $value = implode( $atts['sep'], $value ); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | if ( $atts['truncate'] && $atts['type'] != 'image' ) { |
294 | - $value = FrmAppHelper::truncate($value, 50); |
|
294 | + $value = FrmAppHelper::truncate( $value, 50 ); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | if ( ! $atts['keepjs'] && ! is_array( $value ) ) { |
298 | 298 | $value = wp_kses_post( $value ); |
299 | 299 | } |
300 | 300 | |
301 | - return apply_filters('frm_display_value', $value, $field, $atts); |
|
301 | + return apply_filters( 'frm_display_value', $value, $field, $atts ); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | public static function set_posted_value( $field, $value, $args ) { |
@@ -306,20 +306,20 @@ discard block |
||
306 | 306 | if ( isset( $args['other'] ) && $args['other'] ) { |
307 | 307 | $value = $args['temp_value']; |
308 | 308 | } |
309 | - if ( empty($args['parent_field_id']) ) { |
|
310 | - $_POST['item_meta'][ $field->id ] = $value; |
|
309 | + if ( empty( $args['parent_field_id'] ) ) { |
|
310 | + $_POST['item_meta'][$field->id] = $value; |
|
311 | 311 | } else { |
312 | - $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; |
|
312 | + $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] = $value; |
|
313 | 313 | } |
314 | 314 | } |
315 | 315 | |
316 | 316 | public static function get_posted_value( $field, &$value, $args ) { |
317 | 317 | $field_id = is_object( $field ) ? $field->id : $field; |
318 | 318 | |
319 | - if ( empty($args['parent_field_id']) ) { |
|
320 | - $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : ''; |
|
319 | + if ( empty( $args['parent_field_id'] ) ) { |
|
320 | + $value = isset( $_POST['item_meta'][$field_id] ) ? $_POST['item_meta'][$field_id] : ''; |
|
321 | 321 | } else { |
322 | - $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : ''; |
|
322 | + $value = isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] ) ? $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] : ''; |
|
323 | 323 | } |
324 | 324 | } |
325 | 325 | |
@@ -342,12 +342,12 @@ discard block |
||
342 | 342 | self::set_other_repeating_vals( $field, $value, $args ); |
343 | 343 | |
344 | 344 | // Check if there are any posted "Other" values |
345 | - if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) { |
|
345 | + if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][$field->id] ) ) { |
|
346 | 346 | |
347 | 347 | // Save original value |
348 | 348 | $args['temp_value'] = $value; |
349 | 349 | $args['other'] = true; |
350 | - $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] ); |
|
350 | + $other_vals = stripslashes_deep( $_POST['item_meta']['other'][$field->id] ); |
|
351 | 351 | |
352 | 352 | // Set the validation value now |
353 | 353 | self::set_other_validation_val( $value, $other_vals, $field, $args ); |
@@ -369,12 +369,12 @@ discard block |
||
369 | 369 | } |
370 | 370 | |
371 | 371 | // Check if there are any other posted "other" values for this field |
372 | - if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) { |
|
372 | + if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ) ) { |
|
373 | 373 | // Save original value |
374 | 374 | $args['temp_value'] = $value; |
375 | 375 | $args['other'] = true; |
376 | 376 | |
377 | - $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ]; |
|
377 | + $other_vals = $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id]; |
|
378 | 378 | |
379 | 379 | // Set the validation value now |
380 | 380 | self::set_other_validation_val( $value, $other_vals, $field, $args ); |
@@ -406,27 +406,27 @@ discard block |
||
406 | 406 | } |
407 | 407 | } else { |
408 | 408 | // Radio and dropdowns |
409 | - $other_key = array_filter( array_keys($field->options), 'is_string'); |
|
409 | + $other_key = array_filter( array_keys( $field->options ), 'is_string' ); |
|
410 | 410 | $other_key = reset( $other_key ); |
411 | 411 | |
412 | 412 | // Multi-select dropdown |
413 | 413 | if ( is_array( $value ) ) { |
414 | - $o_key = array_search( $field->options[ $other_key ], $value ); |
|
414 | + $o_key = array_search( $field->options[$other_key], $value ); |
|
415 | 415 | |
416 | 416 | if ( $o_key !== false ) { |
417 | 417 | // Modify the original value so other key will be preserved |
418 | - $value[ $other_key ] = $value[ $o_key ]; |
|
418 | + $value[$other_key] = $value[$o_key]; |
|
419 | 419 | |
420 | 420 | // By default, the array keys will be numeric for multi-select dropdowns |
421 | 421 | // If going backwards and forwards between pages, the array key will match the other key |
422 | 422 | if ( $o_key != $other_key ) { |
423 | - unset( $value[ $o_key ] ); |
|
423 | + unset( $value[$o_key] ); |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | $args['temp_value'] = $value; |
427 | - $value[ $other_key ] = reset( $other_vals ); |
|
427 | + $value[$other_key] = reset( $other_vals ); |
|
428 | 428 | } |
429 | - } else if ( $field->options[ $other_key ] == $value ) { |
|
429 | + } else if ( $field->options[$other_key] == $value ) { |
|
430 | 430 | $value = $other_vals; |
431 | 431 | } |
432 | 432 | } |
@@ -445,9 +445,9 @@ discard block |
||
445 | 445 | $content .= "\n\n"; |
446 | 446 | } |
447 | 447 | |
448 | - if ( is_array($val) ) { |
|
448 | + if ( is_array( $val ) ) { |
|
449 | 449 | $val = FrmAppHelper::array_flatten( $val ); |
450 | - $val = implode(',', $val); |
|
450 | + $val = implode( ',', $val ); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | $content .= $val; |
@@ -492,6 +492,6 @@ discard block |
||
492 | 492 | } |
493 | 493 | |
494 | 494 | public static function entries_dropdown() { |
495 | - _deprecated_function( __FUNCTION__, '1.07.09'); |
|
495 | + _deprecated_function( __FUNCTION__, '1.07.09' ); |
|
496 | 496 | } |
497 | 497 | } |
@@ -25,15 +25,15 @@ discard block |
||
25 | 25 | |
26 | 26 | $s_query = array( 'it.form_id' => $form_id ); |
27 | 27 | |
28 | - $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : ''; |
|
28 | + $s = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : ''; |
|
29 | 29 | |
30 | 30 | if ( $s != '' && FrmAppHelper::pro_is_installed() ) { |
31 | 31 | $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : ''; |
32 | - $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid); |
|
32 | + $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid ); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby; |
36 | - if ( strpos($orderby, 'meta') !== false ) { |
|
36 | + if ( strpos( $orderby, 'meta' ) !== false ) { |
|
37 | 37 | $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) ); |
38 | 38 | $orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : ''; |
39 | 39 | } |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | $page = $this->get_pagenum(); |
45 | 45 | $start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page ); |
46 | 46 | |
47 | - $this->items = FrmEntry::getAll($s_query, $order, ' LIMIT '. $start .','. $per_page, true, false); |
|
48 | - $total_items = FrmEntry::getRecordCount($s_query); |
|
47 | + $this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, false ); |
|
48 | + $total_items = FrmEntry::getRecordCount( $s_query ); |
|
49 | 49 | |
50 | 50 | $this->set_pagination_args( array( |
51 | 51 | 'total_items' => $total_items, |
@@ -55,18 +55,18 @@ discard block |
||
55 | 55 | |
56 | 56 | public function no_items() { |
57 | 57 | $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; |
58 | - if ( ! empty($s) ) { |
|
58 | + if ( ! empty( $s ) ) { |
|
59 | 59 | _e( 'No Entries Found', 'formidable' ); |
60 | 60 | return; |
61 | 61 | } |
62 | 62 | |
63 | 63 | $form_id = $form = $this->params['form']; |
64 | 64 | if ( $form_id ) { |
65 | - $form = FrmForm::getOne($form_id); |
|
65 | + $form = FrmForm::getOne( $form_id ); |
|
66 | 66 | } |
67 | 67 | $colspan = $this->get_column_count(); |
68 | 68 | |
69 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/no_entries.php'); |
|
69 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php' ); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | public function search_box( $text, $input_id ) { |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | public function single_row( $item, $style = '' ) { |
100 | 100 | // Set up the hover actions for this user |
101 | 101 | $actions = array(); |
102 | - $view_link = '?page=formidable-entries&frm_action=show&id='. $item->id; |
|
102 | + $view_link = '?page=formidable-entries&frm_action=show&id=' . $item->id; |
|
103 | 103 | |
104 | 104 | $this->get_actions( $actions, $item, $view_link ); |
105 | 105 | |
@@ -110,11 +110,11 @@ discard block |
||
110 | 110 | |
111 | 111 | $r = "<tr id='item-action-{$item->id}'$style>"; |
112 | 112 | |
113 | - list( $columns, $hidden, , $primary ) = $this->get_column_info(); |
|
113 | + list( $columns, $hidden,, $primary ) = $this->get_column_info(); |
|
114 | 114 | $action_col = false; |
115 | 115 | |
116 | 116 | foreach ( $columns as $column_name => $column_display_name ) { |
117 | - $class = $column_name .' column-'. $column_name; |
|
117 | + $class = $column_name . ' column-' . $column_name; |
|
118 | 118 | |
119 | 119 | if ( $column_name === $primary ) { |
120 | 120 | $class .= ' column-primary'; |
@@ -127,10 +127,10 @@ discard block |
||
127 | 127 | } |
128 | 128 | |
129 | 129 | $attributes = 'class="' . esc_attr( $class ) . '"'; |
130 | - unset($class); |
|
131 | - $attributes .= ' data-colname="' . $column_display_name . '"'; |
|
130 | + unset( $class ); |
|
131 | + $attributes .= ' data-colname="' . $column_display_name . '"'; |
|
132 | 132 | |
133 | - $col_name = preg_replace('/^('. $this->params['form'] .'_)/', '', $column_name); |
|
133 | + $col_name = preg_replace( '/^(' . $this->params['form'] . '_)/', '', $column_name ); |
|
134 | 134 | $this->column_name = $col_name; |
135 | 135 | |
136 | 136 | switch ( $col_name ) { |
@@ -144,24 +144,24 @@ discard block |
||
144 | 144 | break; |
145 | 145 | case 'name': |
146 | 146 | case 'description': |
147 | - $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100); |
|
147 | + $val = FrmAppHelper::truncate( strip_tags( $item->{$col_name}), 100 ); |
|
148 | 148 | break; |
149 | 149 | case 'created_at': |
150 | 150 | case 'updated_at': |
151 | - $date = FrmAppHelper::get_formatted_time($item->{$col_name}); |
|
151 | + $date = FrmAppHelper::get_formatted_time( $item->{$col_name}); |
|
152 | 152 | $val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>'; |
153 | 153 | break; |
154 | 154 | case 'is_draft': |
155 | - $val = empty($item->is_draft) ? __( 'No') : __( 'Yes'); |
|
155 | + $val = empty( $item->is_draft ) ? __( 'No' ) : __( 'Yes' ); |
|
156 | 156 | break; |
157 | 157 | case 'form_id': |
158 | - $val = FrmFormsHelper::edit_form_link($item->form_id); |
|
158 | + $val = FrmFormsHelper::edit_form_link( $item->form_id ); |
|
159 | 159 | break; |
160 | 160 | case 'post_id': |
161 | - $val = FrmAppHelper::post_edit_link($item->post_id); |
|
161 | + $val = FrmAppHelper::post_edit_link( $item->post_id ); |
|
162 | 162 | break; |
163 | 163 | case 'user_id': |
164 | - $user = get_userdata($item->user_id); |
|
164 | + $user = get_userdata( $item->user_id ); |
|
165 | 165 | $val = $user->user_login; |
166 | 166 | break; |
167 | 167 | default: |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | if ( isset( $val ) ) { |
176 | 176 | $r .= "<td $attributes>"; |
177 | 177 | if ( $column_name == $action_col ) { |
178 | - $edit_link = '?page=formidable-entries&frm_action=edit&id='. $item->id; |
|
178 | + $edit_link = '?page=formidable-entries&frm_action=edit&id=' . $item->id; |
|
179 | 179 | $r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> '; |
180 | 180 | $r .= $action_links; |
181 | 181 | } else { |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | } |
184 | 184 | $r .= '</td>'; |
185 | 185 | } |
186 | - unset($val); |
|
186 | + unset( $val ); |
|
187 | 187 | } |
188 | 188 | $r .= '</tr>'; |
189 | 189 | |
@@ -194,14 +194,14 @@ discard block |
||
194 | 194 | * @param string $view_link |
195 | 195 | */ |
196 | 196 | private function get_actions( &$actions, $item, $view_link ) { |
197 | - $actions['view'] = '<a href="' . esc_url( $view_link ) . '">'. __( 'View', 'formidable' ) .'</a>'; |
|
197 | + $actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>'; |
|
198 | 198 | |
199 | - if ( current_user_can('frm_delete_entries') ) { |
|
200 | - $delete_link = '?page=formidable-entries&frm_action=destroy&id='. $item->id .'&form='. $this->params['form']; |
|
199 | + if ( current_user_can( 'frm_delete_entries' ) ) { |
|
200 | + $delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form']; |
|
201 | 201 | $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>'; |
202 | 202 | } |
203 | 203 | |
204 | - $actions = apply_filters('frm_row_actions', $actions, $item); |
|
204 | + $actions = apply_filters( 'frm_row_actions', $actions, $item ); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | private function get_column_value( $item, &$val ) { |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | 'swanky-purse' => 'Swanky Purse', |
30 | 30 | ); |
31 | 31 | |
32 | - $themes = apply_filters('frm_jquery_themes', $themes); |
|
32 | + $themes = apply_filters( 'frm_jquery_themes', $themes ); |
|
33 | 33 | return $themes; |
34 | 34 | } |
35 | 35 | |
@@ -40,15 +40,15 @@ discard block |
||
40 | 40 | |
41 | 41 | if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) { |
42 | 42 | $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css'; |
43 | - } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) { |
|
43 | + } else if ( preg_match( '/^http.?:\/\/.*\..*$/', $theme_css ) ) { |
|
44 | 44 | $css_file = $theme_css; |
45 | 45 | } else { |
46 | 46 | $uploads = self::get_upload_base(); |
47 | - $file_path = '/formidable/css/'. $theme_css . '/jquery-ui.css'; |
|
48 | - if ( file_exists($uploads['basedir'] . $file_path) ) { |
|
47 | + $file_path = '/formidable/css/' . $theme_css . '/jquery-ui.css'; |
|
48 | + if ( file_exists( $uploads['basedir'] . $file_path ) ) { |
|
49 | 49 | $css_file = $uploads['baseurl'] . $file_path; |
50 | 50 | } else { |
51 | - $css_file = FrmAppHelper::jquery_ui_base_url() .'/themes/'. $theme_css . '/jquery-ui.min.css'; |
|
51 | + $css_file = FrmAppHelper::jquery_ui_base_url() . '/themes/' . $theme_css . '/jquery-ui.min.css'; |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $form = self::get_form_for_page(); |
60 | 60 | $theme_css = FrmStylesController::get_style_val( 'theme_css', $form ); |
61 | 61 | if ( $theme_css != -1 ) { |
62 | - wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version()); |
|
62 | + wp_enqueue_style( 'jquery-theme', self::jquery_css_url( $theme_css ), array(), FrmAppHelper::plugin_version() ); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | |
80 | 80 | public static function get_upload_base() { |
81 | 81 | $uploads = wp_upload_dir(); |
82 | - if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) { |
|
83 | - $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']); |
|
82 | + if ( is_ssl() && ! preg_match( '/^https:\/\/.*\..*$/', $uploads['baseurl'] ) ) { |
|
83 | + $uploads['baseurl'] = str_replace( 'http://', 'https://', $uploads['baseurl'] ); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | return $uploads; |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | <h2 class="nav-tab-wrapper"> |
92 | 92 | <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles' ) ) ?>" class="nav-tab <?php echo ( '' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Edit Styles', 'formidable' ) ?></a> |
93 | 93 | <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=manage' ) ) ?>" class="nav-tab <?php echo ( 'manage' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Manage Form Styles', 'formidable' ) ?></a> |
94 | - <a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a> |
|
94 | + <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a> |
|
95 | 95 | </h2> |
96 | 96 | <?php |
97 | 97 | } |
@@ -130,15 +130,15 @@ discard block |
||
130 | 130 | * @return The class for this icon |
131 | 131 | */ |
132 | 132 | public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) { |
133 | - if ( 'arrow' == $type && is_numeric($key) ) { |
|
133 | + if ( 'arrow' == $type && is_numeric( $key ) ) { |
|
134 | 134 | //frm_arrowup6_icon |
135 | 135 | $arrow = array( '-' => 'down', '+' => 'up' ); |
136 | - $class = 'frm_arrow' . $arrow[ $icon ]; |
|
136 | + $class = 'frm_arrow' . $arrow[$icon]; |
|
137 | 137 | } else { |
138 | 138 | //frm_minus1_icon |
139 | - $key = str_replace('p', '', $key); |
|
139 | + $key = str_replace( 'p', '', $key ); |
|
140 | 140 | $plus = array( '-' => 'minus', '+' => 'plus' ); |
141 | - $class = 'frm_' . $plus[ $icon ]; |
|
141 | + $class = 'frm_' . $plus[$icon]; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | if ( $key ) { |
@@ -156,18 +156,18 @@ discard block |
||
156 | 156 | |
157 | 157 | $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon'; |
158 | 158 | ?> |
159 | - <select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js"> |
|
159 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( $name ) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js"> |
|
160 | 160 | <?php foreach ( $icons as $key => $icon ) { ?> |
161 | - <option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[ $name ], $key ) ?>> |
|
162 | - <?php echo ''. $icon['+'] .'; '. $icon['-'] .';'; ?> |
|
161 | + <option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[$name], $key ) ?>> |
|
162 | + <?php echo '' . $icon['+'] . '; ' . $icon['-'] . ';'; ?> |
|
163 | 163 | </option> |
164 | 164 | <?php } ?> |
165 | 165 | </select> |
166 | 166 | |
167 | 167 | <div class="btn-group hide-if-no-js" id="frm_<?php echo esc_attr( $name ) ?>_select"> |
168 | 168 | <button class="multiselect dropdown-toggle btn btn-default" data-toggle="dropdown" type="button"> |
169 | - <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '+', $type ) ) ?>"></i> |
|
170 | - <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '-', $type ) ) ?>"></i> |
|
169 | + <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '+', $type ) ) ?>"></i> |
|
170 | + <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '-', $type ) ) ?>"></i> |
|
171 | 171 | <b class="caret"></b> |
172 | 172 | </button> |
173 | 173 | <ul class="multiselect-container frm-dropdown-menu"> |
@@ -190,19 +190,19 @@ discard block |
||
190 | 190 | } |
191 | 191 | |
192 | 192 | public static function hex2rgb( $hex ) { |
193 | - $hex = str_replace('#', '', $hex); |
|
193 | + $hex = str_replace( '#', '', $hex ); |
|
194 | 194 | |
195 | - if ( strlen($hex) == 3 ) { |
|
196 | - $r = hexdec( substr($hex,0,1).substr($hex,0,1) ); |
|
197 | - $g = hexdec( substr($hex,1,1).substr($hex,1,1) ); |
|
198 | - $b = hexdec( substr($hex,2,1).substr($hex,2,1) ); |
|
195 | + if ( strlen( $hex ) == 3 ) { |
|
196 | + $r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) ); |
|
197 | + $g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) ); |
|
198 | + $b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) ); |
|
199 | 199 | } else { |
200 | - $r = hexdec( substr($hex,0,2) ); |
|
201 | - $g = hexdec( substr($hex,2,2) ); |
|
202 | - $b = hexdec( substr($hex,4,2) ); |
|
200 | + $r = hexdec( substr( $hex, 0, 2 ) ); |
|
201 | + $g = hexdec( substr( $hex, 2, 2 ) ); |
|
202 | + $b = hexdec( substr( $hex, 4, 2 ) ); |
|
203 | 203 | } |
204 | 204 | $rgb = array( $r, $g, $b ); |
205 | - return implode(',', $rgb); // returns the rgb values separated by commas |
|
205 | + return implode( ',', $rgb ); // returns the rgb values separated by commas |
|
206 | 206 | //return $rgb; // returns an array with the rgb values |
207 | 207 | } |
208 | 208 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined('ABSPATH') ) { |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | 3 | die( 'You are not allowed to call this page directly.' ); |
4 | 4 | } |
5 | 5 | |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | echo "\n" . $padding; |
12 | 12 | $tag = ( is_numeric( $ok ) ? 'key:' : '' ) . $ok; |
13 | 13 | echo '<' . $tag . '>'; |
14 | - self::get_xml_values( $ov, $padding .' ' ); |
|
14 | + self::get_xml_values( $ov, $padding . ' ' ); |
|
15 | 15 | if ( is_array( $ov ) ) { |
16 | 16 | echo "\n" . $padding; |
17 | 17 | } |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | 'terms' => array(), |
37 | 37 | ); |
38 | 38 | |
39 | - unset($defaults); |
|
39 | + unset( $defaults ); |
|
40 | 40 | |
41 | 41 | if ( ! defined( 'WP_IMPORTING' ) ) { |
42 | - define('WP_IMPORTING', true); |
|
42 | + define( 'WP_IMPORTING', true ); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | if ( ! class_exists( 'DOMDocument' ) ) { |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() ); |
53 | 53 | } |
54 | 54 | |
55 | - if ( ! function_exists('simplexml_import_dom') ) { |
|
55 | + if ( ! function_exists( 'simplexml_import_dom' ) ) { |
|
56 | 56 | return new WP_Error( 'SimpleXML_parse_error', __( 'Your server is missing the simplexml_import_dom function', 'formidable' ), libxml_get_errors() ); |
57 | 57 | } |
58 | 58 | |
@@ -67,21 +67,21 @@ discard block |
||
67 | 67 | // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order |
68 | 68 | foreach ( array( 'term', 'form', 'view' ) as $item_type ) { |
69 | 69 | // grab cats, tags, and terms, or forms or posts |
70 | - if ( isset($xml->{$item_type} ) ) { |
|
70 | + if ( isset( $xml->{$item_type} ) ) { |
|
71 | 71 | $function_name = 'import_xml_' . $item_type . 's'; |
72 | 72 | $imported = self::$function_name( $xml->{$item_type}, $imported ); |
73 | 73 | unset( $function_name, $xml->{$item_type} ); |
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | - $return = apply_filters('frm_importing_xml', $imported, $xml ); |
|
77 | + $return = apply_filters( 'frm_importing_xml', $imported, $xml ); |
|
78 | 78 | |
79 | 79 | return $return; |
80 | 80 | } |
81 | 81 | |
82 | 82 | public static function import_xml_terms( $terms, $imported ) { |
83 | 83 | foreach ( $terms as $t ) { |
84 | - if ( term_exists((string) $t->term_slug, (string) $t->term_taxonomy) ) { |
|
84 | + if ( term_exists( (string) $t->term_slug, (string) $t->term_taxonomy ) ) { |
|
85 | 85 | continue; |
86 | 86 | } |
87 | 87 | |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | 'description' => (string) $t->term_description, |
93 | 93 | 'parent' => empty( $parent ) ? 0 : $parent, |
94 | 94 | 'slug' => (string) $t->term_slug, |
95 | - )); |
|
95 | + ) ); |
|
96 | 96 | |
97 | 97 | if ( $term && is_array( $term ) ) { |
98 | - $imported['imported']['terms']++; |
|
99 | - $imported['terms'][ (int) $t->term_id ] = $term['term_id']; |
|
98 | + $imported['imported']['terms'] ++; |
|
99 | + $imported['terms'][(int) $t->term_id] = $term['term_id']; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | unset( $term, $t ); |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | 'default_template' => (int) $item->default_template, |
140 | 140 | 'editable' => (int) $item->editable, |
141 | 141 | 'status' => (string) $item->status, |
142 | - 'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0, |
|
143 | - 'created_at' => date('Y-m-d H:i:s', strtotime((string) $item->created_at)), |
|
142 | + 'parent_form_id' => isset( $item->parent_form_id ) ? (int) $item->parent_form_id : 0, |
|
143 | + 'created_at' => date( 'Y-m-d H:i:s', strtotime( (string) $item->created_at ) ), |
|
144 | 144 | ); |
145 | 145 | |
146 | - $form['options'] = FrmAppHelper::maybe_json_decode($form['options']); |
|
146 | + $form['options'] = FrmAppHelper::maybe_json_decode( $form['options'] ); |
|
147 | 147 | |
148 | 148 | // if template, allow to edit if form keys match, otherwise, creation date must also match |
149 | 149 | $edit_query = array( 'form_key' => $form['form_key'], 'is_template' => $form['is_template'] ); |
@@ -151,35 +151,35 @@ discard block |
||
151 | 151 | $edit_query['created_at'] = $form['created_at']; |
152 | 152 | } |
153 | 153 | |
154 | - $edit_query = apply_filters('frm_match_xml_form', $edit_query, $form); |
|
154 | + $edit_query = apply_filters( 'frm_match_xml_form', $edit_query, $form ); |
|
155 | 155 | |
156 | - $this_form = FrmForm::getAll($edit_query, '', 1); |
|
157 | - unset($edit_query); |
|
156 | + $this_form = FrmForm::getAll( $edit_query, '', 1 ); |
|
157 | + unset( $edit_query ); |
|
158 | 158 | |
159 | 159 | if ( ! empty( $this_form ) ) { |
160 | 160 | $old_id = $form_id = $this_form->id; |
161 | - FrmForm::update($form_id, $form ); |
|
162 | - $imported['updated']['forms']++; |
|
161 | + FrmForm::update( $form_id, $form ); |
|
162 | + $imported['updated']['forms'] ++; |
|
163 | 163 | // Keep track of whether this specific form was updated or not |
164 | - $imported['form_status'][ $form_id ] = 'updated'; |
|
164 | + $imported['form_status'][$form_id] = 'updated'; |
|
165 | 165 | |
166 | 166 | $form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' ); |
167 | 167 | $old_fields = array(); |
168 | 168 | foreach ( $form_fields as $f ) { |
169 | - $old_fields[ $f->id ] = $f; |
|
170 | - $old_fields[ $f->field_key ] = $f->id; |
|
171 | - unset($f); |
|
169 | + $old_fields[$f->id] = $f; |
|
170 | + $old_fields[$f->field_key] = $f->id; |
|
171 | + unset( $f ); |
|
172 | 172 | } |
173 | 173 | $form_fields = $old_fields; |
174 | - unset($old_fields); |
|
174 | + unset( $old_fields ); |
|
175 | 175 | } else { |
176 | 176 | $old_id = false; |
177 | 177 | //form does not exist, so create it |
178 | 178 | $form_id = FrmForm::create( $form ); |
179 | 179 | if ( $form_id ) { |
180 | - $imported['imported']['forms']++; |
|
180 | + $imported['imported']['forms'] ++; |
|
181 | 181 | // Keep track of whether this specific form was updated or not |
182 | - $imported['form_status'][ $form_id ] = 'imported'; |
|
182 | + $imported['form_status'][$form_id] = 'imported'; |
|
183 | 183 | self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms ); |
184 | 184 | } |
185 | 185 | } |
@@ -189,23 +189,23 @@ discard block |
||
189 | 189 | // Delete any fields attached to this form that were not included in the template |
190 | 190 | if ( isset( $form_fields ) && ! empty( $form_fields ) ) { |
191 | 191 | foreach ( $form_fields as $field ) { |
192 | - if ( is_object($field) ) { |
|
193 | - FrmField::destroy($field->id); |
|
192 | + if ( is_object( $field ) ) { |
|
193 | + FrmField::destroy( $field->id ); |
|
194 | 194 | } |
195 | - unset($field); |
|
195 | + unset( $field ); |
|
196 | 196 | } |
197 | - unset($form_fields); |
|
197 | + unset( $form_fields ); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | // Update field ids/keys to new ones |
201 | 201 | do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) ); |
202 | 202 | |
203 | - $imported['forms'][ (int) $item->id ] = $form_id; |
|
203 | + $imported['forms'][(int) $item->id] = $form_id; |
|
204 | 204 | |
205 | 205 | // Send pre 2.0 form options through function that creates actions |
206 | 206 | self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true ); |
207 | 207 | |
208 | - unset($form, $item); |
|
208 | + unset( $form, $item ); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms ); |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | $regular_forms = array(); |
225 | 225 | |
226 | 226 | foreach ( $forms as $form ) { |
227 | - $parent_form_id = isset( $form->parent_form_id) ? (int) $form->parent_form_id : 0; |
|
227 | + $parent_form_id = isset( $form->parent_form_id ) ? (int) $form->parent_form_id : 0; |
|
228 | 228 | |
229 | 229 | if ( $parent_form_id ) { |
230 | 230 | $child_forms[] = $form; |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | */ |
247 | 247 | private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) { |
248 | 248 | if ( $parent_form_id ) { |
249 | - $child_forms[ $form_id ] = $parent_form_id; |
|
249 | + $child_forms[$form_id] = $parent_form_id; |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) { |
262 | 262 | foreach ( $child_forms as $child_form_id => $old_parent_form_id ) { |
263 | 263 | |
264 | - if ( isset( $imported_forms[ $old_parent_form_id ] ) && $imported_forms[ $old_parent_form_id ] != $old_parent_form_id ) { |
|
264 | + if ( isset( $imported_forms[$old_parent_form_id] ) && $imported_forms[$old_parent_form_id] != $old_parent_form_id ) { |
|
265 | 265 | // Update all children with this old parent_form_id |
266 | - $new_parent_form_id = (int) $imported_forms[ $old_parent_form_id ]; |
|
266 | + $new_parent_form_id = (int) $imported_forms[$old_parent_form_id]; |
|
267 | 267 | |
268 | 268 | FrmForm::update( $child_form_id, array( 'parent_form_id' => $new_parent_form_id ) ); |
269 | 269 | } |
@@ -284,51 +284,51 @@ discard block |
||
284 | 284 | 'name' => (string) $field->name, |
285 | 285 | 'description' => (string) $field->description, |
286 | 286 | 'type' => (string) $field->type, |
287 | - 'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value), |
|
287 | + 'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value ), |
|
288 | 288 | 'field_order' => (int) $field->field_order, |
289 | 289 | 'form_id' => (int) $form_id, |
290 | 290 | 'required' => (int) $field->required, |
291 | - 'options' => FrmAppHelper::maybe_json_decode( (string) $field->options), |
|
291 | + 'options' => FrmAppHelper::maybe_json_decode( (string) $field->options ), |
|
292 | 292 | 'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ), |
293 | 293 | ); |
294 | 294 | |
295 | - if ( is_array($f['default_value']) && in_array($f['type'], array( |
|
295 | + if ( is_array( $f['default_value'] ) && in_array( $f['type'], array( |
|
296 | 296 | 'text', 'email', 'url', 'textarea', |
297 | - 'number','phone', 'date', 'time', |
|
297 | + 'number', 'phone', 'date', 'time', |
|
298 | 298 | 'hidden', 'password', 'tag', 'image', |
299 | - )) ) { |
|
300 | - if ( count($f['default_value']) === 1 ) { |
|
301 | - $f['default_value'] = '['. reset($f['default_value']) .']'; |
|
299 | + ) ) ) { |
|
300 | + if ( count( $f['default_value'] ) === 1 ) { |
|
301 | + $f['default_value'] = '[' . reset( $f['default_value'] ) . ']'; |
|
302 | 302 | } else { |
303 | - $f['default_value'] = reset($f['default_value']); |
|
303 | + $f['default_value'] = reset( $f['default_value'] ); |
|
304 | 304 | } |
305 | 305 | } |
306 | 306 | |
307 | - $f = apply_filters('frm_duplicated_field', $f); |
|
307 | + $f = apply_filters( 'frm_duplicated_field', $f ); |
|
308 | 308 | |
309 | 309 | self::maybe_update_form_select( $f, $imported ); |
310 | 310 | |
311 | - if ( ! empty($this_form) ) { |
|
311 | + if ( ! empty( $this_form ) ) { |
|
312 | 312 | // check for field to edit by field id |
313 | - if ( isset( $form_fields[ $f['id'] ] ) ) { |
|
313 | + if ( isset( $form_fields[$f['id']] ) ) { |
|
314 | 314 | FrmField::update( $f['id'], $f ); |
315 | - $imported['updated']['fields']++; |
|
315 | + $imported['updated']['fields'] ++; |
|
316 | 316 | |
317 | - unset( $form_fields[ $f['id'] ] ); |
|
317 | + unset( $form_fields[$f['id']] ); |
|
318 | 318 | |
319 | 319 | //unset old field key |
320 | - if ( isset( $form_fields[ $f['field_key'] ] ) ) { |
|
321 | - unset( $form_fields[ $f['field_key'] ] ); |
|
320 | + if ( isset( $form_fields[$f['field_key']] ) ) { |
|
321 | + unset( $form_fields[$f['field_key']] ); |
|
322 | 322 | } |
323 | - } else if ( isset( $form_fields[ $f['field_key'] ] ) ) { |
|
323 | + } else if ( isset( $form_fields[$f['field_key']] ) ) { |
|
324 | 324 | // check for field to edit by field key |
325 | - unset($f['id']); |
|
325 | + unset( $f['id'] ); |
|
326 | 326 | |
327 | - FrmField::update( $form_fields[ $f['field_key'] ], $f ); |
|
328 | - $imported['updated']['fields']++; |
|
327 | + FrmField::update( $form_fields[$f['field_key']], $f ); |
|
328 | + $imported['updated']['fields'] ++; |
|
329 | 329 | |
330 | - unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id |
|
331 | - unset( $form_fields[ $f['field_key'] ] ); //unset old field key |
|
330 | + unset( $form_fields[$form_fields[$f['field_key']]] ); //unset old field id |
|
331 | + unset( $form_fields[$f['field_key']] ); //unset old field key |
|
332 | 332 | } else { |
333 | 333 | $new_id = FrmField::create( $f ); |
334 | 334 | if ( $new_id == false ) { |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | } |
337 | 337 | |
338 | 338 | // if no matching field id or key in this form, create the field |
339 | - $imported['imported']['fields']++; |
|
339 | + $imported['imported']['fields'] ++; |
|
340 | 340 | } |
341 | 341 | } else { |
342 | 342 | $new_id = FrmField::create( $f ); |
@@ -344,10 +344,10 @@ discard block |
||
344 | 344 | continue; |
345 | 345 | } |
346 | 346 | |
347 | - $imported['imported']['fields']++; |
|
347 | + $imported['imported']['fields'] ++; |
|
348 | 348 | } |
349 | 349 | |
350 | - unset($field, $new_id); |
|
350 | + unset( $field, $new_id ); |
|
351 | 351 | } |
352 | 352 | } |
353 | 353 | |
@@ -366,8 +366,8 @@ discard block |
||
366 | 366 | if ( $f['type'] == 'form' || ( $f['type'] == 'divider' && FrmField::is_option_true( $f['field_options'], 'repeat' ) ) ) { |
367 | 367 | if ( FrmField::is_option_true( $f['field_options'], 'form_select' ) ) { |
368 | 368 | $form_select = $f['field_options']['form_select']; |
369 | - if ( isset( $imported['forms'][ $form_select ] ) ) { |
|
370 | - $f['field_options']['form_select'] = $imported['forms'][ $form_select ]; |
|
369 | + if ( isset( $imported['forms'][$form_select] ) ) { |
|
370 | + $f['field_options']['form_select'] = $imported['forms'][$form_select]; |
|
371 | 371 | } |
372 | 372 | } |
373 | 373 | } |
@@ -395,8 +395,8 @@ discard block |
||
395 | 395 | 'post_id' => (int) $item->post_id, |
396 | 396 | 'post_parent' => (int) $item->post_parent, |
397 | 397 | 'menu_order' => (int) $item->menu_order, |
398 | - 'post_content' => FrmFieldsHelper::switch_field_ids((string) $item->content), |
|
399 | - 'post_excerpt' => FrmFieldsHelper::switch_field_ids((string) $item->excerpt), |
|
398 | + 'post_content' => FrmFieldsHelper::switch_field_ids( (string) $item->content ), |
|
399 | + 'post_excerpt' => FrmFieldsHelper::switch_field_ids( (string) $item->excerpt ), |
|
400 | 400 | 'is_sticky' => (string) $item->is_sticky, |
401 | 401 | 'comment_status' => (string) $item->comment_status, |
402 | 402 | 'post_date' => (string) $item->post_date, |
@@ -407,9 +407,9 @@ discard block |
||
407 | 407 | ); |
408 | 408 | |
409 | 409 | $old_id = $post['post_id']; |
410 | - self::populate_post($post, $item, $imported); |
|
410 | + self::populate_post( $post, $item, $imported ); |
|
411 | 411 | |
412 | - unset($item); |
|
412 | + unset( $item ); |
|
413 | 413 | |
414 | 414 | $post_id = false; |
415 | 415 | if ( $post['post_type'] == $form_action_type ) { |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | if ( $action_control ) { |
418 | 418 | $post_id = $action_control->maybe_create_action( $post, $imported['form_status'] ); |
419 | 419 | } |
420 | - unset($action_control); |
|
420 | + unset( $action_control ); |
|
421 | 421 | } else if ( $post['post_type'] == 'frm_styles' ) { |
422 | 422 | // Properly encode post content before inserting the post |
423 | 423 | $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] ); |
@@ -430,26 +430,26 @@ discard block |
||
430 | 430 | $post_id = wp_insert_post( $post ); |
431 | 431 | } |
432 | 432 | |
433 | - if ( ! is_numeric($post_id) ) { |
|
433 | + if ( ! is_numeric( $post_id ) ) { |
|
434 | 434 | continue; |
435 | 435 | } |
436 | 436 | |
437 | - self::update_postmeta($post, $post_id); |
|
437 | + self::update_postmeta( $post, $post_id ); |
|
438 | 438 | |
439 | 439 | $this_type = 'posts'; |
440 | - if ( isset( $post_types[ $post['post_type'] ] ) ) { |
|
441 | - $this_type = $post_types[ $post['post_type'] ]; |
|
440 | + if ( isset( $post_types[$post['post_type']] ) ) { |
|
441 | + $this_type = $post_types[$post['post_type']]; |
|
442 | 442 | } |
443 | 443 | |
444 | - if ( isset($post['ID']) && $post_id == $post['ID'] ) { |
|
445 | - $imported['updated'][ $this_type ]++; |
|
444 | + if ( isset( $post['ID'] ) && $post_id == $post['ID'] ) { |
|
445 | + $imported['updated'][$this_type] ++; |
|
446 | 446 | } else { |
447 | - $imported['imported'][ $this_type ]++; |
|
447 | + $imported['imported'][$this_type] ++; |
|
448 | 448 | } |
449 | 449 | |
450 | - unset($post); |
|
450 | + unset( $post ); |
|
451 | 451 | |
452 | - $imported['posts'][ (int) $old_id ] = $post_id; |
|
452 | + $imported['posts'][(int) $old_id] = $post_id; |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | self::maybe_update_stylesheet( $imported ); |
@@ -458,23 +458,23 @@ discard block |
||
458 | 458 | } |
459 | 459 | |
460 | 460 | private static function populate_post( &$post, $item, $imported ) { |
461 | - if ( isset($item->attachment_url) ) { |
|
461 | + if ( isset( $item->attachment_url ) ) { |
|
462 | 462 | $post['attachment_url'] = (string) $item->attachment_url; |
463 | 463 | } |
464 | 464 | |
465 | - if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) { |
|
465 | + if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][(int) $post['menu_order']] ) ) { |
|
466 | 466 | // update to new form id |
467 | - $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ]; |
|
467 | + $post['menu_order'] = $imported['forms'][(int) $post['menu_order']]; |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | foreach ( $item->postmeta as $meta ) { |
471 | - self::populate_postmeta($post, $meta, $imported); |
|
472 | - unset($meta); |
|
471 | + self::populate_postmeta( $post, $meta, $imported ); |
|
472 | + unset( $meta ); |
|
473 | 473 | } |
474 | 474 | |
475 | - self::populate_taxonomies($post, $item); |
|
475 | + self::populate_taxonomies( $post, $item ); |
|
476 | 476 | |
477 | - self::maybe_editing_post($post); |
|
477 | + self::maybe_editing_post( $post ); |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | private static function populate_postmeta( &$post, $meta, $imported ) { |
@@ -486,27 +486,27 @@ discard block |
||
486 | 486 | ); |
487 | 487 | |
488 | 488 | //switch old form and field ids to new ones |
489 | - if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) { |
|
490 | - $m['value'] = $imported['forms'][ (int) $m['value'] ]; |
|
489 | + if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][(int) $m['value']] ) ) { |
|
490 | + $m['value'] = $imported['forms'][(int) $m['value']]; |
|
491 | 491 | } else { |
492 | - $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
492 | + $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] ); |
|
493 | 493 | |
494 | - if ( ! empty($frm_duplicate_ids) ) { |
|
494 | + if ( ! empty( $frm_duplicate_ids ) ) { |
|
495 | 495 | |
496 | 496 | if ( $m['key'] == 'frm_dyncontent' ) { |
497 | - $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']); |
|
497 | + $m['value'] = FrmFieldsHelper::switch_field_ids( $m['value'] ); |
|
498 | 498 | } else if ( $m['key'] == 'frm_options' ) { |
499 | 499 | |
500 | 500 | foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) { |
501 | - if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) { |
|
502 | - $m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ]; |
|
501 | + if ( isset( $m['value'][$setting_name] ) && is_numeric( $m['value'][$setting_name] ) && isset( $frm_duplicate_ids[$m['value'][$setting_name]] ) ) { |
|
502 | + $m['value'][$setting_name] = $frm_duplicate_ids[$m['value'][$setting_name]]; |
|
503 | 503 | } |
504 | 504 | } |
505 | 505 | |
506 | 506 | $check_dup_array = array(); |
507 | 507 | if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) { |
508 | - if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) { |
|
509 | - $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ]; |
|
508 | + if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[$m['value']['order_by']] ) ) { |
|
509 | + $m['value']['order_by'] = $frm_duplicate_ids[$m['value']['order_by']]; |
|
510 | 510 | } else if ( is_array( $m['value']['order_by'] ) ) { |
511 | 511 | $check_dup_array[] = 'order_by'; |
512 | 512 | } |
@@ -517,22 +517,22 @@ discard block |
||
517 | 517 | } |
518 | 518 | |
519 | 519 | foreach ( $check_dup_array as $check_k ) { |
520 | - foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) { |
|
521 | - if ( isset( $frm_duplicate_ids[ $mv ] ) ) { |
|
522 | - $m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ]; |
|
520 | + foreach ( (array) $m['value'][$check_k] as $mk => $mv ) { |
|
521 | + if ( isset( $frm_duplicate_ids[$mv] ) ) { |
|
522 | + $m['value'][$check_k][$mk] = $frm_duplicate_ids[$mv]; |
|
523 | 523 | } |
524 | - unset($mk, $mv); |
|
524 | + unset( $mk, $mv ); |
|
525 | 525 | } |
526 | 526 | } |
527 | 527 | } |
528 | 528 | } |
529 | 529 | } |
530 | 530 | |
531 | - if ( ! is_array($m['value']) ) { |
|
532 | - $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
531 | + if ( ! is_array( $m['value'] ) ) { |
|
532 | + $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] ); |
|
533 | 533 | } |
534 | 534 | |
535 | - $post['postmeta'][ (string) $meta->meta_key ] = $m['value']; |
|
535 | + $post['postmeta'][(string) $meta->meta_key] = $m['value']; |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | /** |
@@ -548,23 +548,23 @@ discard block |
||
548 | 548 | } |
549 | 549 | |
550 | 550 | $taxonomy = (string) $att['domain']; |
551 | - if ( is_taxonomy_hierarchical($taxonomy) ) { |
|
551 | + if ( is_taxonomy_hierarchical( $taxonomy ) ) { |
|
552 | 552 | $name = (string) $att['nicename']; |
553 | - $h_term = get_term_by('slug', $name, $taxonomy); |
|
553 | + $h_term = get_term_by( 'slug', $name, $taxonomy ); |
|
554 | 554 | if ( $h_term ) { |
555 | 555 | $name = $h_term->term_id; |
556 | 556 | } |
557 | - unset($h_term); |
|
557 | + unset( $h_term ); |
|
558 | 558 | } else { |
559 | 559 | $name = (string) $c; |
560 | 560 | } |
561 | 561 | |
562 | - if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) { |
|
563 | - $post['tax_input'][ $taxonomy ] = array(); |
|
562 | + if ( ! isset( $post['tax_input'][$taxonomy] ) ) { |
|
563 | + $post['tax_input'][$taxonomy] = array(); |
|
564 | 564 | } |
565 | 565 | |
566 | - $post['tax_input'][ $taxonomy ][] = $name; |
|
567 | - unset($name); |
|
566 | + $post['tax_input'][$taxonomy][] = $name; |
|
567 | + unset( $name ); |
|
568 | 568 | } |
569 | 569 | } |
570 | 570 | |
@@ -581,29 +581,29 @@ discard block |
||
581 | 581 | |
582 | 582 | if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) { |
583 | 583 | $match_by['include'] = $post['post_id']; |
584 | - unset($match_by['name']); |
|
584 | + unset( $match_by['name'] ); |
|
585 | 585 | } |
586 | 586 | |
587 | - $editing = get_posts($match_by); |
|
587 | + $editing = get_posts( $match_by ); |
|
588 | 588 | |
589 | - if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) { |
|
589 | + if ( ! empty( $editing ) && current( $editing )->post_date == $post['post_date'] ) { |
|
590 | 590 | // set the id of the post to edit |
591 | - $post['ID'] = current($editing)->ID; |
|
591 | + $post['ID'] = current( $editing )->ID; |
|
592 | 592 | } |
593 | 593 | } |
594 | 594 | |
595 | 595 | private static function update_postmeta( &$post, $post_id ) { |
596 | 596 | foreach ( $post['postmeta'] as $k => $v ) { |
597 | 597 | if ( '_edit_last' == $k ) { |
598 | - $v = FrmAppHelper::get_user_id_param($v); |
|
598 | + $v = FrmAppHelper::get_user_id_param( $v ); |
|
599 | 599 | } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) { |
600 | 600 | //change the attachment ID |
601 | - $v = FrmProXMLHelper::get_file_id($v); |
|
601 | + $v = FrmProXMLHelper::get_file_id( $v ); |
|
602 | 602 | } |
603 | 603 | |
604 | - update_post_meta($post_id, $k, $v); |
|
604 | + update_post_meta( $post_id, $k, $v ); |
|
605 | 605 | |
606 | - unset($k, $v); |
|
606 | + unset( $k, $v ); |
|
607 | 607 | } |
608 | 608 | } |
609 | 609 | |
@@ -620,13 +620,13 @@ discard block |
||
620 | 620 | * @param string $message |
621 | 621 | */ |
622 | 622 | public static function parse_message( $result, &$message, &$errors ) { |
623 | - if ( is_wp_error($result) ) { |
|
623 | + if ( is_wp_error( $result ) ) { |
|
624 | 624 | $errors[] = $result->get_error_message(); |
625 | 625 | } else if ( ! $result ) { |
626 | 626 | return; |
627 | 627 | } |
628 | 628 | |
629 | - if ( ! is_array($result) ) { |
|
629 | + if ( ! is_array( $result ) ) { |
|
630 | 630 | $message = is_string( $result ) ? $result : print_r( $result, 1 ); |
631 | 631 | return; |
632 | 632 | } |
@@ -638,20 +638,20 @@ discard block |
||
638 | 638 | |
639 | 639 | $message = '<ul>'; |
640 | 640 | foreach ( $result as $type => $results ) { |
641 | - if ( ! isset( $t_strings[ $type ] ) ) { |
|
641 | + if ( ! isset( $t_strings[$type] ) ) { |
|
642 | 642 | // only print imported and updated |
643 | 643 | continue; |
644 | 644 | } |
645 | 645 | |
646 | 646 | $s_message = array(); |
647 | 647 | foreach ( $results as $k => $m ) { |
648 | - self::item_count_message($m, $k, $s_message); |
|
649 | - unset($k, $m); |
|
648 | + self::item_count_message( $m, $k, $s_message ); |
|
649 | + unset( $k, $m ); |
|
650 | 650 | } |
651 | 651 | |
652 | - if ( ! empty($s_message) ) { |
|
653 | - $message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> '; |
|
654 | - $message .= implode(', ', $s_message); |
|
652 | + if ( ! empty( $s_message ) ) { |
|
653 | + $message .= '<li><strong>' . $t_strings[$type] . ':</strong> '; |
|
654 | + $message .= implode( ', ', $s_message ); |
|
655 | 655 | $message .= '</li>'; |
656 | 656 | } |
657 | 657 | } |
@@ -680,18 +680,18 @@ discard block |
||
680 | 680 | 'actions' => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ), |
681 | 681 | ); |
682 | 682 | |
683 | - $s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type ); |
|
683 | + $s_message[] = isset( $strings[$type] ) ? $strings[$type] : ' ' . $m . ' ' . ucfirst( $type ); |
|
684 | 684 | } |
685 | 685 | |
686 | 686 | public static function cdata( $str ) { |
687 | - $str = maybe_unserialize($str); |
|
688 | - if ( is_array($str) ) { |
|
689 | - $str = json_encode($str); |
|
687 | + $str = maybe_unserialize( $str ); |
|
688 | + if ( is_array( $str ) ) { |
|
689 | + $str = json_encode( $str ); |
|
690 | 690 | } else if ( seems_utf8( $str ) == false ) { |
691 | 691 | $str = utf8_encode( $str ); |
692 | 692 | } |
693 | 693 | |
694 | - if ( is_numeric($str) ) { |
|
694 | + if ( is_numeric( $str ) ) { |
|
695 | 695 | return $str; |
696 | 696 | } |
697 | 697 | |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | * @param string $post_type |
724 | 724 | */ |
725 | 725 | private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
726 | - if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) { |
|
726 | + if ( ! isset( $form_options['create_post'] ) || ! $form_options['create_post'] ) { |
|
727 | 727 | return; |
728 | 728 | } |
729 | 729 | |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | 'menu_order' => $form_id, |
735 | 735 | 'post_status' => 'publish', |
736 | 736 | 'post_content' => array(), |
737 | - 'post_name' => $form_id .'_wppost_1', |
|
737 | + 'post_name' => $form_id . '_wppost_1', |
|
738 | 738 | ); |
739 | 739 | |
740 | 740 | $post_settings = array( |
@@ -744,10 +744,10 @@ discard block |
||
744 | 744 | ); |
745 | 745 | |
746 | 746 | foreach ( $post_settings as $post_setting ) { |
747 | - if ( isset( $form_options[ $post_setting ] ) ) { |
|
748 | - $new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ]; |
|
747 | + if ( isset( $form_options[$post_setting] ) ) { |
|
748 | + $new_action['post_content'][$post_setting] = $form_options[$post_setting]; |
|
749 | 749 | } |
750 | - unset($post_setting); |
|
750 | + unset( $post_setting ); |
|
751 | 751 | } |
752 | 752 | |
753 | 753 | $new_action['event'] = array( 'create', 'update' ); |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | |
762 | 762 | $new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields ); |
763 | 763 | } |
764 | - $new_action['post_content'] = json_encode($new_action['post_content']); |
|
764 | + $new_action['post_content'] = json_encode( $new_action['post_content'] ); |
|
765 | 765 | |
766 | 766 | $exists = get_posts( array( |
767 | 767 | 'name' => $new_action['post_name'], |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | if ( ! $exists ) { |
774 | 774 | // this isn't an email, but we need to use a class that will always be included |
775 | 775 | FrmAppHelper::save_json_post( $new_action ); |
776 | - $imported['imported']['actions']++; |
|
776 | + $imported['imported']['actions'] ++; |
|
777 | 777 | } |
778 | 778 | } |
779 | 779 | |
@@ -805,11 +805,11 @@ discard block |
||
805 | 805 | foreach ( $post_content as $key => $setting ) { |
806 | 806 | if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) { |
807 | 807 | // Replace old IDs with new IDs |
808 | - $post_content[ $key ] = str_replace( $old, $new, $setting ); |
|
808 | + $post_content[$key] = str_replace( $old, $new, $setting ); |
|
809 | 809 | } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) { |
810 | 810 | foreach ( $setting as $k => $val ) { |
811 | 811 | // Replace old IDs with new IDs |
812 | - $post_content[ $key ][ $k ] = str_replace( $old, $new, $val ); |
|
812 | + $post_content[$key][$k] = str_replace( $old, $new, $val ); |
|
813 | 813 | } |
814 | 814 | } |
815 | 815 | unset( $key, $setting ); |
@@ -832,14 +832,14 @@ discard block |
||
832 | 832 | // Migrate autoresponders |
833 | 833 | self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications ); |
834 | 834 | |
835 | - if ( empty( $notifications ) ) { |
|
835 | + if ( empty( $notifications ) ) { |
|
836 | 836 | return; |
837 | 837 | } |
838 | 838 | |
839 | 839 | foreach ( $notifications as $new_notification ) { |
840 | 840 | $new_notification['post_type'] = $post_type; |
841 | 841 | $new_notification['post_excerpt'] = 'email'; |
842 | - $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
|
842 | + $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
|
843 | 843 | $new_notification['menu_order'] = $form_id; |
844 | 844 | $new_notification['post_status'] = 'publish'; |
845 | 845 | |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | // Switch all other field IDs in email |
853 | 853 | $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] ); |
854 | 854 | } |
855 | - $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
855 | + $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
856 | 856 | |
857 | 857 | $exists = get_posts( array( |
858 | 858 | 'name' => $new_notification['post_name'], |
@@ -861,11 +861,11 @@ discard block |
||
861 | 861 | 'numberposts' => 1, |
862 | 862 | ) ); |
863 | 863 | |
864 | - if ( empty($exists) ) { |
|
864 | + if ( empty( $exists ) ) { |
|
865 | 865 | FrmAppHelper::save_json_post( $new_notification ); |
866 | - $imported['imported']['actions']++; |
|
866 | + $imported['imported']['actions'] ++; |
|
867 | 867 | } |
868 | - unset($new_notification); |
|
868 | + unset( $new_notification ); |
|
869 | 869 | } |
870 | 870 | } |
871 | 871 | |
@@ -878,7 +878,7 @@ discard block |
||
878 | 878 | $form_options['notification'] = array( 0 => $form_options['notification'] ); |
879 | 879 | } |
880 | 880 | |
881 | - if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) { |
|
881 | + if ( isset( $form_options['notification'] ) && is_array( $form_options['notification'] ) ) { |
|
882 | 882 | foreach ( $form_options['notification'] as $email_key => $notification ) { |
883 | 883 | |
884 | 884 | $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key ); |
@@ -906,12 +906,12 @@ discard block |
||
906 | 906 | // Format the reply to email and name |
907 | 907 | $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' ); |
908 | 908 | foreach ( $reply_fields as $f => $val ) { |
909 | - if ( isset( $notification[ $f ] ) ) { |
|
910 | - $atts[ $f ] = $notification[ $f ]; |
|
911 | - if ( 'custom' == $notification[ $f ] ) { |
|
912 | - $atts[ $f ] = $notification[ 'cust_' . $f ]; |
|
913 | - } else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) { |
|
914 | - $atts[ $f ] = '[' . $atts[ $f ] . ']'; |
|
909 | + if ( isset( $notification[$f] ) ) { |
|
910 | + $atts[$f] = $notification[$f]; |
|
911 | + if ( 'custom' == $notification[$f] ) { |
|
912 | + $atts[$f] = $notification['cust_' . $f]; |
|
913 | + } else if ( is_numeric( $atts[$f] ) && ! empty( $atts[$f] ) ) { |
|
914 | + $atts[$f] = '[' . $atts[$f] . ']'; |
|
915 | 915 | } |
916 | 916 | } |
917 | 917 | unset( $f, $val ); |
@@ -921,7 +921,7 @@ discard block |
||
921 | 921 | $atts['event'] = array( 'create' ); |
922 | 922 | if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) { |
923 | 923 | $atts['event'][] = 'update'; |
924 | - } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) { |
|
924 | + } else if ( isset( $notification['update_email'] ) && 2 == $notification['update_email'] ) { |
|
925 | 925 | $atts['event'] = array( 'update' ); |
926 | 926 | } |
927 | 927 | } |
@@ -942,18 +942,18 @@ discard block |
||
942 | 942 | foreach ( $atts['email_to'] as $key => $email_field ) { |
943 | 943 | |
944 | 944 | if ( is_numeric( $email_field ) ) { |
945 | - $atts['email_to'][ $key ] = '[' . $email_field . ']'; |
|
945 | + $atts['email_to'][$key] = '[' . $email_field . ']'; |
|
946 | 946 | } |
947 | 947 | |
948 | - if ( strpos( $email_field, '|') ) { |
|
948 | + if ( strpos( $email_field, '|' ) ) { |
|
949 | 949 | $email_opt = explode( '|', $email_field ); |
950 | 950 | if ( isset( $email_opt[0] ) ) { |
951 | - $atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
|
951 | + $atts['email_to'][$key] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
|
952 | 952 | } |
953 | 953 | unset( $email_opt ); |
954 | 954 | } |
955 | 955 | } |
956 | - $atts['email_to'] = implode(', ', $atts['email_to']); |
|
956 | + $atts['email_to'] = implode( ', ', $atts['email_to'] ); |
|
957 | 957 | } |
958 | 958 | |
959 | 959 | private static function setup_new_notification( &$new_notification, $notification, $atts ) { |
@@ -963,18 +963,18 @@ discard block |
||
963 | 963 | 'email_to' => $atts['email_to'], |
964 | 964 | 'event' => $atts['event'], |
965 | 965 | ), |
966 | - 'post_name' => $atts['form_id'] .'_email_'. $atts['email_key'], |
|
966 | + 'post_name' => $atts['form_id'] . '_email_' . $atts['email_key'], |
|
967 | 967 | ); |
968 | 968 | |
969 | 969 | // Add more fields to the new notification |
970 | 970 | $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' ); |
971 | 971 | foreach ( $add_fields as $add_field ) { |
972 | - if ( isset( $notification[ $add_field ] ) ) { |
|
973 | - $new_notification['post_content'][ $add_field ] = $notification[ $add_field ]; |
|
972 | + if ( isset( $notification[$add_field] ) ) { |
|
973 | + $new_notification['post_content'][$add_field] = $notification[$add_field]; |
|
974 | 974 | } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) { |
975 | - $new_notification['post_content'][ $add_field ] = 0; |
|
975 | + $new_notification['post_content'][$add_field] = 0; |
|
976 | 976 | } else { |
977 | - $new_notification['post_content'][ $add_field ] = ''; |
|
977 | + $new_notification['post_content'][$add_field] = ''; |
|
978 | 978 | } |
979 | 979 | unset( $add_field ); |
980 | 980 | } |
@@ -984,7 +984,7 @@ discard block |
||
984 | 984 | |
985 | 985 | // Set from |
986 | 986 | if ( ! empty( $atts['reply_to'] ) || ! empty( $atts['reply_to_name'] ) ) { |
987 | - $new_notification['post_content']['from'] = ( empty($atts['reply_to_name']) ? '[sitename]' : $atts['reply_to_name'] ) .' <'. ( empty($atts['reply_to']) ? '[admin_email]' : $atts['reply_to'] ) .'>'; |
|
987 | + $new_notification['post_content']['from'] = ( empty( $atts['reply_to_name'] ) ? '[sitename]' : $atts['reply_to_name'] ) . ' <' . ( empty( $atts['reply_to'] ) ? '[admin_email]' : $atts['reply_to'] ) . '>'; |
|
988 | 988 | } |
989 | 989 | } |
990 | 990 | |
@@ -998,50 +998,50 @@ discard block |
||
998 | 998 | if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) { |
999 | 999 | foreach ( $post_content['conditions'] as $email_key => $val ) { |
1000 | 1000 | if ( is_numeric( $email_key ) ) { |
1001 | - $post_content['conditions'][ $email_key ] = self::switch_action_field_ids( $val, array( 'hide_field' ) ); |
|
1001 | + $post_content['conditions'][$email_key] = self::switch_action_field_ids( $val, array( 'hide_field' ) ); |
|
1002 | 1002 | } |
1003 | - unset( $email_key, $val); |
|
1003 | + unset( $email_key, $val ); |
|
1004 | 1004 | } |
1005 | 1005 | } |
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) { |
1009 | - if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) { |
|
1009 | + if ( isset( $form_options['auto_responder'] ) && $form_options['auto_responder'] && isset( $form_options['ar_email_message'] ) && $form_options['ar_email_message'] ) { |
|
1010 | 1010 | // migrate autoresponder |
1011 | 1011 | |
1012 | - $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0; |
|
1013 | - if ( strpos($email_field, '|') ) { |
|
1012 | + $email_field = isset( $form_options['ar_email_to'] ) ? $form_options['ar_email_to'] : 0; |
|
1013 | + if ( strpos( $email_field, '|' ) ) { |
|
1014 | 1014 | // data from entries field |
1015 | - $email_field = explode('|', $email_field); |
|
1016 | - if ( isset($email_field[1]) ) { |
|
1015 | + $email_field = explode( '|', $email_field ); |
|
1016 | + if ( isset( $email_field[1] ) ) { |
|
1017 | 1017 | $email_field = $email_field[1]; |
1018 | 1018 | } |
1019 | 1019 | } |
1020 | - if ( is_numeric($email_field) && ! empty($email_field) ) { |
|
1021 | - $email_field = '['. $email_field .']'; |
|
1020 | + if ( is_numeric( $email_field ) && ! empty( $email_field ) ) { |
|
1021 | + $email_field = '[' . $email_field . ']'; |
|
1022 | 1022 | } |
1023 | 1023 | |
1024 | 1024 | $notification = $form_options; |
1025 | 1025 | $new_notification2 = array( |
1026 | 1026 | 'post_content' => array( |
1027 | 1027 | 'email_message' => $notification['ar_email_message'], |
1028 | - 'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '', |
|
1028 | + 'email_subject' => isset( $notification['ar_email_subject'] ) ? $notification['ar_email_subject'] : '', |
|
1029 | 1029 | 'email_to' => $email_field, |
1030 | - 'plain_text' => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0, |
|
1030 | + 'plain_text' => isset( $notification['ar_plain_text'] ) ? $notification['ar_plain_text'] : 0, |
|
1031 | 1031 | 'inc_user_info' => 0, |
1032 | 1032 | ), |
1033 | - 'post_name' => $form_id .'_email_'. count( $notifications ), |
|
1033 | + 'post_name' => $form_id . '_email_' . count( $notifications ), |
|
1034 | 1034 | ); |
1035 | 1035 | |
1036 | - $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : ''; |
|
1037 | - $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : ''; |
|
1036 | + $reply_to = isset( $notification['ar_reply_to'] ) ? $notification['ar_reply_to'] : ''; |
|
1037 | + $reply_to_name = isset( $notification['ar_reply_to_name'] ) ? $notification['ar_reply_to_name'] : ''; |
|
1038 | 1038 | |
1039 | 1039 | if ( ! empty( $reply_to ) ) { |
1040 | 1040 | $new_notification2['post_content']['reply_to'] = $reply_to; |
1041 | 1041 | } |
1042 | 1042 | |
1043 | 1043 | if ( ! empty( $reply_to ) || ! empty( $reply_to_name ) ) { |
1044 | - $new_notification2['post_content']['from'] = ( empty($reply_to_name) ? '[sitename]' : $reply_to_name ) .' <'. ( empty($reply_to) ? '[admin_email]' : $reply_to ) .'>'; |
|
1044 | + $new_notification2['post_content']['from'] = ( empty( $reply_to_name ) ? '[sitename]' : $reply_to_name ) . ' <' . ( empty( $reply_to ) ? '[admin_email]' : $reply_to ) . '>'; |
|
1045 | 1045 | } |
1046 | 1046 | |
1047 | 1047 | $notifications[] = $new_notification2; |
@@ -7,8 +7,8 @@ discard block |
||
7 | 7 | var $entry_metas; |
8 | 8 | |
9 | 9 | public function __construct() { |
10 | - if ( ! defined('ABSPATH') ) { |
|
11 | - die('You are not allowed to call this page directly.'); |
|
10 | + if ( ! defined( 'ABSPATH' ) ) { |
|
11 | + die( 'You are not allowed to call this page directly.' ); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | global $wpdb; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | $frm_db_version = FrmAppHelper::$db_version; |
25 | 25 | $old_db_version = (float) $old_db_version; |
26 | 26 | if ( ! $old_db_version ) { |
27 | - $old_db_version = get_option('frm_db_version'); |
|
27 | + $old_db_version = get_option( 'frm_db_version' ); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | if ( $frm_db_version != $old_db_version ) { |
@@ -34,16 +34,16 @@ discard block |
||
34 | 34 | require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
35 | 35 | |
36 | 36 | $this->create_tables(); |
37 | - $this->migrate_data($frm_db_version, $old_db_version); |
|
37 | + $this->migrate_data( $frm_db_version, $old_db_version ); |
|
38 | 38 | |
39 | 39 | /***** SAVE DB VERSION *****/ |
40 | - update_option('frm_db_version', $frm_db_version); |
|
40 | + update_option( 'frm_db_version', $frm_db_version ); |
|
41 | 41 | |
42 | 42 | /**** ADD/UPDATE DEFAULT TEMPLATES ****/ |
43 | 43 | FrmXMLController::add_default_templates(); |
44 | 44 | } |
45 | 45 | |
46 | - do_action('frm_after_install'); |
|
46 | + do_action( 'frm_after_install' ); |
|
47 | 47 | |
48 | 48 | /**** update the styling settings ****/ |
49 | 49 | if ( is_admin() && function_exists( 'get_filesystem_method' ) ) { |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | |
61 | 61 | $charset_collate = ''; |
62 | 62 | if ( ! empty( $wpdb->charset ) ) { |
63 | - $charset_collate .= ' DEFAULT CHARACTER SET '. $wpdb->charset; |
|
63 | + $charset_collate .= ' DEFAULT CHARACTER SET ' . $wpdb->charset; |
|
64 | 64 | } |
65 | 65 | |
66 | - if ( ! empty($wpdb->collate) ) { |
|
67 | - $charset_collate .= ' COLLATE '. $wpdb->collate; |
|
66 | + if ( ! empty( $wpdb->collate ) ) { |
|
67 | + $charset_collate .= ' COLLATE ' . $wpdb->collate; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | return $charset_collate; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $sql = array(); |
76 | 76 | |
77 | 77 | /* Create/Upgrade Fields Table */ |
78 | - $sql[] = 'CREATE TABLE '. $this->fields .' ( |
|
78 | + $sql[] = 'CREATE TABLE ' . $this->fields . ' ( |
|
79 | 79 | id int(11) NOT NULL auto_increment, |
80 | 80 | field_key varchar(100) default NULL, |
81 | 81 | name text default NULL, |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | )'; |
95 | 95 | |
96 | 96 | /* Create/Upgrade Forms Table */ |
97 | - $sql[] = 'CREATE TABLE '. $this->forms .' ( |
|
97 | + $sql[] = 'CREATE TABLE ' . $this->forms . ' ( |
|
98 | 98 | id int(11) NOT NULL auto_increment, |
99 | 99 | form_key varchar(100) default NULL, |
100 | 100 | name varchar(255) default NULL, |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | )'; |
113 | 113 | |
114 | 114 | /* Create/Upgrade Items Table */ |
115 | - $sql[] = 'CREATE TABLE '. $this->entries .' ( |
|
115 | + $sql[] = 'CREATE TABLE ' . $this->entries . ' ( |
|
116 | 116 | id int(11) NOT NULL auto_increment, |
117 | 117 | item_key varchar(100) default NULL, |
118 | 118 | name varchar(255) default NULL, |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | )'; |
136 | 136 | |
137 | 137 | /* Create/Upgrade Meta Table */ |
138 | - $sql[] = 'CREATE TABLE '. $this->entry_metas .' ( |
|
138 | + $sql[] = 'CREATE TABLE ' . $this->entry_metas . ' ( |
|
139 | 139 | id int(11) NOT NULL auto_increment, |
140 | 140 | meta_value longtext default NULL, |
141 | 141 | field_id int(11) NOT NULL, |
@@ -148,12 +148,12 @@ discard block |
||
148 | 148 | |
149 | 149 | foreach ( $sql as $q ) { |
150 | 150 | if ( function_exists( 'dbDelta' ) ) { |
151 | - dbDelta( $q . $charset_collate .';' ); |
|
151 | + dbDelta( $q . $charset_collate . ';' ); |
|
152 | 152 | } else { |
153 | 153 | global $wpdb; |
154 | 154 | $wpdb->query( $q . $charset_collate ); |
155 | 155 | } |
156 | - unset($q); |
|
156 | + unset( $q ); |
|
157 | 157 | } |
158 | 158 | } |
159 | 159 | |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | $migrations = array( 4, 6, 11, 16, 17, 23, 25 ); |
165 | 165 | foreach ( $migrations as $migration ) { |
166 | 166 | if ( $frm_db_version >= $migration && $old_db_version < $migration ) { |
167 | - $function_name = 'migrate_to_'. $migration; |
|
167 | + $function_name = 'migrate_to_' . $migration; |
|
168 | 168 | $this->$function_name(); |
169 | 169 | } |
170 | 170 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * Change array into format $wpdb->prepare can use |
175 | 175 | */ |
176 | 176 | public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) { |
177 | - if ( empty($args) ) { |
|
177 | + if ( empty( $args ) ) { |
|
178 | 178 | // add an arg to prevent prepare from failing |
179 | 179 | $args = array( 'where' => $starts_with . '1=%d', 'values' => array( 1 ) ); |
180 | 180 | return; |
@@ -230,12 +230,12 @@ discard block |
||
230 | 230 | private static function interpret_array_to_sql( $key, $value, &$where, &$values ) { |
231 | 231 | $key = trim( $key ); |
232 | 232 | |
233 | - if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false ) { |
|
234 | - $k = explode(' ', $key); |
|
233 | + if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false ) { |
|
234 | + $k = explode( ' ', $key ); |
|
235 | 235 | $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key ); |
236 | 236 | $values[] = '%Y-%m-%d %H:%i:%s'; |
237 | 237 | } else { |
238 | - $where .= ' '. $key; |
|
238 | + $where .= ' ' . $key; |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | $lowercase_key = explode( ' ', strtolower( $key ) ); |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | } |
258 | 258 | $where .= ')'; |
259 | 259 | } else if ( ! empty( $value ) ) { |
260 | - $where .= ' in ('. FrmAppHelper::prepare_array_values( $value, '%s' ) .')'; |
|
260 | + $where .= ' in (' . FrmAppHelper::prepare_array_values( $value, '%s' ) . ')'; |
|
261 | 261 | $values = array_merge( $values, $value ); |
262 | 262 | } |
263 | 263 | } else if ( strpos( $lowercase_key, 'like' ) !== false ) { |
@@ -322,8 +322,8 @@ discard block |
||
322 | 322 | $query .= $where . ' ' . implode( ' ', $args ); |
323 | 323 | } |
324 | 324 | |
325 | - $cache_key = str_replace( array( ' ', ',' ), '_', trim( implode('_', FrmAppHelper::array_flatten( $where ) ) . implode( '_', $args ) . $field .'_'. $type, ' WHERE' ) ); |
|
326 | - $results = FrmAppHelper::check_cache( $cache_key, $group, $query, 'get_'. $type ); |
|
325 | + $cache_key = str_replace( array( ' ', ',' ), '_', trim( implode( '_', FrmAppHelper::array_flatten( $where ) ) . implode( '_', $args ) . $field . '_' . $type, ' WHERE' ) ); |
|
326 | + $results = FrmAppHelper::check_cache( $cache_key, $group, $query, 'get_' . $type ); |
|
327 | 327 | return $results; |
328 | 328 | } |
329 | 329 | |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | |
355 | 355 | public static function get_records( $table, $args = array(), $order_by = '', $limit = '', $fields = '*' ) { |
356 | 356 | _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_results' ); |
357 | - return self::get_results( $table, $args, $fields, compact('order_by', 'limit') ); |
|
357 | + return self::get_results( $table, $args, $fields, compact( 'order_by', 'limit' ) ); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | /** |
@@ -387,8 +387,8 @@ discard block |
||
387 | 387 | ); |
388 | 388 | |
389 | 389 | $where_is = strtolower( $where_is ); |
390 | - if ( isset( $switch_to[ $where_is ] ) ) { |
|
391 | - return ' ' . $switch_to[ $where_is ]; |
|
390 | + if ( isset( $switch_to[$where_is] ) ) { |
|
391 | + return ' ' . $switch_to[$where_is]; |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | // > and < need a little more work since we don't want them switched to >= and <= |
@@ -410,8 +410,8 @@ discard block |
||
410 | 410 | private static function get_group_and_table_name( &$table, &$group ) { |
411 | 411 | global $wpdb, $wpmuBaseTablePrefix; |
412 | 412 | |
413 | - $table_parts = explode(' ', $table); |
|
414 | - $group = reset($table_parts); |
|
413 | + $table_parts = explode( ' ', $table ); |
|
414 | + $group = reset( $table_parts ); |
|
415 | 415 | $group = str_replace( $wpdb->prefix, '', $group ); |
416 | 416 | |
417 | 417 | $prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix : $wpdb->base_prefix; |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | } |
427 | 427 | |
428 | 428 | private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) { |
429 | - if ( ! is_array($args) ) { |
|
429 | + if ( ! is_array( $args ) ) { |
|
430 | 430 | $args = array( 'order_by' => $args ); |
431 | 431 | } |
432 | 432 | |
@@ -441,16 +441,16 @@ discard block |
||
441 | 441 | $temp_args = $args; |
442 | 442 | foreach ( $temp_args as $k => $v ) { |
443 | 443 | if ( $v == '' ) { |
444 | - unset( $args[ $k ] ); |
|
444 | + unset( $args[$k] ); |
|
445 | 445 | continue; |
446 | 446 | } |
447 | 447 | |
448 | 448 | if ( $k == 'limit' ) { |
449 | - $args[ $k ] = FrmAppHelper::esc_limit( $v ); |
|
449 | + $args[$k] = FrmAppHelper::esc_limit( $v ); |
|
450 | 450 | } |
451 | 451 | $db_name = strtoupper( str_replace( '_', ' ', $k ) ); |
452 | 452 | if ( strpos( $v, $db_name ) === false ) { |
453 | - $args[ $k ] = $db_name . ' ' . $v; |
|
453 | + $args[$k] = $db_name . ' ' . $v; |
|
454 | 454 | } |
455 | 455 | } |
456 | 456 | } |
@@ -458,18 +458,18 @@ discard block |
||
458 | 458 | public function uninstall() { |
459 | 459 | if ( ! current_user_can( 'administrator' ) ) { |
460 | 460 | $frm_settings = FrmAppHelper::get_settings(); |
461 | - wp_die($frm_settings->admin_permission); |
|
461 | + wp_die( $frm_settings->admin_permission ); |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | global $wpdb, $wp_roles; |
465 | 465 | |
466 | - $wpdb->query( 'DROP TABLE IF EXISTS '. $this->fields ); |
|
467 | - $wpdb->query( 'DROP TABLE IF EXISTS '. $this->forms ); |
|
468 | - $wpdb->query( 'DROP TABLE IF EXISTS '. $this->entries ); |
|
469 | - $wpdb->query( 'DROP TABLE IF EXISTS '. $this->entry_metas ); |
|
466 | + $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->fields ); |
|
467 | + $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->forms ); |
|
468 | + $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries ); |
|
469 | + $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas ); |
|
470 | 470 | |
471 | - delete_option('frm_options'); |
|
472 | - delete_option('frm_db_version'); |
|
471 | + delete_option( 'frm_options' ); |
|
472 | + delete_option( 'frm_db_version' ); |
|
473 | 473 | |
474 | 474 | //delete roles |
475 | 475 | $frm_roles = FrmAppHelper::frm_capabilities(); |
@@ -477,11 +477,11 @@ discard block |
||
477 | 477 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
478 | 478 | foreach ( $roles as $role => $details ) { |
479 | 479 | $wp_roles->remove_cap( $role, $frm_role ); |
480 | - unset($role, $details); |
|
480 | + unset( $role, $details ); |
|
481 | 481 | } |
482 | - unset($frm_role, $frm_role_description); |
|
482 | + unset( $frm_role, $frm_role_description ); |
|
483 | 483 | } |
484 | - unset($roles, $frm_roles); |
|
484 | + unset( $roles, $frm_roles ); |
|
485 | 485 | |
486 | 486 | // delete actions, views, and styles |
487 | 487 | |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | remove_action( 'before_delete_post', 'FrmProDisplaysController::before_delete_post' ); |
490 | 490 | remove_action( 'deleted_post', 'FrmProEntriesController::delete_entry' ); |
491 | 491 | |
492 | - $post_ids = $wpdb->get_col( $wpdb->prepare( 'SELECT ID FROM ' . $wpdb->posts .' WHERE post_type in (%s, %s, %s)', FrmFormActionsController::$action_post_type, FrmStylesController::$post_type, 'frm_display' ) ); |
|
492 | + $post_ids = $wpdb->get_col( $wpdb->prepare( 'SELECT ID FROM ' . $wpdb->posts . ' WHERE post_type in (%s, %s, %s)', FrmFormActionsController::$action_post_type, FrmStylesController::$post_type, 'frm_display' ) ); |
|
493 | 493 | foreach ( $post_ids as $post_id ) { |
494 | 494 | // Delete's each post. |
495 | 495 | wp_delete_post( $post_id, true ); |
@@ -501,9 +501,9 @@ discard block |
||
501 | 501 | delete_transient( 'frm_options' ); |
502 | 502 | delete_transient( 'frmpro_options' ); |
503 | 503 | |
504 | - $wpdb->query( $wpdb->prepare( 'DELETE FROM '. $wpdb->options .' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) ); |
|
504 | + $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) ); |
|
505 | 505 | |
506 | - do_action('frm_after_uninstall'); |
|
506 | + do_action( 'frm_after_uninstall' ); |
|
507 | 507 | return true; |
508 | 508 | } |
509 | 509 | |
@@ -538,9 +538,9 @@ discard block |
||
538 | 538 | */ |
539 | 539 | private function migrate_to_23() { |
540 | 540 | global $wpdb; |
541 | - $exists = $wpdb->get_row( 'SHOW COLUMNS FROM '. $this->forms .' LIKE "parent_form_id"' ); |
|
541 | + $exists = $wpdb->get_row( 'SHOW COLUMNS FROM ' . $this->forms . ' LIKE "parent_form_id"' ); |
|
542 | 542 | if ( empty( $exists ) ) { |
543 | - $wpdb->query( 'ALTER TABLE '. $this->forms .' ADD parent_form_id int(11) default 0' ); |
|
543 | + $wpdb->query( 'ALTER TABLE ' . $this->forms . ' ADD parent_form_id int(11) default 0' ); |
|
544 | 544 | } |
545 | 545 | } |
546 | 546 | |
@@ -560,8 +560,8 @@ discard block |
||
560 | 560 | |
561 | 561 | $updated = 0; |
562 | 562 | foreach ( $fields as $f ) { |
563 | - $f->field_options = maybe_unserialize($f->field_options); |
|
564 | - if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) { |
|
563 | + $f->field_options = maybe_unserialize( $f->field_options ); |
|
564 | + if ( empty( $f->field_options['size'] ) || ! is_numeric( $f->field_options['size'] ) ) { |
|
565 | 565 | continue; |
566 | 566 | } |
567 | 567 | |
@@ -569,27 +569,27 @@ discard block |
||
569 | 569 | $f->field_options['size'] .= 'px'; |
570 | 570 | $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) ); |
571 | 571 | if ( $u ) { |
572 | - $updated++; |
|
572 | + $updated ++; |
|
573 | 573 | } |
574 | - unset($f); |
|
574 | + unset( $f ); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | // Change the characters in widgets to pixels |
578 | - $widgets = get_option('widget_frm_show_form'); |
|
579 | - if ( empty($widgets) ) { |
|
578 | + $widgets = get_option( 'widget_frm_show_form' ); |
|
579 | + if ( empty( $widgets ) ) { |
|
580 | 580 | return; |
581 | 581 | } |
582 | 582 | |
583 | - $widgets = maybe_unserialize($widgets); |
|
583 | + $widgets = maybe_unserialize( $widgets ); |
|
584 | 584 | foreach ( $widgets as $k => $widget ) { |
585 | - if ( ! is_array($widget) || ! isset($widget['size']) ) { |
|
585 | + if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) { |
|
586 | 586 | continue; |
587 | 587 | } |
588 | 588 | $size = round( $pixel_conversion * (int) $widget['size'] ); |
589 | 589 | $size .= 'px'; |
590 | - $widgets[ $k ]['size'] = $size; |
|
590 | + $widgets[$k]['size'] = $size; |
|
591 | 591 | } |
592 | - update_option('widget_frm_show_form', $widgets); |
|
592 | + update_option( 'widget_frm_show_form', $widgets ); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | /** |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | } |
639 | 639 | |
640 | 640 | // Format form options |
641 | - $form_options = maybe_unserialize($form->options); |
|
641 | + $form_options = maybe_unserialize( $form->options ); |
|
642 | 642 | |
643 | 643 | // Migrate settings to actions |
644 | 644 | FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id ); |
@@ -648,10 +648,10 @@ discard block |
||
648 | 648 | private function migrate_to_11() { |
649 | 649 | global $wpdb; |
650 | 650 | |
651 | - $forms = FrmDb::get_results( $this->forms, array(), 'id, options'); |
|
651 | + $forms = FrmDb::get_results( $this->forms, array(), 'id, options' ); |
|
652 | 652 | |
653 | 653 | $sending = __( 'Sending', 'formidable' ); |
654 | - $img = FrmAppHelper::plugin_url() .'/images/ajax_loader.gif'; |
|
654 | + $img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif'; |
|
655 | 655 | $old_default_html = <<<DEFAULT_HTML |
656 | 656 | <div class="frm_submit"> |
657 | 657 | [if back_button]<input type="submit" value="[back_label]" name="frm_prev_page" formnovalidate="formnovalidate" [back_hook] />[/if back_button] |
@@ -659,13 +659,13 @@ discard block |
||
659 | 659 | <img class="frm_ajax_loading" src="$img" alt="$sending" style="visibility:hidden;" /> |
660 | 660 | </div> |
661 | 661 | DEFAULT_HTML; |
662 | - unset($sending, $img); |
|
662 | + unset( $sending, $img ); |
|
663 | 663 | |
664 | - $new_default_html = FrmFormsHelper::get_default_html('submit'); |
|
664 | + $new_default_html = FrmFormsHelper::get_default_html( 'submit' ); |
|
665 | 665 | $draft_link = FrmFormsHelper::get_draft_link(); |
666 | 666 | foreach ( $forms as $form ) { |
667 | - $form->options = maybe_unserialize($form->options); |
|
668 | - if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) { |
|
667 | + $form->options = maybe_unserialize( $form->options ); |
|
668 | + if ( ! isset( $form->options['submit_html'] ) || empty( $form->options['submit_html'] ) ) { |
|
669 | 669 | continue; |
670 | 670 | } |
671 | 671 | |
@@ -673,12 +673,12 @@ discard block |
||
673 | 673 | $form->options['submit_html'] = $new_default_html; |
674 | 674 | $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) ); |
675 | 675 | } else if ( ! strpos( $form->options['submit_html'], 'save_draft' ) ) { |
676 | - $form->options['submit_html'] = preg_replace('~\<\/div\>(?!.*\<\/div\>)~', $draft_link ."\r\n</div>", $form->options['submit_html']); |
|
676 | + $form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] ); |
|
677 | 677 | $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) ); |
678 | 678 | } |
679 | - unset($form); |
|
679 | + unset( $form ); |
|
680 | 680 | } |
681 | - unset($forms); |
|
681 | + unset( $forms ); |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | private function migrate_to_6() { |
@@ -707,16 +707,16 @@ discard block |
||
707 | 707 | </div> |
708 | 708 | DEFAULT_HTML; |
709 | 709 | |
710 | - $new_default_html = FrmFieldsHelper::get_default_html('text'); |
|
710 | + $new_default_html = FrmFieldsHelper::get_default_html( 'text' ); |
|
711 | 711 | foreach ( $fields as $field ) { |
712 | - $field->field_options = maybe_unserialize($field->field_options); |
|
712 | + $field->field_options = maybe_unserialize( $field->field_options ); |
|
713 | 713 | if ( ! FrmField::is_option_empty( $field, 'custom_html' ) || $field->field_options['custom_html'] == $default_html || $field->field_options['custom_html'] == $old_default_html ) { |
714 | 714 | $field->field_options['custom_html'] = $new_default_html; |
715 | 715 | $wpdb->update( $this->fields, array( 'field_options' => maybe_serialize( $field->field_options ) ), array( 'id' => $field->id ) ); |
716 | 716 | } |
717 | - unset($field); |
|
717 | + unset( $field ); |
|
718 | 718 | } |
719 | - unset($default_html, $old_default_html, $fields); |
|
719 | + unset( $default_html, $old_default_html, $fields ); |
|
720 | 720 | } |
721 | 721 | |
722 | 722 | private function migrate_to_4() { |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined('ABSPATH') ) { |
|
3 | - die('You are not allowed to call this page directly.'); |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | + die( 'You are not allowed to call this page directly.' ); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | class FrmForm { |
@@ -12,32 +12,32 @@ discard block |
||
12 | 12 | global $wpdb; |
13 | 13 | |
14 | 14 | $new_values = array( |
15 | - 'form_key' => FrmAppHelper::get_unique_key($values['form_key'], $wpdb->prefix .'frm_forms', 'form_key'), |
|
15 | + 'form_key' => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ), |
|
16 | 16 | 'name' => $values['name'], |
17 | 17 | 'description' => $values['description'], |
18 | - 'status' => isset($values['status']) ? $values['status'] : 'draft', |
|
19 | - 'logged_in' => isset($values['logged_in']) ? $values['logged_in'] : 0, |
|
20 | - 'is_template' => isset($values['is_template']) ? (int) $values['is_template'] : 0, |
|
18 | + 'status' => isset( $values['status'] ) ? $values['status'] : 'draft', |
|
19 | + 'logged_in' => isset( $values['logged_in'] ) ? $values['logged_in'] : 0, |
|
20 | + 'is_template' => isset( $values['is_template'] ) ? (int) $values['is_template'] : 0, |
|
21 | 21 | 'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0, |
22 | - 'editable' => isset($values['editable']) ? (int) $values['editable'] : 0, |
|
23 | - 'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0, |
|
24 | - 'created_at' => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1), |
|
22 | + 'editable' => isset( $values['editable'] ) ? (int) $values['editable'] : 0, |
|
23 | + 'default_template' => isset( $values['default_template'] ) ? (int) $values['default_template'] : 0, |
|
24 | + 'created_at' => isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 ), |
|
25 | 25 | ); |
26 | 26 | |
27 | 27 | $options = array(); |
28 | 28 | FrmFormsHelper::fill_form_options( $options, $values ); |
29 | 29 | |
30 | - $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
31 | - $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
32 | - $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
30 | + $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' ); |
|
31 | + $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' ); |
|
32 | + $options['submit_html'] = isset( $values['options']['submit_html'] ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' ); |
|
33 | 33 | |
34 | - $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
35 | - $new_values['options'] = serialize($options); |
|
34 | + $options = apply_filters( 'frm_form_options_before_update', $options, $values ); |
|
35 | + $new_values['options'] = serialize( $options ); |
|
36 | 36 | |
37 | 37 | //if(isset($values['id']) && is_numeric($values['id'])) |
38 | 38 | // $new_values['id'] = $values['id']; |
39 | 39 | |
40 | - $wpdb->insert( $wpdb->prefix .'frm_forms', $new_values ); |
|
40 | + $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values ); |
|
41 | 41 | |
42 | 42 | $id = $wpdb->insert_id; |
43 | 43 | |
@@ -61,38 +61,38 @@ discard block |
||
61 | 61 | $new_key = $copy_keys ? $values->form_key : ''; |
62 | 62 | |
63 | 63 | $new_values = array( |
64 | - 'form_key' => FrmAppHelper::get_unique_key($new_key, $wpdb->prefix .'frm_forms', 'form_key'), |
|
64 | + 'form_key' => FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_forms', 'form_key' ), |
|
65 | 65 | 'name' => $values->name, |
66 | 66 | 'description' => $values->description, |
67 | 67 | 'status' => $template ? 'published' : 'draft', |
68 | 68 | 'logged_in' => $values->logged_in ? $values->logged_in : 0, |
69 | 69 | 'editable' => $values->editable ? $values->editable : 0, |
70 | - 'created_at' => current_time('mysql', 1), |
|
70 | + 'created_at' => current_time( 'mysql', 1 ), |
|
71 | 71 | 'is_template' => $template ? 1 : 0, |
72 | 72 | ); |
73 | 73 | |
74 | 74 | if ( $blog_id ) { |
75 | 75 | $new_values['status'] = 'published'; |
76 | - $new_options = maybe_unserialize($values->options); |
|
77 | - $new_options['email_to'] = get_option('admin_email'); |
|
76 | + $new_options = maybe_unserialize( $values->options ); |
|
77 | + $new_options['email_to'] = get_option( 'admin_email' ); |
|
78 | 78 | $new_options['copy'] = false; |
79 | 79 | $new_values['options'] = $new_options; |
80 | 80 | } else { |
81 | 81 | $new_values['options'] = $values->options; |
82 | 82 | } |
83 | 83 | |
84 | - if ( is_array($new_values['options']) ) { |
|
85 | - $new_values['options'] = serialize($new_values['options']); |
|
84 | + if ( is_array( $new_values['options'] ) ) { |
|
85 | + $new_values['options'] = serialize( $new_values['options'] ); |
|
86 | 86 | } |
87 | 87 | |
88 | - $query_results = $wpdb->insert( $wpdb->prefix .'frm_forms', $new_values ); |
|
88 | + $query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values ); |
|
89 | 89 | |
90 | 90 | if ( $query_results ) { |
91 | 91 | // Clear form caching |
92 | 92 | self::clear_form_cache(); |
93 | 93 | |
94 | 94 | $form_id = $wpdb->insert_id; |
95 | - FrmField::duplicate($id, $form_id, $copy_keys, $blog_id); |
|
95 | + FrmField::duplicate( $id, $form_id, $copy_keys, $blog_id ); |
|
96 | 96 | |
97 | 97 | // update form settings after fields are created |
98 | 98 | do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) ); |
@@ -103,13 +103,13 @@ discard block |
||
103 | 103 | } |
104 | 104 | |
105 | 105 | public static function after_duplicate( $form_id, $values ) { |
106 | - $new_opts = $values['options'] = maybe_unserialize($values['options']); |
|
106 | + $new_opts = $values['options'] = maybe_unserialize( $values['options'] ); |
|
107 | 107 | |
108 | - if ( isset($new_opts['success_msg']) ) { |
|
109 | - $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']); |
|
108 | + if ( isset( $new_opts['success_msg'] ) ) { |
|
109 | + $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids( $new_opts['success_msg'] ); |
|
110 | 110 | } |
111 | 111 | |
112 | - $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id); |
|
112 | + $new_opts = apply_filters( 'frm_after_duplicate_form_values', $new_opts, $form_id ); |
|
113 | 113 | |
114 | 114 | if ( $new_opts != $values['options'] ) { |
115 | 115 | global $wpdb; |
@@ -127,17 +127,17 @@ discard block |
||
127 | 127 | $values['status'] = 'published'; |
128 | 128 | } |
129 | 129 | |
130 | - if ( isset($values['form_key']) ) { |
|
131 | - $values['form_key'] = FrmAppHelper::get_unique_key($values['form_key'], $wpdb->prefix .'frm_forms', 'form_key', $id); |
|
130 | + if ( isset( $values['form_key'] ) ) { |
|
131 | + $values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id ); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | $form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' ); |
135 | 135 | |
136 | - $new_values = self::set_update_options( array(), $values); |
|
136 | + $new_values = self::set_update_options( array(), $values ); |
|
137 | 137 | |
138 | 138 | foreach ( $values as $value_key => $value ) { |
139 | - if ( in_array($value_key, $form_fields) ) { |
|
140 | - $new_values[ $value_key ] = $value; |
|
139 | + if ( in_array( $value_key, $form_fields ) ) { |
|
140 | + $new_values[$value_key] = $value; |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
@@ -146,19 +146,19 @@ discard block |
||
146 | 146 | } |
147 | 147 | |
148 | 148 | if ( ! empty( $new_values ) ) { |
149 | - $query_results = $wpdb->update( $wpdb->prefix .'frm_forms', $new_values, array( 'id' => $id ) ); |
|
149 | + $query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', $new_values, array( 'id' => $id ) ); |
|
150 | 150 | if ( $query_results ) { |
151 | 151 | self::clear_form_cache(); |
152 | 152 | } |
153 | 153 | } else { |
154 | 154 | $query_results = true; |
155 | 155 | } |
156 | - unset($new_values); |
|
156 | + unset( $new_values ); |
|
157 | 157 | |
158 | - $values = self::update_fields($id, $values); |
|
158 | + $values = self::update_fields( $id, $values ); |
|
159 | 159 | |
160 | - do_action('frm_update_form', $id, $values); |
|
161 | - do_action('frm_update_form_'. $id, $values); |
|
160 | + do_action( 'frm_update_form', $id, $values ); |
|
161 | + do_action( 'frm_update_form_' . $id, $values ); |
|
162 | 162 | |
163 | 163 | return $query_results; |
164 | 164 | } |
@@ -167,20 +167,20 @@ discard block |
||
167 | 167 | * @return array |
168 | 168 | */ |
169 | 169 | public static function set_update_options( $new_values, $values ) { |
170 | - if ( ! isset($values['options']) ) { |
|
170 | + if ( ! isset( $values['options'] ) ) { |
|
171 | 171 | return $new_values; |
172 | 172 | } |
173 | 173 | |
174 | 174 | $options = array(); |
175 | 175 | FrmFormsHelper::fill_form_options( $options, $values ); |
176 | 176 | |
177 | - $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0; |
|
178 | - $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
179 | - $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
180 | - $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
177 | + $options['custom_style'] = isset( $values['options']['custom_style'] ) ? $values['options']['custom_style'] : 0; |
|
178 | + $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' ); |
|
179 | + $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' ); |
|
180 | + $options['submit_html'] = ( isset( $values['options']['submit_html'] ) && $values['options']['submit_html'] != '' ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' ); |
|
181 | 181 | |
182 | - $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
183 | - $new_values['options'] = serialize($options); |
|
182 | + $options = apply_filters( 'frm_form_options_before_update', $options, $values ); |
|
183 | + $new_values['options'] = serialize( $options ); |
|
184 | 184 | |
185 | 185 | return $new_values; |
186 | 186 | } |
@@ -191,82 +191,82 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public static function update_fields( $id, $values ) { |
193 | 193 | |
194 | - if ( ! isset($values['options']) && ! isset($values['item_meta']) && ! isset($values['field_options']) ) { |
|
194 | + if ( ! isset( $values['options'] ) && ! isset( $values['item_meta'] ) && ! isset( $values['field_options'] ) ) { |
|
195 | 195 | return $values; |
196 | 196 | } |
197 | 197 | |
198 | - $all_fields = FrmField::get_all_for_form($id); |
|
199 | - if ( empty($all_fields) ) { |
|
198 | + $all_fields = FrmField::get_all_for_form( $id ); |
|
199 | + if ( empty( $all_fields ) ) { |
|
200 | 200 | return $values; |
201 | 201 | } |
202 | 202 | |
203 | - if ( ! isset($values['item_meta']) ) { |
|
203 | + if ( ! isset( $values['item_meta'] ) ) { |
|
204 | 204 | $values['item_meta'] = array(); |
205 | 205 | } |
206 | 206 | |
207 | 207 | $field_array = array(); |
208 | - $existing_keys = array_keys($values['item_meta']); |
|
208 | + $existing_keys = array_keys( $values['item_meta'] ); |
|
209 | 209 | foreach ( $all_fields as $fid ) { |
210 | - if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) { |
|
211 | - $values['item_meta'][ $fid->id ] = ''; |
|
210 | + if ( ! in_array( $fid->id, $existing_keys ) && ( isset( $values['frm_fields_submitted'] ) && in_array( $fid->id, $values['frm_fields_submitted'] ) ) || isset( $values['options'] ) ) { |
|
211 | + $values['item_meta'][$fid->id] = ''; |
|
212 | 212 | } |
213 | - $field_array[ $fid->id ] = $fid; |
|
213 | + $field_array[$fid->id] = $fid; |
|
214 | 214 | } |
215 | - unset($all_fields); |
|
215 | + unset( $all_fields ); |
|
216 | 216 | |
217 | 217 | foreach ( $values['item_meta'] as $field_id => $default_value ) { |
218 | - if ( isset( $field_array[ $field_id ] ) ) { |
|
219 | - $field = $field_array[ $field_id ]; |
|
218 | + if ( isset( $field_array[$field_id] ) ) { |
|
219 | + $field = $field_array[$field_id]; |
|
220 | 220 | } else { |
221 | - $field = FrmField::getOne($field_id); |
|
221 | + $field = FrmField::getOne( $field_id ); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | if ( ! $field ) { |
225 | 225 | continue; |
226 | 226 | } |
227 | 227 | |
228 | - if ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) { |
|
228 | + if ( isset( $values['options'] ) || isset( $values['field_options']['custom_html_' . $field_id] ) ) { |
|
229 | 229 | //updating the settings page |
230 | - if ( isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) { |
|
231 | - $field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ? $values['field_options'][ 'custom_html_' . $field_id ] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) ); |
|
232 | - $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
230 | + if ( isset( $values['field_options']['custom_html_' . $field_id] ) ) { |
|
231 | + $field->field_options['custom_html'] = isset( $values['field_options']['custom_html_' . $field_id] ) ? $values['field_options']['custom_html_' . $field_id] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) ); |
|
232 | + $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values ); |
|
233 | 233 | FrmField::update( $field_id, array( 'field_options' => $field->field_options ) ); |
234 | 234 | } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) { |
235 | 235 | $prev_opts = $field->field_options; |
236 | - $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
236 | + $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values ); |
|
237 | 237 | if ( $prev_opts != $field->field_options ) { |
238 | 238 | FrmField::update( $field_id, array( 'field_options' => $field->field_options ) ); |
239 | 239 | } |
240 | - unset($prev_opts); |
|
240 | + unset( $prev_opts ); |
|
241 | 241 | } |
242 | 242 | } |
243 | 243 | |
244 | - if ( ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) && ! defined( 'WP_IMPORTING' ) ) { |
|
244 | + if ( ( isset( $values['options'] ) || isset( $values['field_options']['custom_html_' . $field_id] ) ) && ! defined( 'WP_IMPORTING' ) ) { |
|
245 | 245 | continue; |
246 | 246 | } |
247 | 247 | |
248 | 248 | //updating the form |
249 | 249 | foreach ( array( 'size', 'max', 'label', 'invalid', 'blank', 'classes', 'captcha_size' ) as $opt ) { |
250 | - $field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? trim( $values['field_options'][ $opt . '_' . $field_id ] ) : ''; |
|
250 | + $field->field_options[$opt] = isset( $values['field_options'][$opt . '_' . $field_id] ) ? trim( $values['field_options'][$opt . '_' . $field_id] ) : ''; |
|
251 | 251 | } |
252 | 252 | |
253 | - $field->field_options['required_indicator'] = isset( $values['field_options'][ 'required_indicator_' . $field_id ] ) ? trim( $values['field_options'][ 'required_indicator_' . $field_id ] ) : '*'; |
|
254 | - $field->field_options['separate_value'] = isset( $values['field_options'][ 'separate_value_' . $field_id ] ) ? trim( $values['field_options'][ 'separate_value_' . $field_id ] ) : 0; |
|
253 | + $field->field_options['required_indicator'] = isset( $values['field_options']['required_indicator_' . $field_id] ) ? trim( $values['field_options']['required_indicator_' . $field_id] ) : '*'; |
|
254 | + $field->field_options['separate_value'] = isset( $values['field_options']['separate_value_' . $field_id] ) ? trim( $values['field_options']['separate_value_' . $field_id] ) : 0; |
|
255 | 255 | |
256 | - $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values); |
|
257 | - $default_value = maybe_serialize( $values['item_meta'][ $field_id ] ); |
|
258 | - $field_key = isset( $values['field_options'][ 'field_key_' . $field_id ] ) ? $values['field_options'][ 'field_key_' . $field_id ] : $field->field_key; |
|
259 | - $required = isset( $values['field_options'][ 'required_' . $field_id ] ) ? $values['field_options'][ 'required_' . $field_id ] : false; |
|
260 | - $field_type = isset( $values['field_options'][ 'type_' . $field_id ] ) ? $values['field_options'][ 'type_' . $field_id ] : $field->type; |
|
261 | - $field_description = isset( $values['field_options'][ 'description_' . $field_id ] ) ? $values['field_options'][ 'description_' . $field_id ] : $field->description; |
|
256 | + $field->field_options = apply_filters( 'frm_update_field_options', $field->field_options, $field, $values ); |
|
257 | + $default_value = maybe_serialize( $values['item_meta'][$field_id] ); |
|
258 | + $field_key = isset( $values['field_options']['field_key_' . $field_id] ) ? $values['field_options']['field_key_' . $field_id] : $field->field_key; |
|
259 | + $required = isset( $values['field_options']['required_' . $field_id] ) ? $values['field_options']['required_' . $field_id] : false; |
|
260 | + $field_type = isset( $values['field_options']['type_' . $field_id] ) ? $values['field_options']['type_' . $field_id] : $field->type; |
|
261 | + $field_description = isset( $values['field_options']['description_' . $field_id] ) ? $values['field_options']['description_' . $field_id] : $field->description; |
|
262 | 262 | |
263 | - FrmField::update($field_id, array( |
|
263 | + FrmField::update( $field_id, array( |
|
264 | 264 | 'field_key' => $field_key, 'type' => $field_type, |
265 | 265 | 'default_value' => $default_value, 'field_options' => $field->field_options, |
266 | 266 | 'description' => $field_description, 'required' => $required, |
267 | 267 | ) ); |
268 | 268 | |
269 | - FrmField::delete_form_transient($field->form_id); |
|
269 | + FrmField::delete_form_transient( $field->form_id ); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | return $values; |
@@ -278,17 +278,17 @@ discard block |
||
278 | 278 | */ |
279 | 279 | public static function set_status( $id, $status ) { |
280 | 280 | if ( 'trash' == $status ) { |
281 | - return self::trash($id); |
|
281 | + return self::trash( $id ); |
|
282 | 282 | } |
283 | 283 | |
284 | - $statuses = array( 'published', 'draft', 'trash' ); |
|
284 | + $statuses = array( 'published', 'draft', 'trash' ); |
|
285 | 285 | if ( ! in_array( $status, $statuses ) ) { |
286 | 286 | return false; |
287 | 287 | } |
288 | 288 | |
289 | 289 | global $wpdb; |
290 | 290 | |
291 | - if ( is_array($id) ) { |
|
291 | + if ( is_array( $id ) ) { |
|
292 | 292 | $where = array( 'id' => $id ); |
293 | 293 | FrmDb::get_where_clause_and_values( $where ); |
294 | 294 | array_unshift( $where['values'], $status ); |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | return self::destroy( $id ); |
314 | 314 | } |
315 | 315 | |
316 | - $form = self::getOne($id); |
|
316 | + $form = self::getOne( $id ); |
|
317 | 317 | if ( ! $form ) { |
318 | 318 | return false; |
319 | 319 | } |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | |
324 | 324 | global $wpdb; |
325 | 325 | $query_results = $wpdb->update( |
326 | - $wpdb->prefix .'frm_forms', |
|
326 | + $wpdb->prefix . 'frm_forms', |
|
327 | 327 | array( 'status' => 'trash', 'options' => serialize( $options ) ), |
328 | 328 | array( 'id' => $id ) |
329 | 329 | ); |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | public static function destroy( $id ) { |
342 | 342 | global $wpdb; |
343 | 343 | |
344 | - $form = self::getOne($id); |
|
344 | + $form = self::getOne( $id ); |
|
345 | 345 | if ( ! $form ) { |
346 | 346 | return false; |
347 | 347 | } |
@@ -349,24 +349,24 @@ discard block |
||
349 | 349 | // Disconnect the entries from this form |
350 | 350 | $entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) ); |
351 | 351 | foreach ( $entries as $entry_id ) { |
352 | - FrmEntry::destroy($entry_id); |
|
353 | - unset($entry_id); |
|
352 | + FrmEntry::destroy( $entry_id ); |
|
353 | + unset( $entry_id ); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | // Disconnect the fields from this form |
357 | - $wpdb->query($wpdb->prepare('DELETE fi FROM '. $wpdb->prefix .'frm_fields AS fi LEFT JOIN '. $wpdb->prefix .'frm_forms fr ON (fi.form_id = fr.id) WHERE fi.form_id=%d OR parent_form_id=%d', $id, $id)); |
|
357 | + $wpdb->query( $wpdb->prepare( 'DELETE fi FROM ' . $wpdb->prefix . 'frm_fields AS fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id) WHERE fi.form_id=%d OR parent_form_id=%d', $id, $id ) ); |
|
358 | 358 | |
359 | - $query_results = $wpdb->query($wpdb->prepare('DELETE FROM '. $wpdb->prefix .'frm_forms WHERE id=%d OR parent_form_id=%d', $id, $id)); |
|
359 | + $query_results = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_forms WHERE id=%d OR parent_form_id=%d', $id, $id ) ); |
|
360 | 360 | if ( $query_results ) { |
361 | 361 | // Delete all form actions linked to this form |
362 | 362 | $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
363 | - $action_control->destroy($id, 'all'); |
|
363 | + $action_control->destroy( $id, 'all' ); |
|
364 | 364 | |
365 | 365 | // Clear form caching |
366 | 366 | self::clear_form_cache(); |
367 | 367 | |
368 | - do_action('frm_destroy_form', $id); |
|
369 | - do_action('frm_destroy_form_'. $id); |
|
368 | + do_action( 'frm_destroy_form', $id ); |
|
369 | + do_action( 'frm_destroy_form_' . $id ); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | return $query_results; |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | $form->options = maybe_unserialize( $form->options ); |
395 | 395 | if ( ! isset( $form->options['trash_time'] ) || $form->options['trash_time'] < $delete_timestamp ) { |
396 | 396 | self::destroy( $form->id ); |
397 | - $count++; |
|
397 | + $count ++; |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | unset( $form ); |
@@ -408,15 +408,15 @@ discard block |
||
408 | 408 | public static function &getName( $id ) { |
409 | 409 | global $wpdb; |
410 | 410 | |
411 | - $form = FrmAppHelper::check_cache($id, 'frm_form'); |
|
411 | + $form = FrmAppHelper::check_cache( $id, 'frm_form' ); |
|
412 | 412 | if ( $form ) { |
413 | - $r = stripslashes($form->name); |
|
413 | + $r = stripslashes( $form->name ); |
|
414 | 414 | return $r; |
415 | 415 | } |
416 | 416 | |
417 | 417 | $query_key = is_numeric( $id ) ? 'id' : 'form_key'; |
418 | 418 | $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' ); |
419 | - $r = stripslashes($r); |
|
419 | + $r = stripslashes( $r ); |
|
420 | 420 | |
421 | 421 | return $r; |
422 | 422 | } |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | */ |
437 | 437 | public static function &getKeyById( $id ) { |
438 | 438 | $id = (int) $id; |
439 | - $cache = FrmAppHelper::check_cache($id, 'frm_form'); |
|
439 | + $cache = FrmAppHelper::check_cache( $id, 'frm_form' ); |
|
440 | 440 | if ( $cache ) { |
441 | 441 | return $cache->form_key; |
442 | 442 | } |
@@ -465,22 +465,22 @@ discard block |
||
465 | 465 | |
466 | 466 | if ( $blog_id && is_multisite() ) { |
467 | 467 | global $wpmuBaseTablePrefix; |
468 | - $prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix . $blog_id .'_' : $wpdb->get_blog_prefix( $blog_id ); |
|
468 | + $prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix . $blog_id . '_' : $wpdb->get_blog_prefix( $blog_id ); |
|
469 | 469 | |
470 | - $table_name = $prefix .'frm_forms'; |
|
470 | + $table_name = $prefix . 'frm_forms'; |
|
471 | 471 | } else { |
472 | - $table_name = $wpdb->prefix .'frm_forms'; |
|
473 | - $cache = wp_cache_get($id, 'frm_form'); |
|
472 | + $table_name = $wpdb->prefix . 'frm_forms'; |
|
473 | + $cache = wp_cache_get( $id, 'frm_form' ); |
|
474 | 474 | if ( $cache ) { |
475 | - if ( isset($cache->options) ) { |
|
476 | - $cache->options = maybe_unserialize($cache->options); |
|
475 | + if ( isset( $cache->options ) ) { |
|
476 | + $cache->options = maybe_unserialize( $cache->options ); |
|
477 | 477 | } |
478 | 478 | |
479 | - return stripslashes_deep($cache); |
|
479 | + return stripslashes_deep( $cache ); |
|
480 | 480 | } |
481 | 481 | } |
482 | 482 | |
483 | - if ( is_numeric($id) ) { |
|
483 | + if ( is_numeric( $id ) ) { |
|
484 | 484 | $where = array( 'id' => $id ); |
485 | 485 | } else { |
486 | 486 | $where = array( 'form_key' => $id ); |
@@ -488,11 +488,11 @@ discard block |
||
488 | 488 | |
489 | 489 | $results = FrmDb::get_row( $table_name, $where ); |
490 | 490 | |
491 | - if ( isset($results->options) ) { |
|
492 | - wp_cache_set($results->id, $results, 'frm_form'); |
|
493 | - $results->options = maybe_unserialize($results->options); |
|
491 | + if ( isset( $results->options ) ) { |
|
492 | + wp_cache_set( $results->id, $results, 'frm_form' ); |
|
493 | + $results->options = maybe_unserialize( $results->options ); |
|
494 | 494 | } |
495 | - return stripslashes_deep($results); |
|
495 | + return stripslashes_deep( $results ); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | /** |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | $results = reset( $results ); |
522 | 522 | } |
523 | 523 | |
524 | - return stripslashes_deep($results); |
|
524 | + return stripslashes_deep( $results ); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | /** |
@@ -561,19 +561,19 @@ discard block |
||
561 | 561 | foreach ( $results as $row ) { |
562 | 562 | if ( 'trash' != $row->status ) { |
563 | 563 | if ( $row->is_template ) { |
564 | - $counts['template']++; |
|
564 | + $counts['template'] ++; |
|
565 | 565 | } else { |
566 | - $counts['published']++; |
|
566 | + $counts['published'] ++; |
|
567 | 567 | } |
568 | 568 | } else { |
569 | - $counts['trash']++; |
|
569 | + $counts['trash'] ++; |
|
570 | 570 | } |
571 | 571 | |
572 | 572 | if ( 'draft' == $row->status ) { |
573 | - $counts['draft']++; |
|
573 | + $counts['draft'] ++; |
|
574 | 574 | } |
575 | 575 | |
576 | - unset($row); |
|
576 | + unset( $row ); |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | $counts = (object) $counts; |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | public static function validate( $values ) { |
600 | 600 | $errors = array(); |
601 | 601 | |
602 | - return apply_filters('frm_validate_form', $errors, $values); |
|
602 | + return apply_filters( 'frm_validate_form', $errors, $values ); |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | public static function get_params( $form = null ) { |
@@ -611,11 +611,11 @@ discard block |
||
611 | 611 | self::maybe_get_form( $form ); |
612 | 612 | } |
613 | 613 | |
614 | - if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][ $form->id ] ) ) { |
|
615 | - return $frm_vars['form_params'][ $form->id ]; |
|
614 | + if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][$form->id] ) ) { |
|
615 | + return $frm_vars['form_params'][$form->id]; |
|
616 | 616 | } |
617 | 617 | |
618 | - $action_var = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
618 | + $action_var = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
619 | 619 | $action = apply_filters( 'frm_show_new_entry_page', FrmAppHelper::get_param( $action_var, 'new', 'get', 'sanitize_title' ), $form ); |
620 | 620 | |
621 | 621 | $default_values = array( |
@@ -633,15 +633,15 @@ discard block |
||
633 | 633 | //if there are two forms on the same page, make sure not to submit both |
634 | 634 | foreach ( $default_values as $var => $default ) { |
635 | 635 | if ( $var == 'action' ) { |
636 | - $values[ $var ] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' ); |
|
636 | + $values[$var] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' ); |
|
637 | 637 | } else { |
638 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
|
638 | + $values[$var] = FrmAppHelper::get_param( $var, $default ); |
|
639 | 639 | } |
640 | 640 | unset( $var, $default ); |
641 | 641 | } |
642 | 642 | } else { |
643 | 643 | foreach ( $default_values as $var => $default ) { |
644 | - $values[ $var ] = $default; |
|
644 | + $values[$var] = $default; |
|
645 | 645 | unset( $var, $default ); |
646 | 646 | } |
647 | 647 | } |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | public static function list_page_params() { |
657 | 657 | $values = array(); |
658 | 658 | foreach ( array( 'template' => 0, 'id' => '', 'paged' => 1, 'form' => '', 'search' => '', 'sort' => '', 'sdir' => '' ) as $var => $default ) { |
659 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
|
659 | + $values[$var] = FrmAppHelper::get_param( $var, $default ); |
|
660 | 660 | } |
661 | 661 | |
662 | 662 | return $values; |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | 'field_id' => '', 'search' => '', 'sort' => '', 'sdir' => '', 'fid' => '', |
677 | 677 | 'keep_post' => '', |
678 | 678 | ) as $var => $default ) { |
679 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
|
679 | + $values[$var] = FrmAppHelper::get_param( $var, $default ); |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | return $values; |
@@ -718,16 +718,16 @@ discard block |
||
718 | 718 | $small_form = new stdClass(); |
719 | 719 | foreach ( array( 'id', 'form_key', 'name' ) as $var ) { |
720 | 720 | $small_form->{$var} = $form->{$var}; |
721 | - unset($var); |
|
721 | + unset( $var ); |
|
722 | 722 | } |
723 | 723 | |
724 | 724 | $frm_vars['forms_loaded'][] = $small_form; |
725 | 725 | |
726 | - if ( $this_load && empty($global_load) ) { |
|
726 | + if ( $this_load && empty( $global_load ) ) { |
|
727 | 727 | $global_load = $frm_vars['load_css'] = true; |
728 | 728 | } |
729 | 729 | |
730 | - return ( ( ! isset($frm_vars['css_loaded']) || ! $frm_vars['css_loaded'] ) && $global_load ); |
|
730 | + return ( ( ! isset( $frm_vars['css_loaded'] ) || ! $frm_vars['css_loaded'] ) && $global_load ); |
|
731 | 731 | } |
732 | 732 | |
733 | 733 | public static function show_submit( $form ) { |
@@ -2,16 +2,16 @@ discard block |
||
2 | 2 | |
3 | 3 | class FrmFormAction { |
4 | 4 | |
5 | - public $id_base; // Root id for all actions of this type. |
|
6 | - public $name; // Name for this action type. |
|
5 | + public $id_base; // Root id for all actions of this type. |
|
6 | + public $name; // Name for this action type. |
|
7 | 7 | public $option_name; |
8 | - public $action_options; // Option array passed to wp_register_sidebar_widget() |
|
9 | - public $control_options; // Option array passed to wp_register_widget_control() |
|
8 | + public $action_options; // Option array passed to wp_register_sidebar_widget() |
|
9 | + public $control_options; // Option array passed to wp_register_widget_control() |
|
10 | 10 | |
11 | - public $form_id; // The ID of the form to evaluate |
|
12 | - public $number = false; // Unique ID number of the current instance. |
|
13 | - public $id = ''; // Unique ID string of the current instance (id_base-number) |
|
14 | - public $updated = false; // Set true when we update the data after a POST submit - makes sure we don't do it twice. |
|
11 | + public $form_id; // The ID of the form to evaluate |
|
12 | + public $number = false; // Unique ID number of the current instance. |
|
13 | + public $id = ''; // Unique ID string of the current instance (id_base-number) |
|
14 | + public $updated = false; // Set true when we update the data after a POST submit - makes sure we don't do it twice. |
|
15 | 15 | |
16 | 16 | // Member functions that you must over-ride. |
17 | 17 | |
@@ -69,13 +69,13 @@ discard block |
||
69 | 69 | * - height: currently not used but may be needed in the future |
70 | 70 | */ |
71 | 71 | public function __construct( $id_base, $name, $action_options = array(), $control_options = array() ) { |
72 | - if ( ! defined('ABSPATH') ) { |
|
73 | - die('You are not allowed to call this page directly.'); |
|
72 | + if ( ! defined( 'ABSPATH' ) ) { |
|
73 | + die( 'You are not allowed to call this page directly.' ); |
|
74 | 74 | } |
75 | 75 | |
76 | - $this->id_base = strtolower($id_base); |
|
76 | + $this->id_base = strtolower( $id_base ); |
|
77 | 77 | $this->name = $name; |
78 | - $this->option_name = 'frm_' . $this->id_base .'_action'; |
|
78 | + $this->option_name = 'frm_' . $this->id_base . '_action'; |
|
79 | 79 | |
80 | 80 | $default_options = array( |
81 | 81 | 'classes' => '', |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @return string Name attribute for $field_name |
110 | 110 | */ |
111 | 111 | public function get_field_name( $field_name, $post_field = 'post_content' ) { |
112 | - return $this->option_name . '[' . $this->number . ']'. ( empty($post_field) ? '' : '['. $post_field .']' ) .'[' . $field_name . ']'; |
|
112 | + return $this->option_name . '[' . $this->number . ']' . ( empty( $post_field ) ? '' : '[' . $post_field . ']' ) . '[' . $field_name . ']'; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * @return string ID attribute for $field_name |
122 | 122 | */ |
123 | 123 | public function get_field_id( $field_name ) { |
124 | - return $field_name .'_'. $this->number; |
|
124 | + return $field_name . '_' . $this->number; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | // Private Function. Don't worry about this. |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | $default_values = $this->get_global_defaults(); |
141 | 141 | |
142 | 142 | // fill default values |
143 | - $post_content = wp_parse_args( $post_content, $default_values); |
|
143 | + $post_content = wp_parse_args( $post_content, $default_values ); |
|
144 | 144 | |
145 | - if ( ! isset($post_content['event']) && ! $this->action_options['force_event'] ) { |
|
146 | - $post_content['event'] = array( reset($this->action_options['event']) ); |
|
145 | + if ( ! isset( $post_content['event'] ) && ! $this->action_options['force_event'] ) { |
|
146 | + $post_content['event'] = array( reset( $this->action_options['event'] ) ); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | $form_action = array( |
@@ -153,10 +153,10 @@ discard block |
||
153 | 153 | 'ID' => '', |
154 | 154 | 'post_status' => 'publish', |
155 | 155 | 'post_type' => FrmFormActionsController::$action_post_type, |
156 | - 'post_name' => $this->form_id .'_'. $this->id_base .'_'. $this->number, |
|
156 | + 'post_name' => $this->form_id . '_' . $this->id_base . '_' . $this->number, |
|
157 | 157 | 'menu_order' => $this->form_id, |
158 | 158 | ); |
159 | - unset($post_content); |
|
159 | + unset( $post_content ); |
|
160 | 160 | |
161 | 161 | return (object) $form_action; |
162 | 162 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | |
167 | 167 | $action = $this->prepare_new(); |
168 | 168 | |
169 | - return $this->save_settings($action); |
|
169 | + return $this->save_settings( $action ); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | public function duplicate_form_actions( $form_id, $old_id ) { |
@@ -180,8 +180,8 @@ discard block |
||
180 | 180 | |
181 | 181 | $this->form_id = $form_id; |
182 | 182 | foreach ( $actions as $action ) { |
183 | - $this->duplicate_one($action, $form_id); |
|
184 | - unset($action); |
|
183 | + $this->duplicate_one( $action, $form_id ); |
|
184 | + unset( $action ); |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
@@ -193,14 +193,14 @@ discard block |
||
193 | 193 | * @return integer $post_id |
194 | 194 | */ |
195 | 195 | public function maybe_create_action( $action, $forms ) { |
196 | - if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && $forms[ $action['menu_order'] ] == 'updated' ) { |
|
196 | + if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && $forms[$action['menu_order']] == 'updated' ) { |
|
197 | 197 | // Update action only |
198 | 198 | $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] ); |
199 | 199 | $post_id = $this->save_settings( $action ); |
200 | 200 | } else { |
201 | 201 | // Create action |
202 | - $action['post_content'] = FrmAppHelper::maybe_json_decode($action['post_content']); |
|
203 | - $post_id = $this->duplicate_one( (object) $action, $action['menu_order']); |
|
202 | + $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] ); |
|
203 | + $post_id = $this->duplicate_one( (object) $action, $action['menu_order'] ); |
|
204 | 204 | } |
205 | 205 | return $post_id; |
206 | 206 | } |
@@ -211,47 +211,47 @@ discard block |
||
211 | 211 | $action->menu_order = $form_id; |
212 | 212 | $switch = $this->get_global_switch_fields(); |
213 | 213 | foreach ( (array) $action->post_content as $key => $val ) { |
214 | - if ( is_numeric( $val ) && isset( $frm_duplicate_ids[ $val ] ) ) { |
|
215 | - $action->post_content[ $key ] = $frm_duplicate_ids[ $val ]; |
|
214 | + if ( is_numeric( $val ) && isset( $frm_duplicate_ids[$val] ) ) { |
|
215 | + $action->post_content[$key] = $frm_duplicate_ids[$val]; |
|
216 | 216 | } else if ( ! is_array( $val ) ) { |
217 | - $action->post_content[ $key ] = FrmFieldsHelper::switch_field_ids( $val ); |
|
218 | - } else if ( isset( $switch[ $key ] ) && is_array( $switch[ $key ] ) ) { |
|
217 | + $action->post_content[$key] = FrmFieldsHelper::switch_field_ids( $val ); |
|
218 | + } else if ( isset( $switch[$key] ) && is_array( $switch[$key] ) ) { |
|
219 | 219 | // loop through each value if empty |
220 | - if ( empty( $switch[ $key ] ) ) { |
|
221 | - $switch[ $key ] = array_keys( $val ); |
|
220 | + if ( empty( $switch[$key] ) ) { |
|
221 | + $switch[$key] = array_keys( $val ); |
|
222 | 222 | } |
223 | 223 | |
224 | - foreach ( $switch[ $key ] as $subkey ) { |
|
225 | - $action->post_content[ $key ] = $this->duplicate_array_walk( $action->post_content[ $key ], $subkey, $val ); |
|
224 | + foreach ( $switch[$key] as $subkey ) { |
|
225 | + $action->post_content[$key] = $this->duplicate_array_walk( $action->post_content[$key], $subkey, $val ); |
|
226 | 226 | } |
227 | 227 | } |
228 | 228 | |
229 | - unset($key, $val); |
|
229 | + unset( $key, $val ); |
|
230 | 230 | } |
231 | - unset($action->ID); |
|
231 | + unset( $action->ID ); |
|
232 | 232 | |
233 | - return $this->save_settings($action); |
|
233 | + return $this->save_settings( $action ); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | private function duplicate_array_walk( $action, $subkey, $val ) { |
237 | 237 | global $frm_duplicate_ids; |
238 | 238 | |
239 | - if ( is_array($subkey) ) { |
|
239 | + if ( is_array( $subkey ) ) { |
|
240 | 240 | foreach ( $subkey as $subkey2 ) { |
241 | 241 | foreach ( (array) $val as $ck => $cv ) { |
242 | - if ( is_array($cv) ) { |
|
243 | - $action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey2, $cv ); |
|
244 | - } else if ( isset( $cv[ $subkey ] ) && is_numeric( $cv[ $subkey ] ) && isset( $frm_duplicate_ids[ $cv[ $subkey ] ] ) ) { |
|
245 | - $action[ $ck ][ $subkey ] = $frm_duplicate_ids[ $cv[ $subkey ] ]; |
|
242 | + if ( is_array( $cv ) ) { |
|
243 | + $action[$ck] = $this->duplicate_array_walk( $action[$ck], $subkey2, $cv ); |
|
244 | + } else if ( isset( $cv[$subkey] ) && is_numeric( $cv[$subkey] ) && isset( $frm_duplicate_ids[$cv[$subkey]] ) ) { |
|
245 | + $action[$ck][$subkey] = $frm_duplicate_ids[$cv[$subkey]]; |
|
246 | 246 | } |
247 | 247 | } |
248 | 248 | } |
249 | 249 | } else { |
250 | 250 | foreach ( (array) $val as $ck => $cv ) { |
251 | - if ( is_array($cv) ) { |
|
252 | - $action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey, $cv ); |
|
253 | - } else if ( $ck == $subkey && isset( $frm_duplicate_ids[ $cv ] ) ) { |
|
254 | - $action[ $ck ] = $frm_duplicate_ids[ $cv ]; |
|
251 | + if ( is_array( $cv ) ) { |
|
252 | + $action[$ck] = $this->duplicate_array_walk( $action[$ck], $subkey, $cv ); |
|
253 | + } else if ( $ck == $subkey && isset( $frm_duplicate_ids[$cv] ) ) { |
|
254 | + $action[$ck] = $frm_duplicate_ids[$cv]; |
|
255 | 255 | } |
256 | 256 | } |
257 | 257 | } |
@@ -275,8 +275,8 @@ discard block |
||
275 | 275 | return; |
276 | 276 | } |
277 | 277 | |
278 | - if ( isset( $_POST[ $this->option_name ] ) && is_array( $_POST[ $this->option_name ] ) ) { |
|
279 | - $settings = $_POST[ $this->option_name ]; |
|
278 | + if ( isset( $_POST[$this->option_name] ) && is_array( $_POST[$this->option_name] ) ) { |
|
279 | + $settings = $_POST[$this->option_name]; |
|
280 | 280 | } else { |
281 | 281 | return; |
282 | 282 | } |
@@ -284,19 +284,19 @@ discard block |
||
284 | 284 | $action_ids = array(); |
285 | 285 | |
286 | 286 | foreach ( $settings as $number => $new_instance ) { |
287 | - $this->_set($number); |
|
287 | + $this->_set( $number ); |
|
288 | 288 | |
289 | - if ( ! isset($new_instance['post_title']) ) { |
|
289 | + if ( ! isset( $new_instance['post_title'] ) ) { |
|
290 | 290 | // settings were never opened, so don't update |
291 | 291 | $action_ids[] = $new_instance['ID']; |
292 | 292 | $this->updated = true; |
293 | 293 | continue; |
294 | 294 | } |
295 | 295 | |
296 | - $old_instance = isset( $all_instances[ $number ] ) ? $all_instances[ $number ] : array(); |
|
296 | + $old_instance = isset( $all_instances[$number] ) ? $all_instances[$number] : array(); |
|
297 | 297 | |
298 | - $new_instance['post_type'] = FrmFormActionsController::$action_post_type; |
|
299 | - $new_instance['post_name'] = $this->form_id .'_'. $this->id_base .'_'. $this->number; |
|
298 | + $new_instance['post_type'] = FrmFormActionsController::$action_post_type; |
|
299 | + $new_instance['post_name'] = $this->form_id . '_' . $this->id_base . '_' . $this->number; |
|
300 | 300 | $new_instance['menu_order'] = $this->form_id; |
301 | 301 | $new_instance['post_status'] = 'publish'; |
302 | 302 | $new_instance['post_date'] = isset( $old_instance->post_date ) ? $old_instance->post_date : ''; |
@@ -318,14 +318,14 @@ discard block |
||
318 | 318 | */ |
319 | 319 | $instance = apply_filters( 'frm_action_update_callback', $instance, $new_instance, $old_instance, $this ); |
320 | 320 | |
321 | - $instance['post_content'] = apply_filters('frm_before_save_action', $instance['post_content'], $instance, $new_instance, $old_instance, $this); |
|
322 | - $instance['post_content'] = apply_filters('frm_before_save_'. $this->id_base .'_action', $new_instance['post_content'], $instance, $new_instance, $old_instance, $this); |
|
321 | + $instance['post_content'] = apply_filters( 'frm_before_save_action', $instance['post_content'], $instance, $new_instance, $old_instance, $this ); |
|
322 | + $instance['post_content'] = apply_filters( 'frm_before_save_' . $this->id_base . '_action', $new_instance['post_content'], $instance, $new_instance, $old_instance, $this ); |
|
323 | 323 | |
324 | 324 | if ( false !== $instance ) { |
325 | - $all_instances[ $number ] = $instance; |
|
325 | + $all_instances[$number] = $instance; |
|
326 | 326 | } |
327 | 327 | |
328 | - $action_ids[] = $this->save_settings($instance); |
|
328 | + $action_ids[] = $this->save_settings( $instance ); |
|
329 | 329 | |
330 | 330 | $this->updated = true; |
331 | 331 | } |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | } |
339 | 339 | |
340 | 340 | public function get_single_action( $id ) { |
341 | - $action = get_post($id); |
|
341 | + $action = get_post( $id ); |
|
342 | 342 | if ( $action ) { |
343 | 343 | $action = $this->prepare_action( $action ); |
344 | 344 | $this->_set( $id ); |
@@ -347,12 +347,12 @@ discard block |
||
347 | 347 | } |
348 | 348 | |
349 | 349 | public function get_one( $form_id ) { |
350 | - return $this->get_all($form_id, 1); |
|
350 | + return $this->get_all( $form_id, 1 ); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | public static function get_action_for_form( $form_id, $type = 'all', $limit = 99 ) { |
354 | 354 | $action_controls = FrmFormActionsController::get_form_actions( $type ); |
355 | - if ( empty($action_controls) ) { |
|
355 | + if ( empty( $action_controls ) ) { |
|
356 | 356 | // don't continue if there are no available actions |
357 | 357 | return array(); |
358 | 358 | } |
@@ -373,12 +373,12 @@ discard block |
||
373 | 373 | // some plugins/themes are formatting the post_excerpt |
374 | 374 | $action->post_excerpt = sanitize_title( $action->post_excerpt ); |
375 | 375 | |
376 | - if ( ! isset( $action_controls[ $action->post_excerpt ] ) ) { |
|
376 | + if ( ! isset( $action_controls[$action->post_excerpt] ) ) { |
|
377 | 377 | continue; |
378 | 378 | } |
379 | 379 | |
380 | - $action = $action_controls[ $action->post_excerpt ]->prepare_action( $action ); |
|
381 | - $settings[ $action->ID ] = $action; |
|
380 | + $action = $action_controls[$action->post_excerpt]->prepare_action( $action ); |
|
381 | + $settings[$action->ID] = $action; |
|
382 | 382 | |
383 | 383 | if ( count( $settings ) >= $limit ) { |
384 | 384 | break; |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | } |
387 | 387 | |
388 | 388 | if ( 1 === $limit ) { |
389 | - $settings = reset($settings); |
|
389 | + $settings = reset( $settings ); |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | return $settings; |
@@ -402,33 +402,33 @@ discard block |
||
402 | 402 | global $frm_vars; |
403 | 403 | $frm_vars['action_type'] = $type; |
404 | 404 | |
405 | - add_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' ); |
|
405 | + add_filter( 'posts_where', 'FrmFormActionsController::limit_by_type' ); |
|
406 | 406 | $query = self::action_args( $form_id, $limit ); |
407 | 407 | $query['post_status'] = 'any'; |
408 | 408 | $query['suppress_filters'] = false; |
409 | 409 | |
410 | 410 | $actions = FrmAppHelper::check_cache( serialize( $query ) . '_type_' . $type, 'frm_actions', $query, 'get_posts' ); |
411 | - unset($query); |
|
411 | + unset( $query ); |
|
412 | 412 | |
413 | - remove_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' ); |
|
413 | + remove_filter( 'posts_where', 'FrmFormActionsController::limit_by_type' ); |
|
414 | 414 | |
415 | - if ( empty($actions) ) { |
|
415 | + if ( empty( $actions ) ) { |
|
416 | 416 | return array(); |
417 | 417 | } |
418 | 418 | |
419 | 419 | $settings = array(); |
420 | 420 | foreach ( $actions as $action ) { |
421 | - if ( count($settings) >= $limit ) { |
|
421 | + if ( count( $settings ) >= $limit ) { |
|
422 | 422 | continue; |
423 | 423 | } |
424 | 424 | |
425 | - $action = $this->prepare_action($action); |
|
425 | + $action = $this->prepare_action( $action ); |
|
426 | 426 | |
427 | - $settings[ $action->ID ] = $action; |
|
427 | + $settings[$action->ID] = $action; |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | if ( 1 === $limit ) { |
431 | - $settings = reset($settings); |
|
431 | + $settings = reset( $settings ); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | return $settings; |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | } |
452 | 452 | |
453 | 453 | public function prepare_action( $action ) { |
454 | - $action->post_content = (array) FrmAppHelper::maybe_json_decode($action->post_content); |
|
454 | + $action->post_content = (array) FrmAppHelper::maybe_json_decode( $action->post_content ); |
|
455 | 455 | $action->post_excerpt = sanitize_title( $action->post_excerpt ); |
456 | 456 | |
457 | 457 | $default_values = $this->get_global_defaults(); |
@@ -460,16 +460,16 @@ discard block |
||
460 | 460 | $action->post_content += $default_values; |
461 | 461 | |
462 | 462 | foreach ( $default_values as $k => $vals ) { |
463 | - if ( is_array($vals) && ! empty($vals) ) { |
|
464 | - if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) { |
|
463 | + if ( is_array( $vals ) && ! empty( $vals ) ) { |
|
464 | + if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[$k] ) ) { |
|
465 | 465 | continue; |
466 | 466 | } |
467 | - $action->post_content[ $k ] = wp_parse_args( $action->post_content[ $k ], $vals ); |
|
467 | + $action->post_content[$k] = wp_parse_args( $action->post_content[$k], $vals ); |
|
468 | 468 | } |
469 | 469 | } |
470 | 470 | |
471 | - if ( ! is_array($action->post_content['event']) ) { |
|
472 | - $action->post_content['event'] = explode(',', $action->post_content['event']); |
|
471 | + if ( ! is_array( $action->post_content['event'] ) ) { |
|
472 | + $action->post_content['event'] = explode( ',', $action->post_content['event'] ); |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | return $action; |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | $post_ids = FrmDb::get_col( $wpdb->posts, $query, 'ID' ); |
492 | 492 | |
493 | 493 | foreach ( $post_ids as $id ) { |
494 | - wp_delete_post($id); |
|
494 | + wp_delete_post( $id ); |
|
495 | 495 | } |
496 | 496 | self::clear_cache(); |
497 | 497 | } |
@@ -512,11 +512,11 @@ discard block |
||
512 | 512 | public function get_global_defaults() { |
513 | 513 | $defaults = $this->get_defaults(); |
514 | 514 | |
515 | - if ( ! isset($defaults['event']) ) { |
|
515 | + if ( ! isset( $defaults['event'] ) ) { |
|
516 | 516 | $defaults['event'] = array( 'create' ); |
517 | 517 | } |
518 | 518 | |
519 | - if ( ! isset($defaults['conditions']) ) { |
|
519 | + if ( ! isset( $defaults['conditions'] ) ) { |
|
520 | 520 | $defaults['conditions'] = array( |
521 | 521 | 'send_stop' => '', |
522 | 522 | 'any_all' => '', |
@@ -536,18 +536,18 @@ discard block |
||
536 | 536 | * Migrate settings from form->options into new action. |
537 | 537 | */ |
538 | 538 | public function migrate_to_2( $form, $update = 'update' ) { |
539 | - $action = $this->prepare_new($form->id); |
|
540 | - $form->options = maybe_unserialize($form->options); |
|
539 | + $action = $this->prepare_new( $form->id ); |
|
540 | + $form->options = maybe_unserialize( $form->options ); |
|
541 | 541 | |
542 | 542 | // fill with existing options |
543 | 543 | foreach ( $action->post_content as $name => $val ) { |
544 | - if ( isset( $form->options[ $name ] ) ) { |
|
545 | - $action->post_content[ $name ] = $form->options[ $name ]; |
|
546 | - unset( $form->options[ $name ] ); |
|
544 | + if ( isset( $form->options[$name] ) ) { |
|
545 | + $action->post_content[$name] = $form->options[$name]; |
|
546 | + unset( $form->options[$name] ); |
|
547 | 547 | } |
548 | 548 | } |
549 | 549 | |
550 | - $action = $this->migrate_values($action, $form); |
|
550 | + $action = $this->migrate_values( $action, $form ); |
|
551 | 551 | |
552 | 552 | // check if action already exists |
553 | 553 | $post_id = get_posts( array( |
@@ -557,18 +557,18 @@ discard block |
||
557 | 557 | 'numberposts' => 1, |
558 | 558 | ) ); |
559 | 559 | |
560 | - if ( empty($post_id) ) { |
|
560 | + if ( empty( $post_id ) ) { |
|
561 | 561 | // create action now |
562 | - $post_id = $this->save_settings($action); |
|
562 | + $post_id = $this->save_settings( $action ); |
|
563 | 563 | } |
564 | 564 | |
565 | 565 | if ( $post_id && 'update' == $update ) { |
566 | 566 | global $wpdb; |
567 | - $form->options = maybe_serialize($form->options); |
|
567 | + $form->options = maybe_serialize( $form->options ); |
|
568 | 568 | |
569 | 569 | // update form options |
570 | 570 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => $form->options ), array( 'id' => $form->id ) ); |
571 | - wp_cache_delete( $form->id, 'frm_form'); |
|
571 | + wp_cache_delete( $form->id, 'frm_form' ); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | return $post_id; |
@@ -592,27 +592,27 @@ discard block |
||
592 | 592 | continue; |
593 | 593 | } |
594 | 594 | |
595 | - if ( is_array($condition['hide_opt']) ) { |
|
596 | - $condition['hide_opt'] = reset($condition['hide_opt']); |
|
595 | + if ( is_array( $condition['hide_opt'] ) ) { |
|
596 | + $condition['hide_opt'] = reset( $condition['hide_opt'] ); |
|
597 | 597 | } |
598 | 598 | |
599 | - $observed_value = isset( $entry->metas[ $condition['hide_field'] ] ) ? $entry->metas[ $condition['hide_field'] ] : ''; |
|
599 | + $observed_value = isset( $entry->metas[$condition['hide_field']] ) ? $entry->metas[$condition['hide_field']] : ''; |
|
600 | 600 | if ( $condition['hide_opt'] == 'current_user' ) { |
601 | 601 | $condition['hide_opt'] = get_current_user_id(); |
602 | 602 | } |
603 | 603 | |
604 | - $stop = FrmFieldsHelper::value_meets_condition($observed_value, $condition['hide_field_cond'], $condition['hide_opt']); |
|
604 | + $stop = FrmFieldsHelper::value_meets_condition( $observed_value, $condition['hide_field_cond'], $condition['hide_opt'] ); |
|
605 | 605 | |
606 | 606 | if ( $notification['conditions']['send_stop'] == 'send' ) { |
607 | 607 | $stop = $stop ? false : true; |
608 | 608 | } |
609 | 609 | |
610 | - $met[ $stop ] = $stop; |
|
610 | + $met[$stop] = $stop; |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | if ( $notification['conditions']['any_all'] == 'all' && ! empty( $met ) && isset( $met[0] ) && isset( $met[1] ) ) { |
614 | - $stop = ($notification['conditions']['send_stop'] == 'send'); |
|
615 | - } else if ( $notification['conditions']['any_all'] == 'any' && $notification['conditions']['send_stop'] == 'send' && isset($met[0]) ) { |
|
614 | + $stop = ( $notification['conditions']['send_stop'] == 'send' ); |
|
615 | + } else if ( $notification['conditions']['any_all'] == 'any' && $notification['conditions']['send_stop'] == 'send' && isset( $met[0] ) ) { |
|
616 | 616 | $stop = false; |
617 | 617 | } |
618 | 618 |
@@ -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 | } |