Completed
Push — master ( 851f89...5cfd55 )
by Stephanie
03:39
created
classes/controllers/FrmFieldsController.php 2 patches
Indentation   +462 added lines, -462 removed lines patch added patch discarded remove patch
@@ -2,137 +2,137 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmFieldsController {
4 4
 
5
-    public static function load_field() {
5
+	public static function load_field() {
6 6
 		FrmAppHelper::permission_check('frm_edit_forms');
7
-        check_ajax_referer( 'frm_ajax', 'nonce' );
7
+		check_ajax_referer( 'frm_ajax', 'nonce' );
8 8
 
9
-        $fields = $_POST['field'];
10
-        if ( empty( $fields ) ) {
11
-            wp_die();
12
-        }
9
+		$fields = $_POST['field'];
10
+		if ( empty( $fields ) ) {
11
+			wp_die();
12
+		}
13 13
 
14
-        $_GET['page'] = 'formidable';
15
-        $fields = stripslashes_deep( $fields );
14
+		$_GET['page'] = 'formidable';
15
+		$fields = stripslashes_deep( $fields );
16 16
 
17
-        $ajax = true;
17
+		$ajax = true;
18 18
 		$values = array( 'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ) );
19
-        $path = FrmAppHelper::plugin_path();
20
-        $field_html = array();
21
-
22
-        foreach ( $fields as $field ) {
23
-            $field = htmlspecialchars_decode( nl2br( $field ) );
24
-            $field = json_decode( $field, true );
25
-            if ( ! isset( $field['id'] ) ) {
26
-                // this field may have already been loaded
27
-                continue;
28
-            }
19
+		$path = FrmAppHelper::plugin_path();
20
+		$field_html = array();
21
+
22
+		foreach ( $fields as $field ) {
23
+			$field = htmlspecialchars_decode( nl2br( $field ) );
24
+			$field = json_decode( $field, true );
25
+			if ( ! isset( $field['id'] ) ) {
26
+				// this field may have already been loaded
27
+				continue;
28
+			}
29 29
 
30
-            $field_id = absint( $field['id'] );
30
+			$field_id = absint( $field['id'] );
31 31
 
32
-            if ( ! isset( $field['value'] ) ) {
33
-                $field['value'] = '';
34
-            }
32
+			if ( ! isset( $field['value'] ) ) {
33
+				$field['value'] = '';
34
+			}
35 35
 
36
-            $field_name = 'item_meta['. $field_id .']';
37
-            $html_id = FrmFieldsHelper::get_html_id($field);
36
+			$field_name = 'item_meta['. $field_id .']';
37
+			$html_id = FrmFieldsHelper::get_html_id($field);
38 38
 
39
-            ob_start();
40
-            include($path .'/classes/views/frm-forms/add_field.php');
41
-            $field_html[ $field_id ] = ob_get_contents();
42
-            ob_end_clean();
43
-        }
39
+			ob_start();
40
+			include($path .'/classes/views/frm-forms/add_field.php');
41
+			$field_html[ $field_id ] = ob_get_contents();
42
+			ob_end_clean();
43
+		}
44 44
 
45
-        unset($path);
45
+		unset($path);
46 46
 
47
-        echo json_encode($field_html);
47
+		echo json_encode($field_html);
48 48
 
49
-        wp_die();
50
-    }
49
+		wp_die();
50
+	}
51 51
 
52
-    public static function create() {
52
+	public static function create() {
53 53
 		FrmAppHelper::permission_check('frm_edit_forms');
54
-        check_ajax_referer( 'frm_ajax', 'nonce' );
54
+		check_ajax_referer( 'frm_ajax', 'nonce' );
55 55
 
56 56
 		$field_type = FrmAppHelper::get_post_param( 'field', '', 'sanitize_text_field' );
57 57
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
58 58
 
59
-        $field = self::include_new_field($field_type, $form_id);
59
+		$field = self::include_new_field($field_type, $form_id);
60 60
 
61
-        // this hook will allow for multiple fields to be added at once
62
-        do_action('frm_after_field_created', $field, $form_id);
61
+		// this hook will allow for multiple fields to be added at once
62
+		do_action('frm_after_field_created', $field, $form_id);
63 63
 
64
-        wp_die();
65
-    }
64
+		wp_die();
65
+	}
66 66
 
67
-    /**
68
-     * @param integer $form_id
69
-     */
67
+	/**
68
+	 * @param integer $form_id
69
+	 */
70 70
 	public static function include_new_field( $field_type, $form_id ) {
71
-        $values = array();
72
-        if ( FrmAppHelper::pro_is_installed() ) {
73
-            $values['post_type'] = FrmProFormsHelper::post_type($form_id);
74
-        }
71
+		$values = array();
72
+		if ( FrmAppHelper::pro_is_installed() ) {
73
+			$values['post_type'] = FrmProFormsHelper::post_type($form_id);
74
+		}
75 75
 
76
-        $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id));
77
-        $field_id = FrmField::create( $field_values );
76
+		$field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id));
77
+		$field_id = FrmField::create( $field_values );
78 78
 
79
-        if ( ! $field_id ) {
80
-            return false;
81
-        }
79
+		if ( ! $field_id ) {
80
+			return false;
81
+		}
82 82
 
83
-        $field = self::include_single_field($field_id, $values, $form_id);
83
+		$field = self::include_single_field($field_id, $values, $form_id);
84 84
 
85
-        return $field;
86
-    }
85
+		return $field;
86
+	}
87 87
 
88
-    public static function update_form_id() {
88
+	public static function update_form_id() {
89 89
 		FrmAppHelper::permission_check('frm_edit_forms');
90
-        check_ajax_referer( 'frm_ajax', 'nonce' );
90
+		check_ajax_referer( 'frm_ajax', 'nonce' );
91 91
 
92 92
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
93 93
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
94 94
 
95
-        if ( ! $field_id || ! $form_id ) {
96
-            wp_die();
97
-        }
95
+		if ( ! $field_id || ! $form_id ) {
96
+			wp_die();
97
+		}
98 98
 
99 99
 		$updated = FrmField::update( $field_id, compact( 'form_id' ) );
100 100
 		echo absint( $updated );
101 101
 
102
-        wp_die();
103
-    }
102
+		wp_die();
103
+	}
104 104
 
105 105
 	public static function edit_name( $field = 'name', $id = '' ) {
106 106
 		FrmAppHelper::permission_check('frm_edit_forms');
107
-        check_ajax_referer( 'frm_ajax', 'nonce' );
107
+		check_ajax_referer( 'frm_ajax', 'nonce' );
108 108
 
109
-        if ( empty($field) ) {
110
-            $field = 'name';
111
-        }
109
+		if ( empty($field) ) {
110
+			$field = 'name';
111
+		}
112 112
 
113
-        if ( empty($id) ) {
113
+		if ( empty($id) ) {
114 114
 			$id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
115 115
 			$id = str_replace( 'field_label_', '', $id );
116
-        }
116
+		}
117 117
 
118 118
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' );
119 119
 		$value = trim( $value );
120
-        if ( trim(strip_tags($value)) == '' ) {
121
-            // set blank value if there is no content
122
-            $value = '';
123
-        }
120
+		if ( trim(strip_tags($value)) == '' ) {
121
+			// set blank value if there is no content
122
+			$value = '';
123
+		}
124 124
 
125 125
 		FrmField::update( $id, array( $field => $value ) );
126 126
 
127 127
 		do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) );
128 128
 
129 129
 		echo stripslashes( wp_kses_post( $value ) );
130
-        wp_die();
131
-    }
130
+		wp_die();
131
+	}
132 132
 
133
-    public static function update_ajax_option() {
133
+	public static function update_ajax_option() {
134 134
 		FrmAppHelper::permission_check('frm_edit_forms');
135
-        check_ajax_referer( 'frm_ajax', 'nonce' );
135
+		check_ajax_referer( 'frm_ajax', 'nonce' );
136 136
 
137 137
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
138 138
 		if ( ! $field_id ) {
@@ -147,141 +147,141 @@  discard block
 block discarded – undo
147 147
 			unset($new_val);
148 148
 		}
149 149
 
150
-        FrmField::update( $field_id, array(
151
-            'field_options' => $field->field_options,
150
+		FrmField::update( $field_id, array(
151
+			'field_options' => $field->field_options,
152 152
 			'form_id'		=> $field->form_id,
153
-        ) );
154
-        wp_die();
155
-    }
153
+		) );
154
+		wp_die();
155
+	}
156 156
 
157
-    public static function duplicate() {
157
+	public static function duplicate() {
158 158
 		FrmAppHelper::permission_check('frm_edit_forms');
159
-        check_ajax_referer( 'frm_ajax', 'nonce' );
159
+		check_ajax_referer( 'frm_ajax', 'nonce' );
160 160
 
161
-        global $wpdb;
161
+		global $wpdb;
162 162
 
163 163
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
164 164
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
165 165
 
166 166
 		$copy_field = FrmField::getOne( $field_id );
167
-        if ( ! $copy_field ) {
168
-            wp_die();
169
-        }
167
+		if ( ! $copy_field ) {
168
+			wp_die();
169
+		}
170 170
 
171
-        do_action('frm_duplicate_field', $copy_field, $form_id);
172
-        do_action('frm_duplicate_field_'. $copy_field->type, $copy_field, $form_id);
171
+		do_action('frm_duplicate_field', $copy_field, $form_id);
172
+		do_action('frm_duplicate_field_'. $copy_field->type, $copy_field, $form_id);
173 173
 
174
-        $values = array( 'id' => $form_id );
175
-        FrmFieldsHelper::fill_field( $values, $copy_field, $form_id );
174
+		$values = array( 'id' => $form_id );
175
+		FrmFieldsHelper::fill_field( $values, $copy_field, $form_id );
176 176
 
177 177
 		$field_count = FrmDb::get_count( $wpdb->prefix .'frm_fields fi LEFT JOIN '. $wpdb->prefix .'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) );
178 178
 
179
-        $values['field_order'] = $field_count + 1;
179
+		$values['field_order'] = $field_count + 1;
180 180
 
181
-        if ( ! $field_id = FrmField::create($values) ) {
182
-            wp_die();
183
-        }
181
+		if ( ! $field_id = FrmField::create($values) ) {
182
+			wp_die();
183
+		}
184 184
 
185
-        self::include_single_field($field_id, $values);
185
+		self::include_single_field($field_id, $values);
186 186
 
187
-        wp_die();
188
-    }
187
+		wp_die();
188
+	}
189 189
 
190
-    /**
191
-     * Load a single field in the form builder along with all needed variables
192
-     */
193
-    public static function include_single_field( $field_id, $values, $form_id = 0 ) {
194
-        $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
195
-        $field_name = 'item_meta['. $field_id .']';
196
-        $html_id = FrmFieldsHelper::get_html_id($field);
197
-        $id = $form_id ? $form_id : $field['form_id'];
198
-        if ( $field['type'] == 'html' ) {
199
-            $field['stop_filter'] = true;
200
-        }
190
+	/**
191
+	 * Load a single field in the form builder along with all needed variables
192
+	 */
193
+	public static function include_single_field( $field_id, $values, $form_id = 0 ) {
194
+		$field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
195
+		$field_name = 'item_meta['. $field_id .']';
196
+		$html_id = FrmFieldsHelper::get_html_id($field);
197
+		$id = $form_id ? $form_id : $field['form_id'];
198
+		if ( $field['type'] == 'html' ) {
199
+			$field['stop_filter'] = true;
200
+		}
201 201
 
202
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field.php');
202
+		require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field.php');
203 203
 
204
-        return $field;
205
-    }
204
+		return $field;
205
+	}
206 206
 
207
-    public static function destroy() {
207
+	public static function destroy() {
208 208
 		FrmAppHelper::permission_check('frm_edit_forms');
209
-        check_ajax_referer( 'frm_ajax', 'nonce' );
209
+		check_ajax_referer( 'frm_ajax', 'nonce' );
210 210
 
211 211
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
212 212
 		FrmField::destroy( $field_id );
213
-        wp_die();
214
-    }
213
+		wp_die();
214
+	}
215 215
 
216
-    /* Field Options */
216
+	/* Field Options */
217 217
 
218
-    //Add Single Option or Other Option
219
-    public static function add_option() {
218
+	//Add Single Option or Other Option
219
+	public static function add_option() {
220 220
 		FrmAppHelper::permission_check('frm_edit_forms');
221
-        check_ajax_referer( 'frm_ajax', 'nonce' );
221
+		check_ajax_referer( 'frm_ajax', 'nonce' );
222 222
 
223 223
 		$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
224 224
 		$opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
225 225
 
226
-        //Get the field
227
-        $field = FrmField::getOne($id);
226
+		//Get the field
227
+		$field = FrmField::getOne($id);
228 228
 
229 229
 		if ( ! empty( $field->options ) ) {
230 230
 			$keys = array_keys( $field->options );
231
-            $last = str_replace( 'other_', '', end( $keys ) );
232
-        } else {
233
-            $last = 0;
234
-        }
235
-        $opt_key = $last + 1;
231
+			$last = str_replace( 'other_', '', end( $keys ) );
232
+		} else {
233
+			$last = 0;
234
+		}
235
+		$opt_key = $last + 1;
236 236
 
237
-        if ( 'other' == $opt_type ) {
237
+		if ( 'other' == $opt_type ) {
238 238
 			$opt = esc_html__( 'Other', 'formidable' );
239
-            $other_val = '';
240
-            $opt_key = 'other_' . $opt_key;
241
-
242
-            //Update value of "other" in DB
243
-            $field_options = maybe_unserialize( $field->field_options );
244
-            $field_options['other'] = 1;
245
-            FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) );
246
-        } else {
239
+			$other_val = '';
240
+			$opt_key = 'other_' . $opt_key;
241
+
242
+			//Update value of "other" in DB
243
+			$field_options = maybe_unserialize( $field->field_options );
244
+			$field_options['other'] = 1;
245
+			FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) );
246
+		} else {
247 247
 			$first_opt = reset( $field->options );
248 248
 			$next_opt = count( $field->options );
249
-            if ( $first_opt != '' ) {
250
-                $next_opt++;
251
-            }
252
-            $opt = esc_html__( 'Option', 'formidable' ) .' '. $next_opt;
253
-            unset($next_opt);
254
-        }
255
-        $field_val = $opt;
249
+			if ( $first_opt != '' ) {
250
+				$next_opt++;
251
+			}
252
+			$opt = esc_html__( 'Option', 'formidable' ) .' '. $next_opt;
253
+			unset($next_opt);
254
+		}
255
+		$field_val = $opt;
256 256
 		$field->options[ $opt_key ] = $opt;
257 257
 
258
-        //Update options in DB
258
+		//Update options in DB
259 259
 		FrmField::update( $id, array( 'options' => $field->options ) );
260 260
 
261
-        $field_data = $field;
262
-        $field = array(
263
-            'type'  => $field_data->type,
264
-            'id'    => $id,
265
-            'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
266
-            'form_id' => $field_data->form_id,
267
-            'field_key' => $field_data->field_key,
268
-        );
269
-
270
-        $field_name = 'item_meta['. $id .']';
271
-        $html_id = FrmFieldsHelper::get_html_id($field);
272
-        $checked = '';
273
-
274
-        if ( 'other' == $opt_type ) {
275
-            require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php');
276
-        } else {
277
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php');
278
-        }
279
-        wp_die();
280
-    }
281
-
282
-    public static function edit_option() {
261
+		$field_data = $field;
262
+		$field = array(
263
+			'type'  => $field_data->type,
264
+			'id'    => $id,
265
+			'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
266
+			'form_id' => $field_data->form_id,
267
+			'field_key' => $field_data->field_key,
268
+		);
269
+
270
+		$field_name = 'item_meta['. $id .']';
271
+		$html_id = FrmFieldsHelper::get_html_id($field);
272
+		$checked = '';
273
+
274
+		if ( 'other' == $opt_type ) {
275
+			require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php');
276
+		} else {
277
+			require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php');
278
+		}
279
+		wp_die();
280
+	}
281
+
282
+	public static function edit_option() {
283 283
 		FrmAppHelper::permission_check('frm_edit_forms');
284
-        check_ajax_referer( 'frm_ajax', 'nonce' );
284
+		check_ajax_referer( 'frm_ajax', 'nonce' );
285 285
 
286 286
 		$element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
287 287
 		$ids = explode( '-', $element_id );
@@ -289,43 +289,43 @@  discard block
 block discarded – undo
289 289
 
290 290
 		$orig_update_value = $update_value = trim( FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ) );
291 291
 		if ( strpos( $element_id, 'key_' ) ) {
292
-            $new_value = $update_value;
293
-        } else {
294
-            $new_label = $update_value;
295
-        }
292
+			$new_value = $update_value;
293
+		} else {
294
+			$new_label = $update_value;
295
+		}
296 296
 
297
-        $field = FrmField::getOne($id);
298
-        $separate_values = FrmField::is_option_true( $field, 'separate_value' );
297
+		$field = FrmField::getOne($id);
298
+		$separate_values = FrmField::is_option_true( $field, 'separate_value' );
299 299
 
300
-        $this_opt_id = end($ids);
300
+		$this_opt_id = end($ids);
301 301
 		$this_opt = (array) $field->options[ $this_opt_id ];
302 302
 		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false );
303 303
 
304
-        $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
305
-        $value = isset($this_opt['value']) ? $this_opt['value'] : '';
304
+		$label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
305
+		$value = isset($this_opt['value']) ? $this_opt['value'] : '';
306 306
 
307
-        if ( ! isset( $new_label ) ) {
308
-            $new_label = $label;
309
-        }
307
+		if ( ! isset( $new_label ) ) {
308
+			$new_label = $label;
309
+		}
310 310
 
311
-        if ( isset($new_value) || isset($value) ) {
312
-            $update_value = isset($new_value) ? $new_value : $value;
313
-        }
311
+		if ( isset($new_value) || isset($value) ) {
312
+			$update_value = isset($new_value) ? $new_value : $value;
313
+		}
314 314
 
315 315
 		if ( $update_value != $new_label && $other_opt === false && $separate_values ) {
316 316
 			$field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label );
317
-        } else {
317
+		} else {
318 318
 			$field->options[ $this_opt_id ] = $orig_update_value;
319
-        }
319
+		}
320 320
 
321 321
 		FrmField::update( $field->id, array( 'options' => $field->options ) );
322 322
 		echo ( $orig_update_value == '' ) ? esc_html__( '(Blank)', 'formidable' ) : stripslashes( $orig_update_value );
323
-        wp_die();
324
-    }
323
+		wp_die();
324
+	}
325 325
 
326
-    public static function delete_option() {
326
+	public static function delete_option() {
327 327
 		FrmAppHelper::permission_check('frm_edit_forms');
328
-        check_ajax_referer( 'frm_ajax', 'nonce' );
328
+		check_ajax_referer( 'frm_ajax', 'nonce' );
329 329
 
330 330
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
331 331
 		$field = FrmField::getOne( $field_id );
@@ -333,310 +333,310 @@  discard block
 block discarded – undo
333 333
 		$opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' );
334 334
 
335 335
 		$options = $field->options;
336
-        unset( $options[ $opt_key ] );
337
-        $response = array( 'other' => true );
336
+		unset( $options[ $opt_key ] );
337
+		$response = array( 'other' => true );
338 338
 
339
-        //If the deleted option is an "other" option
339
+		//If the deleted option is an "other" option
340 340
 		if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
341
-            //Assume all other options are gone, unless proven otherwise
342
-            $other = false;
341
+			//Assume all other options are gone, unless proven otherwise
342
+			$other = false;
343 343
 
344
-            //Check if all other options are really gone
345
-            foreach ( $options as $o_key => $o_val ) {
346
-                //If there is still an other option in the field, set other to true
344
+			//Check if all other options are really gone
345
+			foreach ( $options as $o_key => $o_val ) {
346
+				//If there is still an other option in the field, set other to true
347 347
 				if ( FrmFieldsHelper::is_other_opt( $o_key ) ) {
348
-                    $other = true;
349
-                    break;
350
-                }
351
-                unset( $o_key, $o_val );
352
-            }
353
-
354
-            //If all other options are gone
355
-            if ( false === $other ) {
356
-                $field_options = maybe_unserialize( $field->field_options );
357
-                $field_options['other'] = 0;
348
+					$other = true;
349
+					break;
350
+				}
351
+				unset( $o_key, $o_val );
352
+			}
353
+
354
+			//If all other options are gone
355
+			if ( false === $other ) {
356
+				$field_options = maybe_unserialize( $field->field_options );
357
+				$field_options['other'] = 0;
358 358
 				FrmField::update( $field_id, array( 'field_options' => maybe_serialize( $field_options ) ) );
359
-                $response = array( 'other' => false );
360
-            }
361
-        }
362
-        echo json_encode( $response );
359
+				$response = array( 'other' => false );
360
+			}
361
+		}
362
+		echo json_encode( $response );
363 363
 
364 364
 		FrmField::update( $field_id, array( 'options' => maybe_serialize( $options ) ) );
365 365
 
366
-        wp_die();
367
-    }
366
+		wp_die();
367
+	}
368 368
 
369
-    public static function import_choices() {
370
-        FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
369
+	public static function import_choices() {
370
+		FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
371 371
 
372 372
 		$field_id = absint( $_REQUEST['field_id'] );
373 373
 
374
-        global $current_screen, $hook_suffix;
374
+		global $current_screen, $hook_suffix;
375 375
 
376
-        // Catch plugins that include admin-header.php before admin.php completes.
377
-        if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
378
-            $hook_suffix = '';
379
-        	set_current_screen();
380
-        }
376
+		// Catch plugins that include admin-header.php before admin.php completes.
377
+		if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
378
+			$hook_suffix = '';
379
+			set_current_screen();
380
+		}
381 381
 
382
-        if ( function_exists( 'register_admin_color_schemes' ) ) {
383
-            register_admin_color_schemes();
384
-        }
382
+		if ( function_exists( 'register_admin_color_schemes' ) ) {
383
+			register_admin_color_schemes();
384
+		}
385 385
 
386
-        $hook_suffix = $admin_body_class = '';
386
+		$hook_suffix = $admin_body_class = '';
387 387
 
388
-        if ( get_user_setting( 'mfold' ) == 'f' ) {
389
-        	$admin_body_class .= ' folded';
390
-        }
388
+		if ( get_user_setting( 'mfold' ) == 'f' ) {
389
+			$admin_body_class .= ' folded';
390
+		}
391 391
 
392
-        if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
393
-        	$admin_body_class .= ' admin-bar';
394
-        }
392
+		if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
393
+			$admin_body_class .= ' admin-bar';
394
+		}
395 395
 
396
-        if ( is_rtl() ) {
397
-        	$admin_body_class .= ' rtl';
398
-        }
396
+		if ( is_rtl() ) {
397
+			$admin_body_class .= ' rtl';
398
+		}
399 399
 
400
-        $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
401
-        $prepop = array();
402
-        FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
400
+		$admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
401
+		$prepop = array();
402
+		FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
403 403
 
404
-        $field = FrmField::getOne($field_id);
404
+		$field = FrmField::getOne($field_id);
405 405
 
406
-        wp_enqueue_script( 'utils' );
407
-        wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css' );
408
-        FrmAppHelper::load_admin_wide_js();
406
+		wp_enqueue_script( 'utils' );
407
+		wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css' );
408
+		FrmAppHelper::load_admin_wide_js();
409 409
 
410
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/import_choices.php');
411
-        wp_die();
412
-    }
410
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/import_choices.php');
411
+		wp_die();
412
+	}
413 413
 
414
-    public static function import_options() {
414
+	public static function import_options() {
415 415
 		FrmAppHelper::permission_check('frm_edit_forms');
416
-        check_ajax_referer( 'frm_ajax', 'nonce' );
416
+		check_ajax_referer( 'frm_ajax', 'nonce' );
417 417
 
418
-        if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
419
-            return;
420
-        }
418
+		if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
419
+			return;
420
+		}
421 421
 
422 422
 		$field_id = absint( $_POST['field_id'] );
423
-        $field = FrmField::getOne($field_id);
423
+		$field = FrmField::getOne($field_id);
424 424
 
425 425
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
426
-            return;
427
-        }
428
-
429
-        $field = FrmFieldsHelper::setup_edit_vars($field);
430
-        $opts = stripslashes_deep($_POST['opts']);
431
-        $opts = explode("\n", rtrim($opts, "\n"));
432
-        if ( $field['separate_value'] ) {
433
-            foreach ( $opts as $opt_key => $opt ) {
434
-                if ( strpos($opt, '|') !== false ) {
435
-                    $vals = explode('|', $opt);
436
-                    if ( $vals[0] != $vals[1] ) {
437
-                        $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
438
-                    }
439
-                    unset($vals);
440
-                }
441
-                unset($opt_key, $opt);
442
-            }
443
-        }
444
-
445
-        //Keep other options after bulk update
446
-        if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
447
-            $other_array = array();
448
-            foreach ( $field['options'] as $opt_key => $opt ) {
449
-                if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
450
-                    $other_array[ $opt_key ] = $opt;
451
-                }
452
-                unset($opt_key, $opt);
453
-            }
454
-            if ( ! empty($other_array) ) {
455
-                $opts = array_merge( $opts, $other_array);
456
-            }
457
-        }
458
-
459
-        FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) );
460
-
461
-        $field['options'] = $opts;
462
-        $field_name = $field['name'];
463
-
464
-        // Get html_id which will be used in single-option.php
465
-        $html_id = FrmFieldsHelper::get_html_id( $field );
466
-
467
-        if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
468
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/radio.php');
469
-        } else {
470
-            FrmFieldsHelper::show_single_option($field);
471
-        }
472
-
473
-        wp_die();
474
-    }
475
-
476
-    public static function update_order() {
426
+			return;
427
+		}
428
+
429
+		$field = FrmFieldsHelper::setup_edit_vars($field);
430
+		$opts = stripslashes_deep($_POST['opts']);
431
+		$opts = explode("\n", rtrim($opts, "\n"));
432
+		if ( $field['separate_value'] ) {
433
+			foreach ( $opts as $opt_key => $opt ) {
434
+				if ( strpos($opt, '|') !== false ) {
435
+					$vals = explode('|', $opt);
436
+					if ( $vals[0] != $vals[1] ) {
437
+						$opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
438
+					}
439
+					unset($vals);
440
+				}
441
+				unset($opt_key, $opt);
442
+			}
443
+		}
444
+
445
+		//Keep other options after bulk update
446
+		if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
447
+			$other_array = array();
448
+			foreach ( $field['options'] as $opt_key => $opt ) {
449
+				if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
450
+					$other_array[ $opt_key ] = $opt;
451
+				}
452
+				unset($opt_key, $opt);
453
+			}
454
+			if ( ! empty($other_array) ) {
455
+				$opts = array_merge( $opts, $other_array);
456
+			}
457
+		}
458
+
459
+		FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) );
460
+
461
+		$field['options'] = $opts;
462
+		$field_name = $field['name'];
463
+
464
+		// Get html_id which will be used in single-option.php
465
+		$html_id = FrmFieldsHelper::get_html_id( $field );
466
+
467
+		if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
468
+			require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/radio.php');
469
+		} else {
470
+			FrmFieldsHelper::show_single_option($field);
471
+		}
472
+
473
+		wp_die();
474
+	}
475
+
476
+	public static function update_order() {
477 477
 		FrmAppHelper::permission_check('frm_edit_forms');
478
-        check_ajax_referer( 'frm_ajax', 'nonce' );
478
+		check_ajax_referer( 'frm_ajax', 'nonce' );
479 479
 
480 480
 		$fields = FrmAppHelper::get_post_param( 'frm_field_id' );
481 481
 		foreach ( (array) $fields as $position => $item ) {
482 482
 			FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) );
483 483
 		}
484
-        wp_die();
485
-    }
484
+		wp_die();
485
+	}
486 486
 
487 487
 	public static function change_type( $type ) {
488
-        $type_switch = array(
489
-            'scale'     => 'radio',
490
-            '10radio'   => 'radio',
491
-            'rte'       => 'textarea',
492
-            'website'   => 'url',
493
-        );
494
-        if ( isset( $type_switch[ $type ] ) ) {
495
-            $type = $type_switch[ $type ];
496
-        }
488
+		$type_switch = array(
489
+			'scale'     => 'radio',
490
+			'10radio'   => 'radio',
491
+			'rte'       => 'textarea',
492
+			'website'   => 'url',
493
+		);
494
+		if ( isset( $type_switch[ $type ] ) ) {
495
+			$type = $type_switch[ $type ];
496
+		}
497 497
 
498 498
 		$frm_field_selection = FrmField::field_selection();
499
-        $types = array_keys($frm_field_selection);
500
-        if ( ! in_array($type, $types) && $type != 'captcha' ) {
501
-            $type = 'text';
502
-        }
499
+		$types = array_keys($frm_field_selection);
500
+		if ( ! in_array($type, $types) && $type != 'captcha' ) {
501
+			$type = 'text';
502
+		}
503 503
 
504
-        return $type;
505
-    }
504
+		return $type;
505
+	}
506 506
 
507 507
 	public static function display_field_options( $display ) {
508 508
 		switch ( $display['type'] ) {
509
-            case 'captcha':
510
-                $display['required'] = false;
511
-                $display['invalid'] = true;
512
-                $display['default_blank'] = false;
509
+			case 'captcha':
510
+				$display['required'] = false;
511
+				$display['invalid'] = true;
512
+				$display['default_blank'] = false;
513 513
 				$display['captcha_size'] = true;
514
-            break;
515
-            case 'radio':
516
-                $display['default_blank'] = false;
517
-            break;
518
-            case 'text':
519
-            case 'textarea':
520
-                $display['size'] = true;
521
-                $display['clear_on_focus'] = true;
522
-            break;
523
-            case 'select':
524
-                $display['size'] = true;
525
-            break;
526
-            case 'url':
527
-            case 'website':
528
-            case 'email':
529
-                $display['size'] = true;
530
-                $display['clear_on_focus'] = true;
531
-                $display['invalid'] = true;
532
-        }
533
-
534
-        return $display;
535
-    }
536
-
537
-    public static function input_html( $field, $echo = true ) {
538
-        $class = array(); //$field['type'];
539
-        self::add_input_classes($field, $class);
540
-
541
-        $add_html = array();
542
-        self::add_html_size($field, $add_html);
543
-        self::add_html_length($field, $add_html);
544
-        self::add_html_placeholder($field, $add_html, $class);
514
+			break;
515
+			case 'radio':
516
+				$display['default_blank'] = false;
517
+			break;
518
+			case 'text':
519
+			case 'textarea':
520
+				$display['size'] = true;
521
+				$display['clear_on_focus'] = true;
522
+			break;
523
+			case 'select':
524
+				$display['size'] = true;
525
+			break;
526
+			case 'url':
527
+			case 'website':
528
+			case 'email':
529
+				$display['size'] = true;
530
+				$display['clear_on_focus'] = true;
531
+				$display['invalid'] = true;
532
+		}
533
+
534
+		return $display;
535
+	}
536
+
537
+	public static function input_html( $field, $echo = true ) {
538
+		$class = array(); //$field['type'];
539
+		self::add_input_classes($field, $class);
540
+
541
+		$add_html = array();
542
+		self::add_html_size($field, $add_html);
543
+		self::add_html_length($field, $add_html);
544
+		self::add_html_placeholder($field, $add_html, $class);
545 545
 		self::add_validation_messages( $field, $add_html );
546 546
 
547
-        $class = apply_filters('frm_field_classes', implode(' ', $class), $field);
547
+		$class = apply_filters('frm_field_classes', implode(' ', $class), $field);
548 548
 
549 549
 		FrmFormsHelper::add_html_attr( $class, 'class', $add_html );
550 550
 
551
-        self::add_shortcodes_to_html($field, $add_html);
551
+		self::add_shortcodes_to_html($field, $add_html);
552 552
 
553 553
 		$add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
554 554
 		$add_html = ' ' . implode( ' ', $add_html ) . '  ';
555 555
 
556
-        if ( $echo ) {
557
-            echo $add_html;
558
-        }
556
+		if ( $echo ) {
557
+			echo $add_html;
558
+		}
559 559
 
560
-        return $add_html;
561
-    }
560
+		return $add_html;
561
+	}
562 562
 
563 563
 	private static function add_input_classes( $field, array &$class ) {
564
-        if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
565
-            $class[] = $field['input_class'];
566
-        }
564
+		if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
565
+			$class[] = $field['input_class'];
566
+		}
567 567
 
568
-        if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
569
-            return;
570
-        }
568
+		if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
569
+			return;
570
+		}
571 571
 
572
-        global $frm_vars;
572
+		global $frm_vars;
573 573
 		if ( is_admin() && ! FrmAppHelper::is_preview_page() && ! in_array( $field['type'], array( 'scale', 'radio', 'checkbox', 'data' ) ) ) {
574
-            $class[] = 'dyn_default_value';
575
-        }
574
+			$class[] = 'dyn_default_value';
575
+		}
576 576
 
577
-        if ( isset($field['size']) && $field['size'] > 0 ) {
578
-            $class[] = 'auto_width';
579
-        }
580
-    }
577
+		if ( isset($field['size']) && $field['size'] > 0 ) {
578
+			$class[] = 'auto_width';
579
+		}
580
+	}
581 581
 
582 582
 	private static function add_html_size( $field, array &$add_html ) {
583 583
 		if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden' ) ) ) {
584
-            return;
585
-        }
584
+			return;
585
+		}
586 586
 
587
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
588
-            return;
589
-        }
587
+		if ( FrmAppHelper::is_admin_page('formidable' ) ) {
588
+			return;
589
+		}
590 590
 
591
-        if ( is_numeric($field['size']) ) {
592
-            $field['size'] .= 'px';
593
-        }
591
+		if ( is_numeric($field['size']) ) {
592
+			$field['size'] .= 'px';
593
+		}
594 594
 
595
-        $important = apply_filters('frm_use_important_width', 1, $field);
596
-        // Note: This inline styling must stay since we cannot realistically set a class for every possible field size
597
-        $add_html['style'] = 'style="width:'. esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) .'"';
595
+		$important = apply_filters('frm_use_important_width', 1, $field);
596
+		// Note: This inline styling must stay since we cannot realistically set a class for every possible field size
597
+		$add_html['style'] = 'style="width:'. esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) .'"';
598 598
 
599
-        self::add_html_cols($field, $add_html);
600
-    }
599
+		self::add_html_cols($field, $add_html);
600
+	}
601 601
 
602 602
 	private static function add_html_cols( $field, array &$add_html ) {
603 603
 		if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) {
604
-            return;
605
-        }
604
+			return;
605
+		}
606 606
 
607
-        // convert to cols for textareas
608
-        $calc = array(
609
-            ''      => 9,
610
-            'px'    => 9,
611
-            'rem'   => 0.444,
612
-            'em'    => 0.544,
613
-        );
607
+		// convert to cols for textareas
608
+		$calc = array(
609
+			''      => 9,
610
+			'px'    => 9,
611
+			'rem'   => 0.444,
612
+			'em'    => 0.544,
613
+		);
614 614
 
615
-        // include "col" for valid html
616
-        $unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
615
+		// include "col" for valid html
616
+		$unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
617 617
 
618
-        if ( ! isset( $calc[ $unit ] ) ) {
619
-            return;
620
-        }
618
+		if ( ! isset( $calc[ $unit ] ) ) {
619
+			return;
620
+		}
621 621
 
622
-        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
622
+		$size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
623 623
 
624 624
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
625
-    }
625
+	}
626 626
 
627 627
 	private static function add_html_length( $field, array &$add_html ) {
628
-        // check for max setting and if this field accepts maxlength
628
+		// check for max setting and if this field accepts maxlength
629 629
 		if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden' ) ) ) {
630
-            return;
631
-        }
630
+			return;
631
+		}
632 632
 
633
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
634
-            // don't load on form builder page
635
-            return;
636
-        }
633
+		if ( FrmAppHelper::is_admin_page('formidable' ) ) {
634
+			// don't load on form builder page
635
+			return;
636
+		}
637 637
 
638 638
 		$add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"';
639
-    }
639
+	}
640 640
 
641 641
 	private static function add_html_placeholder( $field, array &$add_html, array &$class ) {
642 642
 		if ( empty( $field['default_value'] ) || FrmAppHelper::is_admin_page( 'formidable' ) ) {
@@ -644,35 +644,35 @@  discard block
 block discarded – undo
644 644
 		}
645 645
 
646 646
 		$default_value_array = is_array( $field['default_value'] );
647
-        if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
647
+		if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
648 648
 			if ( $default_value_array ) {
649 649
 				$field['default_value'] = json_encode( $field['default_value'] );
650 650
 			}
651 651
 			$add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"';
652
-            return;
653
-        }
652
+			return;
653
+		}
654 654
 
655 655
 		if ( $default_value_array ) {
656 656
 			// don't include a json placeholder
657 657
 			return;
658 658
 		}
659 659
 
660
-        $frm_settings = FrmAppHelper::get_settings();
660
+		$frm_settings = FrmAppHelper::get_settings();
661 661
 
662 662
 		if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) {
663
-            // use HMTL5 placeholder with js fallback
664
-            $add_html['placeholder'] = 'placeholder="'. esc_attr($field['default_value']) .'"';
665
-            wp_enqueue_script('jquery-placeholder');
666
-        } else if ( ! $frm_settings->use_html ) {
663
+			// use HMTL5 placeholder with js fallback
664
+			$add_html['placeholder'] = 'placeholder="'. esc_attr($field['default_value']) .'"';
665
+			wp_enqueue_script('jquery-placeholder');
666
+		} else if ( ! $frm_settings->use_html ) {
667 667
 			$val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( '&#039;', "'", esc_attr( $field['default_value'] ) ) ) );
668
-            $add_html['data-frmval'] = 'data-frmval="'. esc_attr($val) .'"';
669
-            $class[] = 'frm_toggle_default';
668
+			$add_html['data-frmval'] = 'data-frmval="'. esc_attr($val) .'"';
669
+			$class[] = 'frm_toggle_default';
670 670
 
671
-            if ( $field['value'] == $field['default_value'] ) {
672
-                $class[] = 'frm_default';
673
-            }
674
-        }
675
-    }
671
+			if ( $field['value'] == $field['default_value'] ) {
672
+				$class[] = 'frm_default';
673
+			}
674
+		}
675
+	}
676 676
 
677 677
 	private static function add_validation_messages( $field, array &$add_html ) {
678 678
 		if ( FrmField::is_required( $field ) ) {
@@ -693,44 +693,44 @@  discard block
 block discarded – undo
693 693
 		}
694 694
 	}
695 695
 
696
-    private static function add_shortcodes_to_html( $field, array &$add_html ) {
697
-        if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
698
-            return;
699
-        }
700
-
701
-        foreach ( $field['shortcodes'] as $k => $v ) {
702
-            if ( 'opt' === $k ) {
703
-                continue;
704
-            }
705
-
706
-            if ( is_numeric($k) && strpos($v, '=') ) {
707
-                $add_html[] = $v;
708
-            } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
709
-                $add_html[ $k ] = str_replace( $k .'="', $k .'="'. $v, $add_html[ $k ] );
710
-            } else {
696
+	private static function add_shortcodes_to_html( $field, array &$add_html ) {
697
+		if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
698
+			return;
699
+		}
700
+
701
+		foreach ( $field['shortcodes'] as $k => $v ) {
702
+			if ( 'opt' === $k ) {
703
+				continue;
704
+			}
705
+
706
+			if ( is_numeric($k) && strpos($v, '=') ) {
707
+				$add_html[] = $v;
708
+			} else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
709
+				$add_html[ $k ] = str_replace( $k .'="', $k .'="'. $v, $add_html[ $k ] );
710
+			} else {
711 711
 				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
712
-            }
713
-
714
-            unset($k, $v);
715
-        }
716
-    }
717
-
718
-    public static function check_value( $opt, $opt_key, $field ) {
719
-        if ( is_array( $opt ) ) {
720
-            if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
721
-                $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
722
-            } else {
723
-                $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
724
-            }
725
-        }
726
-        return $opt;
727
-    }
712
+			}
713
+
714
+			unset($k, $v);
715
+		}
716
+	}
717
+
718
+	public static function check_value( $opt, $opt_key, $field ) {
719
+		if ( is_array( $opt ) ) {
720
+			if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
721
+				$opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
722
+			} else {
723
+				$opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
724
+			}
725
+		}
726
+		return $opt;
727
+	}
728 728
 
729 729
 	public static function check_label( $opt ) {
730
-        if ( is_array($opt) ) {
731
-            $opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
732
-        }
730
+		if ( is_array($opt) ) {
731
+			$opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
732
+		}
733 733
 
734
-        return $opt;
735
-    }
734
+		return $opt;
735
+	}
736 736
 }
Please login to merge, or discard this patch.
Spacing   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 class FrmFieldsController {
4 4
 
5 5
     public static function load_field() {
6
-		FrmAppHelper::permission_check('frm_edit_forms');
6
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
7 7
         check_ajax_referer( 'frm_ajax', 'nonce' );
8 8
 
9 9
         $fields = $_POST['field'];
@@ -33,33 +33,33 @@  discard block
 block discarded – undo
33 33
                 $field['value'] = '';
34 34
             }
35 35
 
36
-            $field_name = 'item_meta['. $field_id .']';
37
-            $html_id = FrmFieldsHelper::get_html_id($field);
36
+            $field_name = 'item_meta[' . $field_id . ']';
37
+            $html_id = FrmFieldsHelper::get_html_id( $field );
38 38
 
39 39
             ob_start();
40
-            include($path .'/classes/views/frm-forms/add_field.php');
41
-            $field_html[ $field_id ] = ob_get_contents();
40
+            include( $path . '/classes/views/frm-forms/add_field.php' );
41
+            $field_html[$field_id] = ob_get_contents();
42 42
             ob_end_clean();
43 43
         }
44 44
 
45
-        unset($path);
45
+        unset( $path );
46 46
 
47
-        echo json_encode($field_html);
47
+        echo json_encode( $field_html );
48 48
 
49 49
         wp_die();
50 50
     }
51 51
 
52 52
     public static function create() {
53
-		FrmAppHelper::permission_check('frm_edit_forms');
53
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
54 54
         check_ajax_referer( 'frm_ajax', 'nonce' );
55 55
 
56 56
 		$field_type = FrmAppHelper::get_post_param( 'field', '', 'sanitize_text_field' );
57 57
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
58 58
 
59
-        $field = self::include_new_field($field_type, $form_id);
59
+        $field = self::include_new_field( $field_type, $form_id );
60 60
 
61 61
         // this hook will allow for multiple fields to be added at once
62
-        do_action('frm_after_field_created', $field, $form_id);
62
+        do_action( 'frm_after_field_created', $field, $form_id );
63 63
 
64 64
         wp_die();
65 65
     }
@@ -70,23 +70,23 @@  discard block
 block discarded – undo
70 70
 	public static function include_new_field( $field_type, $form_id ) {
71 71
         $values = array();
72 72
         if ( FrmAppHelper::pro_is_installed() ) {
73
-            $values['post_type'] = FrmProFormsHelper::post_type($form_id);
73
+            $values['post_type'] = FrmProFormsHelper::post_type( $form_id );
74 74
         }
75 75
 
76
-        $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id));
76
+        $field_values = apply_filters( 'frm_before_field_created', FrmFieldsHelper::setup_new_vars( $field_type, $form_id ) );
77 77
         $field_id = FrmField::create( $field_values );
78 78
 
79 79
         if ( ! $field_id ) {
80 80
             return false;
81 81
         }
82 82
 
83
-        $field = self::include_single_field($field_id, $values, $form_id);
83
+        $field = self::include_single_field( $field_id, $values, $form_id );
84 84
 
85 85
         return $field;
86 86
     }
87 87
 
88 88
     public static function update_form_id() {
89
-		FrmAppHelper::permission_check('frm_edit_forms');
89
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
90 90
         check_ajax_referer( 'frm_ajax', 'nonce' );
91 91
 
92 92
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
@@ -103,21 +103,21 @@  discard block
 block discarded – undo
103 103
     }
104 104
 
105 105
 	public static function edit_name( $field = 'name', $id = '' ) {
106
-		FrmAppHelper::permission_check('frm_edit_forms');
106
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
107 107
         check_ajax_referer( 'frm_ajax', 'nonce' );
108 108
 
109
-        if ( empty($field) ) {
109
+        if ( empty( $field ) ) {
110 110
             $field = 'name';
111 111
         }
112 112
 
113
-        if ( empty($id) ) {
113
+        if ( empty( $id ) ) {
114 114
 			$id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
115 115
 			$id = str_replace( 'field_label_', '', $id );
116 116
         }
117 117
 
118 118
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' );
119 119
 		$value = trim( $value );
120
-        if ( trim(strip_tags($value)) == '' ) {
120
+        if ( trim( strip_tags( $value ) ) == '' ) {
121 121
             // set blank value if there is no content
122 122
             $value = '';
123 123
         }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     }
132 132
 
133 133
     public static function update_ajax_option() {
134
-		FrmAppHelper::permission_check('frm_edit_forms');
134
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
135 135
         check_ajax_referer( 'frm_ajax', 'nonce' );
136 136
 
137 137
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 		if ( isset( $_POST['separate_value'] ) ) {
145 145
 			$new_val = FrmField::is_option_true( $field, 'separate_value' ) ? 0 : 1;
146 146
 			$field->field_options['separate_value'] = $new_val;
147
-			unset($new_val);
147
+			unset( $new_val );
148 148
 		}
149 149
 
150 150
         FrmField::update( $field_id, array(
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
     }
156 156
 
157 157
     public static function duplicate() {
158
-		FrmAppHelper::permission_check('frm_edit_forms');
158
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
159 159
         check_ajax_referer( 'frm_ajax', 'nonce' );
160 160
 
161 161
         global $wpdb;
@@ -168,21 +168,21 @@  discard block
 block discarded – undo
168 168
             wp_die();
169 169
         }
170 170
 
171
-        do_action('frm_duplicate_field', $copy_field, $form_id);
172
-        do_action('frm_duplicate_field_'. $copy_field->type, $copy_field, $form_id);
171
+        do_action( 'frm_duplicate_field', $copy_field, $form_id );
172
+        do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id );
173 173
 
174 174
         $values = array( 'id' => $form_id );
175 175
         FrmFieldsHelper::fill_field( $values, $copy_field, $form_id );
176 176
 
177
-		$field_count = FrmDb::get_count( $wpdb->prefix .'frm_fields fi LEFT JOIN '. $wpdb->prefix .'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) );
177
+		$field_count = FrmDb::get_count( $wpdb->prefix . 'frm_fields fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) );
178 178
 
179 179
         $values['field_order'] = $field_count + 1;
180 180
 
181
-        if ( ! $field_id = FrmField::create($values) ) {
181
+        if ( ! $field_id = FrmField::create( $values ) ) {
182 182
             wp_die();
183 183
         }
184 184
 
185
-        self::include_single_field($field_id, $values);
185
+        self::include_single_field( $field_id, $values );
186 186
 
187 187
         wp_die();
188 188
     }
@@ -191,21 +191,21 @@  discard block
 block discarded – undo
191 191
      * Load a single field in the form builder along with all needed variables
192 192
      */
193 193
     public static function include_single_field( $field_id, $values, $form_id = 0 ) {
194
-        $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
195
-        $field_name = 'item_meta['. $field_id .']';
196
-        $html_id = FrmFieldsHelper::get_html_id($field);
194
+        $field = FrmFieldsHelper::setup_edit_vars( FrmField::getOne( $field_id ) );
195
+        $field_name = 'item_meta[' . $field_id . ']';
196
+        $html_id = FrmFieldsHelper::get_html_id( $field );
197 197
         $id = $form_id ? $form_id : $field['form_id'];
198 198
         if ( $field['type'] == 'html' ) {
199 199
             $field['stop_filter'] = true;
200 200
         }
201 201
 
202
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field.php');
202
+        require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' );
203 203
 
204 204
         return $field;
205 205
     }
206 206
 
207 207
     public static function destroy() {
208
-		FrmAppHelper::permission_check('frm_edit_forms');
208
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
209 209
         check_ajax_referer( 'frm_ajax', 'nonce' );
210 210
 
211 211
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
@@ -217,14 +217,14 @@  discard block
 block discarded – undo
217 217
 
218 218
     //Add Single Option or Other Option
219 219
     public static function add_option() {
220
-		FrmAppHelper::permission_check('frm_edit_forms');
220
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
221 221
         check_ajax_referer( 'frm_ajax', 'nonce' );
222 222
 
223 223
 		$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
224 224
 		$opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
225 225
 
226 226
         //Get the field
227
-        $field = FrmField::getOne($id);
227
+        $field = FrmField::getOne( $id );
228 228
 
229 229
 		if ( ! empty( $field->options ) ) {
230 230
 			$keys = array_keys( $field->options );
@@ -247,13 +247,13 @@  discard block
 block discarded – undo
247 247
 			$first_opt = reset( $field->options );
248 248
 			$next_opt = count( $field->options );
249 249
             if ( $first_opt != '' ) {
250
-                $next_opt++;
250
+                $next_opt ++;
251 251
             }
252
-            $opt = esc_html__( 'Option', 'formidable' ) .' '. $next_opt;
253
-            unset($next_opt);
252
+            $opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt;
253
+            unset( $next_opt );
254 254
         }
255 255
         $field_val = $opt;
256
-		$field->options[ $opt_key ] = $opt;
256
+		$field->options[$opt_key] = $opt;
257 257
 
258 258
         //Update options in DB
259 259
 		FrmField::update( $id, array( 'options' => $field->options ) );
@@ -262,25 +262,25 @@  discard block
 block discarded – undo
262 262
         $field = array(
263 263
             'type'  => $field_data->type,
264 264
             'id'    => $id,
265
-            'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
265
+            'separate_value' => isset( $field_data->field_options['separate_value'] ) ? $field_data->field_options['separate_value'] : 0,
266 266
             'form_id' => $field_data->form_id,
267 267
             'field_key' => $field_data->field_key,
268 268
         );
269 269
 
270
-        $field_name = 'item_meta['. $id .']';
271
-        $html_id = FrmFieldsHelper::get_html_id($field);
270
+        $field_name = 'item_meta[' . $id . ']';
271
+        $html_id = FrmFieldsHelper::get_html_id( $field );
272 272
         $checked = '';
273 273
 
274 274
         if ( 'other' == $opt_type ) {
275
-            require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php');
275
+            require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' );
276 276
         } else {
277
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php');
277
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
278 278
         }
279 279
         wp_die();
280 280
     }
281 281
 
282 282
     public static function edit_option() {
283
-		FrmAppHelper::permission_check('frm_edit_forms');
283
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
284 284
         check_ajax_referer( 'frm_ajax', 'nonce' );
285 285
 
286 286
 		$element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
@@ -294,28 +294,28 @@  discard block
 block discarded – undo
294 294
             $new_label = $update_value;
295 295
         }
296 296
 
297
-        $field = FrmField::getOne($id);
297
+        $field = FrmField::getOne( $id );
298 298
         $separate_values = FrmField::is_option_true( $field, 'separate_value' );
299 299
 
300
-        $this_opt_id = end($ids);
301
-		$this_opt = (array) $field->options[ $this_opt_id ];
302
-		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false );
300
+        $this_opt_id = end( $ids );
301
+		$this_opt = (array) $field->options[$this_opt_id];
302
+		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other' ) !== false );
303 303
 
304
-        $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
305
-        $value = isset($this_opt['value']) ? $this_opt['value'] : '';
304
+        $label = isset( $this_opt['label'] ) ? $this_opt['label'] : reset( $this_opt );
305
+        $value = isset( $this_opt['value'] ) ? $this_opt['value'] : '';
306 306
 
307 307
         if ( ! isset( $new_label ) ) {
308 308
             $new_label = $label;
309 309
         }
310 310
 
311
-        if ( isset($new_value) || isset($value) ) {
312
-            $update_value = isset($new_value) ? $new_value : $value;
311
+        if ( isset( $new_value ) || isset( $value ) ) {
312
+            $update_value = isset( $new_value ) ? $new_value : $value;
313 313
         }
314 314
 
315 315
 		if ( $update_value != $new_label && $other_opt === false && $separate_values ) {
316
-			$field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label );
316
+			$field->options[$this_opt_id] = array( 'value' => $update_value, 'label' => $new_label );
317 317
         } else {
318
-			$field->options[ $this_opt_id ] = $orig_update_value;
318
+			$field->options[$this_opt_id] = $orig_update_value;
319 319
         }
320 320
 
321 321
 		FrmField::update( $field->id, array( 'options' => $field->options ) );
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
     }
325 325
 
326 326
     public static function delete_option() {
327
-		FrmAppHelper::permission_check('frm_edit_forms');
327
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
328 328
         check_ajax_referer( 'frm_ajax', 'nonce' );
329 329
 
330 330
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 		$opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' );
334 334
 
335 335
 		$options = $field->options;
336
-        unset( $options[ $opt_key ] );
336
+        unset( $options[$opt_key] );
337 337
         $response = array( 'other' => true );
338 338
 
339 339
         //If the deleted option is an "other" option
@@ -399,46 +399,46 @@  discard block
 block discarded – undo
399 399
 
400 400
         $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
401 401
         $prepop = array();
402
-        FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
402
+        FrmFieldsHelper::get_bulk_prefilled_opts( $prepop );
403 403
 
404
-        $field = FrmField::getOne($field_id);
404
+        $field = FrmField::getOne( $field_id );
405 405
 
406 406
         wp_enqueue_script( 'utils' );
407
-        wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css' );
407
+        wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' );
408 408
         FrmAppHelper::load_admin_wide_js();
409 409
 
410
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/import_choices.php');
410
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' );
411 411
         wp_die();
412 412
     }
413 413
 
414 414
     public static function import_options() {
415
-		FrmAppHelper::permission_check('frm_edit_forms');
415
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
416 416
         check_ajax_referer( 'frm_ajax', 'nonce' );
417 417
 
418
-        if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
418
+        if ( ! is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
419 419
             return;
420 420
         }
421 421
 
422 422
 		$field_id = absint( $_POST['field_id'] );
423
-        $field = FrmField::getOne($field_id);
423
+        $field = FrmField::getOne( $field_id );
424 424
 
425 425
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
426 426
             return;
427 427
         }
428 428
 
429
-        $field = FrmFieldsHelper::setup_edit_vars($field);
430
-        $opts = stripslashes_deep($_POST['opts']);
431
-        $opts = explode("\n", rtrim($opts, "\n"));
429
+        $field = FrmFieldsHelper::setup_edit_vars( $field );
430
+        $opts = stripslashes_deep( $_POST['opts'] );
431
+        $opts = explode( "\n", rtrim( $opts, "\n" ) );
432 432
         if ( $field['separate_value'] ) {
433 433
             foreach ( $opts as $opt_key => $opt ) {
434
-                if ( strpos($opt, '|') !== false ) {
435
-                    $vals = explode('|', $opt);
434
+                if ( strpos( $opt, '|' ) !== false ) {
435
+                    $vals = explode( '|', $opt );
436 436
                     if ( $vals[0] != $vals[1] ) {
437
-                        $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
437
+                        $opts[$opt_key] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
438 438
                     }
439
-                    unset($vals);
439
+                    unset( $vals );
440 440
                 }
441
-                unset($opt_key, $opt);
441
+                unset( $opt_key, $opt );
442 442
             }
443 443
         }
444 444
 
@@ -447,12 +447,12 @@  discard block
 block discarded – undo
447 447
             $other_array = array();
448 448
             foreach ( $field['options'] as $opt_key => $opt ) {
449 449
                 if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
450
-                    $other_array[ $opt_key ] = $opt;
450
+                    $other_array[$opt_key] = $opt;
451 451
                 }
452
-                unset($opt_key, $opt);
452
+                unset( $opt_key, $opt );
453 453
             }
454
-            if ( ! empty($other_array) ) {
455
-                $opts = array_merge( $opts, $other_array);
454
+            if ( ! empty( $other_array ) ) {
455
+                $opts = array_merge( $opts, $other_array );
456 456
             }
457 457
         }
458 458
 
@@ -465,16 +465,16 @@  discard block
 block discarded – undo
465 465
         $html_id = FrmFieldsHelper::get_html_id( $field );
466 466
 
467 467
         if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
468
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/radio.php');
468
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' );
469 469
         } else {
470
-            FrmFieldsHelper::show_single_option($field);
470
+            FrmFieldsHelper::show_single_option( $field );
471 471
         }
472 472
 
473 473
         wp_die();
474 474
     }
475 475
 
476 476
     public static function update_order() {
477
-		FrmAppHelper::permission_check('frm_edit_forms');
477
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
478 478
         check_ajax_referer( 'frm_ajax', 'nonce' );
479 479
 
480 480
 		$fields = FrmAppHelper::get_post_param( 'frm_field_id' );
@@ -491,13 +491,13 @@  discard block
 block discarded – undo
491 491
             'rte'       => 'textarea',
492 492
             'website'   => 'url',
493 493
         );
494
-        if ( isset( $type_switch[ $type ] ) ) {
495
-            $type = $type_switch[ $type ];
494
+        if ( isset( $type_switch[$type] ) ) {
495
+            $type = $type_switch[$type];
496 496
         }
497 497
 
498 498
 		$frm_field_selection = FrmField::field_selection();
499
-        $types = array_keys($frm_field_selection);
500
-        if ( ! in_array($type, $types) && $type != 'captcha' ) {
499
+        $types = array_keys( $frm_field_selection );
500
+        if ( ! in_array( $type, $types ) && $type != 'captcha' ) {
501 501
             $type = 'text';
502 502
         }
503 503
 
@@ -536,19 +536,19 @@  discard block
 block discarded – undo
536 536
 
537 537
     public static function input_html( $field, $echo = true ) {
538 538
         $class = array(); //$field['type'];
539
-        self::add_input_classes($field, $class);
539
+        self::add_input_classes( $field, $class );
540 540
 
541 541
         $add_html = array();
542
-        self::add_html_size($field, $add_html);
543
-        self::add_html_length($field, $add_html);
544
-        self::add_html_placeholder($field, $add_html, $class);
542
+        self::add_html_size( $field, $add_html );
543
+        self::add_html_length( $field, $add_html );
544
+        self::add_html_placeholder( $field, $add_html, $class );
545 545
 		self::add_validation_messages( $field, $add_html );
546 546
 
547
-        $class = apply_filters('frm_field_classes', implode(' ', $class), $field);
547
+        $class = apply_filters( 'frm_field_classes', implode( ' ', $class ), $field );
548 548
 
549 549
 		FrmFormsHelper::add_html_attr( $class, 'class', $add_html );
550 550
 
551
-        self::add_shortcodes_to_html($field, $add_html);
551
+        self::add_shortcodes_to_html( $field, $add_html );
552 552
 
553 553
 		$add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
554 554
 		$add_html = ' ' . implode( ' ', $add_html ) . '  ';
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
     }
562 562
 
563 563
 	private static function add_input_classes( $field, array &$class ) {
564
-        if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
564
+        if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) {
565 565
             $class[] = $field['input_class'];
566 566
         }
567 567
 
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
             $class[] = 'dyn_default_value';
575 575
         }
576 576
 
577
-        if ( isset($field['size']) && $field['size'] > 0 ) {
577
+        if ( isset( $field['size'] ) && $field['size'] > 0 ) {
578 578
             $class[] = 'auto_width';
579 579
         }
580 580
     }
@@ -584,19 +584,19 @@  discard block
 block discarded – undo
584 584
             return;
585 585
         }
586 586
 
587
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
587
+        if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
588 588
             return;
589 589
         }
590 590
 
591
-        if ( is_numeric($field['size']) ) {
591
+        if ( is_numeric( $field['size'] ) ) {
592 592
             $field['size'] .= 'px';
593 593
         }
594 594
 
595
-        $important = apply_filters('frm_use_important_width', 1, $field);
595
+        $important = apply_filters( 'frm_use_important_width', 1, $field );
596 596
         // Note: This inline styling must stay since we cannot realistically set a class for every possible field size
597
-        $add_html['style'] = 'style="width:'. esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) .'"';
597
+        $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"';
598 598
 
599
-        self::add_html_cols($field, $add_html);
599
+        self::add_html_cols( $field, $add_html );
600 600
     }
601 601
 
602 602
 	private static function add_html_cols( $field, array &$add_html ) {
@@ -613,13 +613,13 @@  discard block
 block discarded – undo
613 613
         );
614 614
 
615 615
         // include "col" for valid html
616
-        $unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
616
+        $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) );
617 617
 
618
-        if ( ! isset( $calc[ $unit ] ) ) {
618
+        if ( ! isset( $calc[$unit] ) ) {
619 619
             return;
620 620
         }
621 621
 
622
-        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
622
+        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[$unit];
623 623
 
624 624
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
625 625
     }
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
             return;
631 631
         }
632 632
 
633
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
633
+        if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
634 634
             // don't load on form builder page
635 635
             return;
636 636
         }
@@ -661,11 +661,11 @@  discard block
 block discarded – undo
661 661
 
662 662
 		if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) {
663 663
             // use HMTL5 placeholder with js fallback
664
-            $add_html['placeholder'] = 'placeholder="'. esc_attr($field['default_value']) .'"';
665
-            wp_enqueue_script('jquery-placeholder');
664
+            $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"';
665
+            wp_enqueue_script( 'jquery-placeholder' );
666 666
         } else if ( ! $frm_settings->use_html ) {
667 667
 			$val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( '&#039;', "'", esc_attr( $field['default_value'] ) ) ) );
668
-            $add_html['data-frmval'] = 'data-frmval="'. esc_attr($val) .'"';
668
+            $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"';
669 669
             $class[] = 'frm_toggle_default';
670 670
 
671 671
             if ( $field['value'] == $field['default_value'] ) {
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 			$format = FrmEntryValidate::phone_format( $field );
690 690
 			$format = substr( $format, 2, -2 );
691 691
 			$key = 'pattern';
692
-			$add_html[ $key ] = $key . '="' . esc_attr( $format ) . '"';
692
+			$add_html[$key] = $key . '="' . esc_attr( $format ) . '"';
693 693
 		}
694 694
 	}
695 695
 
@@ -703,15 +703,15 @@  discard block
 block discarded – undo
703 703
                 continue;
704 704
             }
705 705
 
706
-            if ( is_numeric($k) && strpos($v, '=') ) {
706
+            if ( is_numeric( $k ) && strpos( $v, '=' ) ) {
707 707
                 $add_html[] = $v;
708
-            } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
709
-                $add_html[ $k ] = str_replace( $k .'="', $k .'="'. $v, $add_html[ $k ] );
708
+            } else if ( ! empty( $k ) && isset( $add_html[$k] ) ) {
709
+                $add_html[$k] = str_replace( $k . '="', $k . '="' . $v, $add_html[$k] );
710 710
             } else {
711
-				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
711
+				$add_html[$k] = $k . '="' . esc_attr( $v ) . '"';
712 712
             }
713 713
 
714
-            unset($k, $v);
714
+            unset( $k, $v );
715 715
         }
716 716
     }
717 717
 
@@ -727,8 +727,8 @@  discard block
 block discarded – undo
727 727
     }
728 728
 
729 729
 	public static function check_label( $opt ) {
730
-        if ( is_array($opt) ) {
731
-            $opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
730
+        if ( is_array( $opt ) ) {
731
+            $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
732 732
         }
733 733
 
734 734
         return $opt;
Please login to merge, or discard this patch.
classes/helpers/FrmFieldsHelper.php 1 patch
Spacing   +225 added lines, -225 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
 
8 8
 	public static function setup_new_vars( $type = '', $form_id = '' ) {
9 9
 
10
-        if ( strpos($type, '|') ) {
11
-            list($type, $setting) = explode('|', $type);
10
+        if ( strpos( $type, '|' ) ) {
11
+            list( $type, $setting ) = explode( '|', $type );
12 12
         }
13 13
 
14
-        $defaults = self::get_default_field_opts($type, $form_id);
15
-        $defaults['field_options']['custom_html'] = self::get_default_html($type);
14
+        $defaults = self::get_default_field_opts( $type, $form_id );
15
+        $defaults['field_options']['custom_html'] = self::get_default_html( $type );
16 16
 
17 17
         $values = array();
18 18
 
@@ -20,20 +20,20 @@  discard block
 block discarded – undo
20 20
             if ( $var == 'field_options' ) {
21 21
                 $values['field_options'] = array();
22 22
                 foreach ( $default as $opt_var => $opt_default ) {
23
-                    $values['field_options'][ $opt_var ] = $opt_default;
24
-                    unset($opt_var, $opt_default);
23
+                    $values['field_options'][$opt_var] = $opt_default;
24
+                    unset( $opt_var, $opt_default );
25 25
                 }
26 26
             } else {
27
-                $values[ $var ] = $default;
27
+                $values[$var] = $default;
28 28
             }
29
-            unset($var, $default);
29
+            unset( $var, $default );
30 30
         }
31 31
 
32 32
         if ( isset( $setting ) && ! empty( $setting ) ) {
33 33
             if ( 'data' == $type ) {
34 34
                 $values['field_options']['data_type'] = $setting;
35 35
             } else {
36
-                $values['field_options'][ $setting ] = 1;
36
+                $values['field_options'][$setting] = 1;
37 37
             }
38 38
         }
39 39
 
@@ -56,19 +56,19 @@  discard block
 block discarded – undo
56 56
         }
57 57
 
58 58
 		$fields = FrmField::field_selection();
59
-        $fields = array_merge($fields, FrmField::pro_field_selection());
59
+        $fields = array_merge( $fields, FrmField::pro_field_selection() );
60 60
 
61
-        if ( isset( $fields[ $type ] ) ) {
62
-            $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ];
61
+        if ( isset( $fields[$type] ) ) {
62
+            $values['name'] = is_array( $fields[$type] ) ? $fields[$type]['name'] : $fields[$type];
63 63
         }
64 64
 
65
-        unset($fields);
65
+        unset( $fields );
66 66
 
67 67
         return $values;
68 68
     }
69 69
 
70 70
 	public static function get_html_id( $field, $plus = '' ) {
71
-        return apply_filters('frm_field_html_id', 'field_'. $field['field_key'] . $plus, $field);
71
+        return apply_filters( 'frm_field_html_id', 'field_' . $field['field_key'] . $plus, $field );
72 72
     }
73 73
 
74 74
     public static function setup_edit_vars( $record, $doing_ajax = false ) {
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
             $values['form_name'] = '';
89 89
 		} else {
90 90
 			foreach ( $defaults as $var => $default ) {
91
-                $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
92
-                unset($var, $default);
91
+                $values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
92
+                unset( $var, $default );
93 93
             }
94 94
 
95 95
 			$values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : '';
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         $values['options'] = $record->options;
101 101
         $values['field_options'] = $record->field_options;
102 102
 
103
-        $defaults = self::get_default_field_opts($values['type'], $record, true);
103
+        $defaults = self::get_default_field_opts( $values['type'], $record, true );
104 104
 
105 105
 		if ( $values['type'] == 'captcha' ) {
106 106
             $frm_settings = FrmAppHelper::get_settings();
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
         }
109 109
 
110 110
 		foreach ( $defaults as $opt => $default ) {
111
-            $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default;
112
-            unset($opt, $default);
111
+            $values[$opt] = isset( $record->field_options[$opt] ) ? $record->field_options[$opt] : $default;
112
+            unset( $opt, $default );
113 113
         }
114 114
 
115
-        $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type);
115
+        $values['custom_html'] = ( isset( $record->field_options['custom_html'] ) ) ? $record->field_options['custom_html'] : self::get_default_html( $record->type );
116 116
 
117 117
 		return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) );
118 118
     }
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
 
132 132
         global $wpdb;
133 133
 
134
-        $form_id = (is_numeric($field)) ? $field : $field->form_id;
134
+        $form_id = ( is_numeric( $field ) ) ? $field : $field->form_id;
135 135
 
136
-        $key = is_numeric($field) ? FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_fields', 'field_key') : $field->field_key;
136
+        $key = is_numeric( $field ) ? FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' ) : $field->field_key;
137 137
 
138 138
         $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) );
139 139
 
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
     public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
152 152
         global $wpdb;
153 153
 
154
-        $values['field_key'] = FrmAppHelper::get_unique_key($new_key, $wpdb->prefix .'frm_fields', 'field_key');
154
+        $values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' );
155 155
         $values['form_id'] = $form_id;
156
-        $values['options'] = maybe_serialize($field->options);
157
-        $values['default_value'] = maybe_serialize($field->default_value);
156
+        $values['options'] = maybe_serialize( $field->options );
157
+        $values['default_value'] = maybe_serialize( $field->default_value );
158 158
 
159 159
         foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
160
-            $values[ $col ] = $field->{$col};
160
+            $values[$col] = $field->{$col};
161 161
         }
162 162
     }
163 163
 
@@ -170,19 +170,19 @@  discard block
 block discarded – undo
170 170
 		$field_name = is_array( $field ) ? $field['name'] : $field->name;
171 171
 
172 172
 		$defaults = array(
173
-			'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __('%s must be unique', 'formidable' ), $field_name ) ),
174
-			'invalid'   => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __('%s is invalid', 'formidable' ), $field_name ) ),
173
+			'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __( '%s must be unique', 'formidable' ), $field_name ) ),
174
+			'invalid'   => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __( '%s is invalid', 'formidable' ), $field_name ) ),
175 175
 			'blank'     => array( 'full' => $frm_settings->blank_msg, 'part' => $frm_settings->blank_msg ),
176 176
 		);
177 177
 
178 178
 		$msg = FrmField::get_option( $field, $error );
179
-		$msg = ( $msg == $defaults[ $error ]['full'] || empty( $msg ) ) ? $defaults[ $error ]['part'] : $msg;
179
+		$msg = ( $msg == $defaults[$error]['full'] || empty( $msg ) ) ? $defaults[$error]['part'] : $msg;
180 180
 		return $msg;
181 181
 	}
182 182
 
183 183
     public static function get_form_fields( $form_id, $error = false ) {
184
-        $fields = FrmField::get_all_for_form($form_id);
185
-        $fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error);
184
+        $fields = FrmField::get_all_for_form( $form_id );
185
+        $fields = apply_filters( 'frm_get_paged_fields', $fields, $form_id, $error );
186 186
         return $fields;
187 187
     }
188 188
 
@@ -205,57 +205,57 @@  discard block
 block discarded – undo
205 205
 </div>
206 206
 DEFAULT_HTML;
207 207
         } else {
208
-			$default_html = apply_filters('frm_other_custom_html', '', $type);
208
+			$default_html = apply_filters( 'frm_other_custom_html', '', $type );
209 209
         }
210 210
 
211
-        return apply_filters('frm_custom_html', $default_html, $type);
211
+        return apply_filters( 'frm_custom_html', $default_html, $type );
212 212
     }
213 213
 
214 214
 	public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) {
215
-        $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
215
+        $html = apply_filters( 'frm_before_replace_shortcodes', $html, $field, $errors, $form );
216 216
 
217 217
         $defaults = array(
218
-            'field_name'  => 'item_meta['. $field['id'] .']',
218
+            'field_name'  => 'item_meta[' . $field['id'] . ']',
219 219
             'field_id'    => $field['id'],
220 220
             'field_plus_id' => '',
221 221
             'section_id'    => '',
222 222
         );
223
-        $args = wp_parse_args($args, $defaults);
223
+        $args = wp_parse_args( $args, $defaults );
224 224
         $field_name = $args['field_name'];
225 225
         $field_id = $args['field_id'];
226
-        $html_id = self::get_html_id($field, $args['field_plus_id']);
226
+        $html_id = self::get_html_id( $field, $args['field_plus_id'] );
227 227
 
228
-        if ( FrmField::is_multiple_select($field) ) {
228
+        if ( FrmField::is_multiple_select( $field ) ) {
229 229
             $field_name .= '[]';
230 230
         }
231 231
 
232 232
         //replace [id]
233
-        $html = str_replace('[id]', $field_id, $html);
233
+        $html = str_replace( '[id]', $field_id, $html );
234 234
 
235 235
         // Remove the for attribute for captcha
236 236
         if ( $field['type'] == 'captcha' ) {
237
-            $html = str_replace(' for="field_[key]"', '', $html);
237
+            $html = str_replace( ' for="field_[key]"', '', $html );
238 238
         }
239 239
 
240 240
         // set the label for
241
-        $html = str_replace('field_[key]', $html_id, $html);
241
+        $html = str_replace( 'field_[key]', $html_id, $html );
242 242
 
243 243
         //replace [key]
244
-        $html = str_replace('[key]', $field['field_key'], $html);
244
+        $html = str_replace( '[key]', $field['field_key'], $html );
245 245
 
246 246
         //replace [description] and [required_label] and [error]
247 247
 		$required = FrmField::is_required( $field ) ? $field['required_indicator'] : '';
248 248
         if ( ! is_array( $errors ) ) {
249 249
             $errors = array();
250 250
         }
251
-		$error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false;
251
+		$error = isset( $errors['field' . $field_id] ) ? $errors['field' . $field_id] : false;
252 252
 
253 253
         //If field type is section heading, add class so a bottom margin can be added to either the h3 or description
254 254
         if ( $field['type'] == 'divider' ) {
255 255
             if ( FrmField::is_option_true( $field, 'description' ) ) {
256 256
                 $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
257 257
             } else {
258
-                $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
258
+                $html = str_replace( '[label_position]', '[label_position] frm_section_spacing', $html );
259 259
             }
260 260
         }
261 261
 
@@ -265,83 +265,83 @@  discard block
 block discarded – undo
265 265
 
266 266
         //replace [required_class]
267 267
 		$required_class = FrmField::is_required( $field ) ? ' frm_required_field' : '';
268
-        $html = str_replace('[required_class]', $required_class, $html);
268
+        $html = str_replace( '[required_class]', $required_class, $html );
269 269
 
270 270
         //replace [label_position]
271
-        $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form);
271
+        $field['label'] = apply_filters( 'frm_html_label_position', $field['label'], $field, $form );
272 272
         $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top';
273 273
 		$html = str_replace( '[label_position]', ( ( in_array( $field['type'], array( 'divider', 'end_divider', 'break' ) ) ) ? $field['label'] : ' frm_primary_label' ), $html );
274 274
 
275 275
         //replace [field_name]
276
-        $html = str_replace('[field_name]', $field['name'], $html);
276
+        $html = str_replace( '[field_name]', $field['name'], $html );
277 277
 
278 278
         //replace [error_class]
279
-		$error_class = isset( $errors[ 'field' . $field_id ] ) ? ' frm_blank_field' : '';
279
+		$error_class = isset( $errors['field' . $field_id] ) ? ' frm_blank_field' : '';
280 280
 		self::get_more_field_classes( $error_class, $field, $field_id, $html );
281 281
 		if ( $field['type'] == 'html' && strpos( $html, '[error_class]' ) === false ) {
282 282
 			// there is no error_class shortcode to use for addign fields
283 283
 			$html = str_replace( 'class="frm_form_field', 'class="frm_form_field ' . $error_class, $html );
284 284
 		}
285
-        $html = str_replace('[error_class]', $error_class, $html);
285
+        $html = str_replace( '[error_class]', $error_class, $html );
286 286
 
287 287
         //replace [entry_key]
288 288
         $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
289
-        $html = str_replace('[entry_key]', $entry_key, $html);
289
+        $html = str_replace( '[entry_key]', $entry_key, $html );
290 290
 
291 291
         //replace [input]
292
-        preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
292
+        preg_match_all( "/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER );
293 293
         global $frm_vars;
294 294
         $frm_settings = FrmAppHelper::get_settings();
295 295
 
296 296
         foreach ( $shortcodes[0] as $short_key => $tag ) {
297
-            $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
297
+            $atts = shortcode_parse_atts( $shortcodes[2][$short_key] );
298 298
 			$tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) );
299 299
 
300 300
             $replace_with = '';
301 301
 
302 302
             if ( $tag == 'input' ) {
303
-                if ( isset($atts['opt']) ) {
304
-                    $atts['opt']--;
303
+                if ( isset( $atts['opt'] ) ) {
304
+                    $atts['opt'] --;
305 305
                 }
306 306
 
307
-                $field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
308
-                if ( isset($atts['class']) ) {
309
-                    unset($atts['class']);
307
+                $field['input_class'] = isset( $atts['class'] ) ? $atts['class'] : '';
308
+                if ( isset( $atts['class'] ) ) {
309
+                    unset( $atts['class'] );
310 310
                 }
311 311
 
312 312
                 $field['shortcodes'] = $atts;
313 313
                 ob_start();
314
-                include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/input.php');
314
+                include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/input.php' );
315 315
                 $replace_with = ob_get_contents();
316 316
                 ob_end_clean();
317 317
             } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
318
-                $replace_with = FrmProEntriesController::entry_delete_link($atts);
318
+                $replace_with = FrmProEntriesController::entry_delete_link( $atts );
319 319
             }
320 320
 
321
-            $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
321
+            $html = str_replace( $shortcodes[0][$short_key], $replace_with, $html );
322 322
         }
323 323
 
324 324
 		if ( $form ) {
325 325
             $form = (array) $form;
326 326
 
327 327
             //replace [form_key]
328
-            $html = str_replace('[form_key]', $form['form_key'], $html);
328
+            $html = str_replace( '[form_key]', $form['form_key'], $html );
329 329
 
330 330
             //replace [form_name]
331
-            $html = str_replace('[form_name]', $form['name'], $html);
331
+            $html = str_replace( '[form_name]', $form['name'], $html );
332 332
         }
333 333
         $html .= "\n";
334 334
 
335 335
         //Return html if conf_field to prevent loop
336
-        if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
336
+        if ( isset( $field['conf_field'] ) && $field['conf_field'] == 'stop' ) {
337 337
             return $html;
338 338
         }
339 339
 
340 340
         //If field is in repeating section
341 341
         if ( $args['section_id'] ) {
342
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ));
342
+            $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ) );
343 343
         } else {
344
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
344
+            $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ) );
345 345
         }
346 346
 
347 347
 		self::remove_collapse_shortcode( $html );
@@ -363,10 +363,10 @@  discard block
 block discarded – undo
363 363
 	* @param $html string
364 364
 	*/
365 365
 	private static function get_more_field_classes( &$error_class, $field, $field_id, $html ) {
366
-		$error_class .= ' frm_'. $field['label'] .'_container';
366
+		$error_class .= ' frm_' . $field['label'] . '_container';
367 367
 		if ( $field['id'] != $field_id ) {
368 368
 			// add a class for repeating/embedded fields
369
-			$error_class .= ' frm_field_'. $field['id'] .'_container';
369
+			$error_class .= ' frm_field_' . $field['id'] . '_container';
370 370
 		}
371 371
 
372 372
 		// Add class to embedded form field
@@ -418,22 +418,22 @@  discard block
 block discarded – undo
418 418
 
419 419
 		//insert custom CSS classes
420 420
 		if ( ! empty( $field['classes'] ) ) {
421
-			if ( ! strpos( $html, 'frm_form_field ') ) {
421
+			if ( ! strpos( $html, 'frm_form_field ' ) ) {
422 422
 				$error_class .= ' frm_form_field';
423 423
 			}
424
-			$error_class .= ' '. $field['classes'];
424
+			$error_class .= ' ' . $field['classes'];
425 425
 		}
426 426
 	}
427 427
 
428 428
     public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
429 429
         if ( $no_vars ) {
430
-            $html = str_replace( '[if '. $code.']', '', $html );
431
-    	    $html = str_replace( '[/if '. $code.']', '', $html );
430
+            $html = str_replace( '[if ' . $code . ']', '', $html );
431
+    	    $html = str_replace( '[/if ' . $code . ']', '', $html );
432 432
         } else {
433
-            $html = preg_replace( '/(\[if\s+'. $code .'\])(.*?)(\[\/if\s+'. $code .'\])/mis', '', $html );
433
+            $html = preg_replace( '/(\[if\s+' . $code . '\])(.*?)(\[\/if\s+' . $code . '\])/mis', '', $html );
434 434
         }
435 435
 
436
-        $html = str_replace( '['. $code .']', $replace_with, $html );
436
+        $html = str_replace( '[' . $code . ']', $replace_with, $html );
437 437
     }
438 438
 
439 439
 	public static function get_shortcode_tag( $shortcodes, $short_key, $args ) {
@@ -452,15 +452,15 @@  discard block
 block discarded – undo
452 452
         }
453 453
 
454 454
         $with_tags = $args['conditional_check'] ? 3 : 2;
455
-        if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
456
-            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
457
-            $tag = str_replace(']', '', $tag);
458
-            $tags = explode(' ', $tag);
459
-            if ( is_array($tags) ) {
455
+        if ( ! empty( $shortcodes[$with_tags][$short_key] ) ) {
456
+            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][$short_key] );
457
+            $tag = str_replace( ']', '', $tag );
458
+            $tags = explode( ' ', $tag );
459
+            if ( is_array( $tags ) ) {
460 460
                 $tag = $tags[0];
461 461
             }
462 462
         } else {
463
-            $tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
463
+            $tag = $shortcodes[$with_tags - 1][$short_key];
464 464
         }
465 465
 
466 466
         return $tag;
@@ -478,16 +478,16 @@  discard block
 block discarded – undo
478 478
 
479 479
 	public static function display_recaptcha( $field ) {
480 480
         $frm_settings = FrmAppHelper::get_settings();
481
-        $lang = apply_filters('frm_recaptcha_lang', $frm_settings->re_lang, $field);
481
+        $lang = apply_filters( 'frm_recaptcha_lang', $frm_settings->re_lang, $field );
482 482
 
483 483
         $api_js_url = 'https://www.google.com/recaptcha/api.js?onload=frmRecaptcha&render=explicit';
484 484
         if ( $lang != 'en' ) {
485
-            $api_js_url .= '&hl='. $lang;
485
+            $api_js_url .= '&hl=' . $lang;
486 486
         }
487
-        $api_js_url = apply_filters('frm_recpatcha_js_url', $api_js_url);
487
+        $api_js_url = apply_filters( 'frm_recpatcha_js_url', $api_js_url );
488 488
 
489
-        wp_register_script('recaptcha-api', $api_js_url, '', true);
490
-        wp_enqueue_script('recaptcha-api');
489
+        wp_register_script( 'recaptcha-api', $api_js_url, '', true );
490
+        wp_enqueue_script( 'recaptcha-api' );
491 491
 
492 492
 ?>
493 493
 <div id="field_<?php echo esc_attr( $field['field_key'] ) ?>" class="frm-g-recaptcha" data-sitekey="<?php echo esc_attr( $frm_settings->pubkey ) ?>" data-size="<?php echo esc_attr( $field['captcha_size'] ) ?>"></div>
@@ -496,45 +496,45 @@  discard block
 block discarded – undo
496 496
 
497 497
 	public static function show_single_option( $field ) {
498 498
         $field_name = $field['name'];
499
-        $html_id = self::get_html_id($field);
499
+        $html_id = self::get_html_id( $field );
500 500
         foreach ( $field['options'] as $opt_key => $opt ) {
501
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
502
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
501
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
502
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field );
503 503
 
504 504
             // If this is an "Other" option, get the HTML for it
505 505
 			if ( self::is_other_opt( $opt_key ) ) {
506 506
                 // Get string for Other text field, if needed
507 507
 				$other_val = self::get_other_val( compact( 'opt_key', 'field' ) );
508
-                require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php');
508
+                require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' );
509 509
             } else {
510
-                require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php');
510
+                require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
511 511
             }
512 512
         }
513 513
     }
514 514
 
515 515
 	public static function dropdown_categories( $args ) {
516 516
 		$defaults = array( 'field' => false, 'name' => false, 'show_option_all' => ' ' );
517
-        $args = wp_parse_args($args, $defaults);
517
+        $args = wp_parse_args( $args, $defaults );
518 518
 
519 519
         if ( ! $args['field'] ) {
520 520
             return;
521 521
         }
522 522
 
523 523
         if ( ! $args['name'] ) {
524
-            $args['name'] = 'item_meta['. $args['field']['id'] .']';
524
+            $args['name'] = 'item_meta[' . $args['field']['id'] . ']';
525 525
         }
526 526
 
527
-        $id = self::get_html_id($args['field']);
527
+        $id = self::get_html_id( $args['field'] );
528 528
         $class = $args['field']['type'];
529 529
 
530
-        $exclude = (is_array($args['field']['exclude_cat'])) ? implode(',', $args['field']['exclude_cat']) : $args['field']['exclude_cat'];
531
-        $exclude = apply_filters('frm_exclude_cats', $exclude, $args['field']);
530
+        $exclude = ( is_array( $args['field']['exclude_cat'] ) ) ? implode( ',', $args['field']['exclude_cat'] ) : $args['field']['exclude_cat'];
531
+        $exclude = apply_filters( 'frm_exclude_cats', $exclude, $args['field'] );
532 532
 
533
-        if ( is_array($args['field']['value']) ) {
534
-            if ( ! empty($exclude) ) {
535
-                $args['field']['value'] = array_diff($args['field']['value'], explode(',', $exclude));
533
+        if ( is_array( $args['field']['value'] ) ) {
534
+            if ( ! empty( $exclude ) ) {
535
+                $args['field']['value'] = array_diff( $args['field']['value'], explode( ',', $exclude ) );
536 536
             }
537
-            $selected = reset($args['field']['value']);
537
+            $selected = reset( $args['field']['value'] );
538 538
         } else {
539 539
             $selected = $args['field']['value'];
540 540
         }
@@ -545,40 +545,40 @@  discard block
 block discarded – undo
545 545
             'hide_empty' => false, 'echo' => 0, 'orderby' => 'name',
546 546
         );
547 547
 
548
-        $tax_atts = apply_filters('frm_dropdown_cat', $tax_atts, $args['field']);
548
+        $tax_atts = apply_filters( 'frm_dropdown_cat', $tax_atts, $args['field'] );
549 549
 
550 550
         if ( FrmAppHelper::pro_is_installed() ) {
551
-            $post_type = FrmProFormsHelper::post_type($args['field']['form_id']);
552
-            $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $args['field']);
551
+            $post_type = FrmProFormsHelper::post_type( $args['field']['form_id'] );
552
+            $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy( $post_type, $args['field'] );
553 553
             if ( ! $tax_atts['taxonomy'] ) {
554 554
                 return;
555 555
             }
556 556
 
557 557
             // If field type is dropdown (not Dynamic), exclude children when parent is excluded
558
-            if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical($tax_atts['taxonomy']) ) {
558
+            if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical( $tax_atts['taxonomy'] ) ) {
559 559
                 $tax_atts['exclude_tree'] = $exclude;
560 560
             }
561 561
         }
562 562
 
563
-        $dropdown = wp_dropdown_categories($tax_atts);
563
+        $dropdown = wp_dropdown_categories( $tax_atts );
564 564
 
565
-        $add_html = FrmFieldsController::input_html($args['field'], false);
565
+        $add_html = FrmFieldsController::input_html( $args['field'], false );
566 566
 
567 567
         if ( FrmAppHelper::pro_is_installed() ) {
568
-            $add_html .= FrmProFieldsController::input_html($args['field'], false);
568
+            $add_html .= FrmProFieldsController::input_html( $args['field'], false );
569 569
         }
570 570
 
571
-		$dropdown = str_replace( "<select name='" . esc_attr( $args['name'] ) ."' id='" . esc_attr( $id ) . "' class='" . esc_attr( $class ) . "'", "<select name='" . esc_attr( $args['name'] ) . "' id='" . esc_attr( $id ) . "' " . $add_html, $dropdown );
571
+		$dropdown = str_replace( "<select name='" . esc_attr( $args['name'] ) . "' id='" . esc_attr( $id ) . "' class='" . esc_attr( $class ) . "'", "<select name='" . esc_attr( $args['name'] ) . "' id='" . esc_attr( $id ) . "' " . $add_html, $dropdown );
572 572
 
573
-        if ( is_array($args['field']['value']) ) {
573
+        if ( is_array( $args['field']['value'] ) ) {
574 574
             $skip = true;
575 575
             foreach ( $args['field']['value'] as $v ) {
576 576
 				if ( $skip ) {
577 577
                     $skip = false;
578 578
                     continue;
579 579
                 }
580
-				$dropdown = str_replace(' value="' . esc_attr( $v ) . '"', ' value="' . esc_attr( $v ) . '" selected="selected"', $dropdown );
581
-                unset($v);
580
+				$dropdown = str_replace( ' value="' . esc_attr( $v ) . '"', ' value="' . esc_attr( $v ) . '" selected="selected"', $dropdown );
581
+                unset( $v );
582 582
             }
583 583
         }
584 584
 
@@ -586,16 +586,16 @@  discard block
 block discarded – undo
586 586
     }
587 587
 
588 588
 	public static function get_term_link( $tax_id ) {
589
-        $tax = get_taxonomy($tax_id);
589
+        $tax = get_taxonomy( $tax_id );
590 590
         if ( ! $tax ) {
591 591
             return;
592 592
         }
593 593
 
594 594
         $link = sprintf(
595 595
             __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
596
-            '<a href="'. esc_url( admin_url( 'edit-tags.php?taxonomy='. $tax->name ) ) .'" target="_blank">'. ( empty($tax->labels->name) ? __( 'Categories' ) : $tax->labels->name ) .'</a>'
596
+            '<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
597 597
         );
598
-        unset($tax);
598
+        unset( $tax );
599 599
 
600 600
         return $link;
601 601
     }
@@ -606,8 +606,8 @@  discard block
 block discarded – undo
606 606
 			$hide_opt = rtrim( $hide_opt );
607 607
 		}
608 608
 
609
-        if ( is_array($observed_value) ) {
610
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
609
+        if ( is_array( $observed_value ) ) {
610
+            return self::array_value_condition( $observed_value, $cond, $hide_opt );
611 611
         }
612 612
 
613 613
         $m = false;
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
         } else if ( $cond == '<' ) {
621 621
             $m = $observed_value < $hide_opt;
622 622
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
623
-            $m = stripos($observed_value, $hide_opt);
623
+            $m = stripos( $observed_value, $hide_opt );
624 624
             if ( $cond == 'not LIKE' ) {
625 625
                 $m = ( $m === false ) ? true : false;
626 626
             } else {
@@ -633,23 +633,23 @@  discard block
 block discarded – undo
633 633
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
634 634
         $m = false;
635 635
         if ( $cond == '==' ) {
636
-            if ( is_array($hide_opt) ) {
637
-                $m = array_intersect($hide_opt, $observed_value);
638
-                $m = empty($m) ? false : true;
636
+            if ( is_array( $hide_opt ) ) {
637
+                $m = array_intersect( $hide_opt, $observed_value );
638
+                $m = empty( $m ) ? false : true;
639 639
             } else {
640
-                $m = in_array($hide_opt, $observed_value);
640
+                $m = in_array( $hide_opt, $observed_value );
641 641
             }
642 642
         } else if ( $cond == '!=' ) {
643
-            $m = ! in_array($hide_opt, $observed_value);
643
+            $m = ! in_array( $hide_opt, $observed_value );
644 644
         } else if ( $cond == '>' ) {
645
-            $min = min($observed_value);
645
+            $min = min( $observed_value );
646 646
             $m = $min > $hide_opt;
647 647
         } else if ( $cond == '<' ) {
648
-            $max = max($observed_value);
648
+            $max = max( $observed_value );
649 649
             $m = $max < $hide_opt;
650 650
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
651 651
             foreach ( $observed_value as $ob ) {
652
-                $m = strpos($ob, $hide_opt);
652
+                $m = strpos( $ob, $hide_opt );
653 653
                 if ( $m !== false ) {
654 654
                     $m = true;
655 655
                     break;
@@ -670,27 +670,27 @@  discard block
 block discarded – undo
670 670
      * @return string
671 671
      */
672 672
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
673
-        if ( strpos($value, '[sitename]') !== false ) {
673
+        if ( strpos( $value, '[sitename]' ) !== false ) {
674 674
             $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
675
-            $value = str_replace('[sitename]', $new_value, $value);
675
+            $value = str_replace( '[sitename]', $new_value, $value );
676 676
         }
677 677
 
678
-        $value = apply_filters('frm_content', $value, $form, $entry);
679
-        $value = do_shortcode($value);
678
+        $value = apply_filters( 'frm_content', $value, $form, $entry );
679
+        $value = do_shortcode( $value );
680 680
 
681 681
         return $value;
682 682
     }
683 683
 
684 684
 	public static function get_shortcodes( $content, $form_id ) {
685 685
         if ( FrmAppHelper::pro_is_installed() ) {
686
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
686
+            return FrmProDisplaysHelper::get_shortcodes( $content, $form_id );
687 687
         }
688 688
 
689 689
         $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
690 690
 
691
-        $tagregexp = self::allowed_shortcodes($fields);
691
+        $tagregexp = self::allowed_shortcodes( $fields );
692 692
 
693
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
693
+        preg_match_all( "/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER );
694 694
 
695 695
         return $matches;
696 696
     }
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
             $tagregexp[] = $field->field_key;
709 709
         }
710 710
 
711
-        $tagregexp = implode('|', $tagregexp);
711
+        $tagregexp = implode( '|', $tagregexp );
712 712
         return $tagregexp;
713 713
     }
714 714
 
@@ -720,28 +720,28 @@  discard block
 block discarded – undo
720 720
         );
721 721
 
722 722
         foreach ( $shortcodes[0] as $short_key => $tag ) {
723
-            $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] );
723
+            $atts = shortcode_parse_atts( $shortcodes[3][$short_key] );
724 724
 
725
-            if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
726
-				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] );
727
-                $tags = explode(' ', $tag);
728
-                if ( is_array($tags) ) {
725
+            if ( ! empty( $shortcodes[3][$short_key] ) ) {
726
+				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][$short_key] );
727
+                $tags = explode( ' ', $tag );
728
+                if ( is_array( $tags ) ) {
729 729
                     $tag = $tags[0];
730 730
                 }
731 731
             } else {
732
-                $tag = $shortcodes[2][ $short_key ];
732
+                $tag = $shortcodes[2][$short_key];
733 733
             }
734 734
 
735 735
             switch ( $tag ) {
736 736
                 case 'id':
737 737
                 case 'key':
738 738
                 case 'ip':
739
-                    $replace_with = $shortcode_values[ $tag ];
739
+                    $replace_with = $shortcode_values[$tag];
740 740
                 break;
741 741
 
742 742
                 case 'user_agent':
743 743
                 case 'user-agent':
744
-                    $entry->description = maybe_unserialize($entry->description);
744
+                    $entry->description = maybe_unserialize( $entry->description );
745 745
 					$replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] );
746 746
                 break;
747 747
 
@@ -749,25 +749,25 @@  discard block
 block discarded – undo
749 749
                 case 'created-at':
750 750
                 case 'updated_at':
751 751
                 case 'updated-at':
752
-                    if ( isset($atts['format']) ) {
752
+                    if ( isset( $atts['format'] ) ) {
753 753
                         $time_format = ' ';
754 754
                     } else {
755
-                        $atts['format'] = get_option('date_format');
755
+                        $atts['format'] = get_option( 'date_format' );
756 756
                         $time_format = '';
757 757
                     }
758 758
 
759
-                    $this_tag = str_replace('-', '_', $tag);
760
-                    $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
761
-                    unset($this_tag);
759
+                    $this_tag = str_replace( '-', '_', $tag );
760
+                    $replace_with = FrmAppHelper::get_formatted_time( $entry->{$this_tag}, $atts['format'], $time_format );
761
+                    unset( $this_tag );
762 762
                 break;
763 763
 
764 764
                 case 'created_by':
765 765
                 case 'created-by':
766 766
                 case 'updated_by':
767 767
                 case 'updated-by':
768
-                    $this_tag = str_replace('-', '_', $tag);
768
+                    $this_tag = str_replace( '-', '_', $tag );
769 769
 					$replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts );
770
-                    unset($this_tag);
770
+                    unset( $this_tag );
771 771
                 break;
772 772
 
773 773
                 case 'admin_email':
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
                         break;
785 785
                     }
786 786
 
787
-                    $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
787
+                    $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
788 788
 
789 789
                     $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
790 790
 
@@ -792,29 +792,29 @@  discard block
 block discarded – undo
792 792
                     $atts['entry_key'] = $entry->item_key;
793 793
                     //$replace_with = apply_filters('frmpro_fields_replace_shortcodes', $replace_with, $tag, $atts, $field);
794 794
 
795
-                    if ( is_array($replace_with) ) {
796
-                        $replace_with = implode($sep, $replace_with);
795
+                    if ( is_array( $replace_with ) ) {
796
+                        $replace_with = implode( $sep, $replace_with );
797 797
                     }
798 798
 
799
-                    if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
799
+                    if ( isset( $atts['show'] ) && $atts['show'] == 'field_label' ) {
800 800
                         $replace_with = $field->name;
801
-                    } else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
801
+                    } else if ( isset( $atts['show'] ) && $atts['show'] == 'description' ) {
802 802
                         $replace_with = $field->description;
803
-                    } else if ( empty($replace_with) && $replace_with != '0' ) {
803
+                    } else if ( empty( $replace_with ) && $replace_with != '0' ) {
804 804
                         $replace_with = '';
805 805
                     } else {
806
-                        $replace_with = self::get_display_value($replace_with, $field, $atts);
806
+                        $replace_with = self::get_display_value( $replace_with, $field, $atts );
807 807
                     }
808 808
 
809
-                    unset($field);
809
+                    unset( $field );
810 810
                 break;
811 811
             }
812 812
 
813
-            if ( isset($replace_with) ) {
814
-                $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
813
+            if ( isset( $replace_with ) ) {
814
+                $content = str_replace( $shortcodes[0][$short_key], $replace_with, $content );
815 815
             }
816 816
 
817
-            unset($atts, $conditional, $replace_with);
817
+            unset( $atts, $conditional, $replace_with );
818 818
 		}
819 819
 
820 820
 		return $content;
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
         $new_value = '';
831 831
         switch ( $tag ) {
832 832
             case 'admin_email':
833
-                $new_value = get_option('admin_email');
833
+                $new_value = get_option( 'admin_email' );
834 834
                 break;
835 835
             case 'siteurl':
836 836
                 $new_value = FrmAppHelper::site_url();
@@ -856,28 +856,28 @@  discard block
 block discarded – undo
856 856
      * @return string|array
857 857
      */
858 858
     public static function process_get_shortcode( $atts, $return_array = false ) {
859
-        if ( ! isset($atts['param']) ) {
859
+        if ( ! isset( $atts['param'] ) ) {
860 860
             return '';
861 861
         }
862 862
 
863
-        if ( strpos($atts['param'], '&#91;') ) {
864
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
865
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
863
+        if ( strpos( $atts['param'], '&#91;' ) ) {
864
+            $atts['param'] = str_replace( '&#91;', '[', $atts['param'] );
865
+            $atts['param'] = str_replace( '&#93;', ']', $atts['param'] );
866 866
         }
867 867
 
868
-        $new_value = FrmAppHelper::get_param($atts['param'], '');
868
+        $new_value = FrmAppHelper::get_param( $atts['param'], '' );
869 869
         $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
870 870
 
871 871
         if ( $new_value == '' ) {
872
-            if ( ! isset($atts['prev_val']) ) {
872
+            if ( ! isset( $atts['prev_val'] ) ) {
873 873
                 $atts['prev_val'] = '';
874 874
             }
875 875
 
876
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
876
+            $new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val'];
877 877
         }
878 878
 
879
-        if ( is_array($new_value) && ! $return_array ) {
880
-            $new_value = implode(', ', $new_value);
879
+        if ( is_array( $new_value ) && ! $return_array ) {
880
+            $new_value = implode( ', ', $new_value );
881 881
         }
882 882
 
883 883
         return $new_value;
@@ -889,12 +889,12 @@  discard block
 block discarded – undo
889 889
 		$replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts );
890 890
 
891 891
         if ( $field->type == 'textarea' || $field->type == 'rte' ) {
892
-            $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
893
-            if ( apply_filters('frm_use_wpautop', $autop) ) {
894
-                if ( is_array($replace_with) ) {
895
-                    $replace_with = implode("\n", $replace_with);
892
+            $autop = isset( $atts['wpautop'] ) ? $atts['wpautop'] : true;
893
+            if ( apply_filters( 'frm_use_wpautop', $autop ) ) {
894
+                if ( is_array( $replace_with ) ) {
895
+                    $replace_with = implode( "\n", $replace_with );
896 896
                 }
897
-                $replace_with = wpautop($replace_with);
897
+                $replace_with = wpautop( $replace_with );
898 898
             }
899 899
 			unset( $autop );
900 900
 		} else if ( is_array( $replace_with ) ) {
@@ -916,14 +916,14 @@  discard block
 block discarded – undo
916 916
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
917 917
 
918 918
         $field_types = array();
919
-        if ( in_array($type, $single_input) ) {
919
+        if ( in_array( $type, $single_input ) ) {
920 920
             self::field_types_for_input( $single_input, $field_selection, $field_types );
921
-        } else if ( in_array($type, $multiple_input) ) {
921
+        } else if ( in_array( $type, $multiple_input ) ) {
922 922
             self::field_types_for_input( $multiple_input, $field_selection, $field_types );
923
-        } else if ( in_array($type, $other_type) ) {
923
+        } else if ( in_array( $type, $other_type ) ) {
924 924
             self::field_types_for_input( $other_type, $field_selection, $field_types );
925
-		} else if ( isset( $field_selection[ $type ] ) ) {
926
-            $field_types[ $type ] = $field_selection[ $type ];
925
+		} else if ( isset( $field_selection[$type] ) ) {
926
+            $field_types[$type] = $field_selection[$type];
927 927
         }
928 928
 
929 929
         return $field_types;
@@ -931,8 +931,8 @@  discard block
 block discarded – undo
931 931
 
932 932
     private static function field_types_for_input( $inputs, $fields, &$field_types ) {
933 933
         foreach ( $inputs as $input ) {
934
-            $field_types[ $input ] = $fields[ $input ];
935
-            unset($input);
934
+            $field_types[$input] = $fields[$input];
935
+            unset( $input );
936 936
         }
937 937
     }
938 938
 
@@ -977,21 +977,21 @@  discard block
 block discarded – undo
977 977
 		// Check posted vals before checking saved values
978 978
 
979 979
 		// For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero
980
-		if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) {
980
+		if ( $parent && isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ) {
981 981
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
982
-				$other_val = isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) : '';
982
+				$other_val = isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) : '';
983 983
 			} else {
984
-				$other_val = sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] );
984
+				$other_val = sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] );
985 985
 			}
986 986
 			return $other_val;
987 987
 
988
-		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) {
988
+		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][$field['id']] ) ) {
989 989
 			// For normal fields
990 990
 
991 991
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
992
-				$other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) : '';
992
+				$other_val = isset( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta']['other'][$field['id']][$opt_key] ) : '';
993 993
 			} else {
994
-				$other_val = sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ] );
994
+				$other_val = sanitize_text_field( $_POST['item_meta']['other'][$field['id']] );
995 995
 			}
996 996
 			return $other_val;
997 997
 		}
@@ -1000,8 +1000,8 @@  discard block
 block discarded – undo
1000 1000
 		if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) {
1001 1001
 			// Check if there is an "other" val in saved value and make sure the
1002 1002
 			// "other" val is not equal to the Other checkbox option
1003
-			if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) {
1004
-				$other_val = $field['value'][ $opt_key ];
1003
+			if ( isset( $field['value'][$opt_key] ) && $field['options'][$opt_key] != $field['value'][$opt_key] ) {
1004
+				$other_val = $field['value'][$opt_key];
1005 1005
 			}
1006 1006
 		} else {
1007 1007
 			/**
@@ -1013,8 +1013,8 @@  discard block
 block discarded – undo
1013 1013
 				// Multi-select dropdowns - key is not preserved
1014 1014
 				if ( is_array( $field['value'] ) ) {
1015 1015
 					$o_key = array_search( $temp_val, $field['value'] );
1016
-					if ( isset( $field['value'][ $o_key ] ) ) {
1017
-						unset( $field['value'][ $o_key ], $o_key );
1016
+					if ( isset( $field['value'][$o_key] ) ) {
1017
+						unset( $field['value'][$o_key], $o_key );
1018 1018
 					}
1019 1019
 				} else if ( $temp_val == $field['value'] ) {
1020 1020
 					// For radio and regular dropdowns
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
 	private static function set_other_name( $args, &$other_args ) {
1072 1072
 		//Set up name for other field
1073 1073
 		$other_args['name'] = str_replace( '[]', '', $args['field_name'] );
1074
-		$other_args['name'] = preg_replace('/\[' . $args['field']['id'] . '\]$/', '', $other_args['name']);
1074
+		$other_args['name'] = preg_replace( '/\[' . $args['field']['id'] . '\]$/', '', $other_args['name'] );
1075 1075
 		$other_args['name'] = $other_args['name'] . '[other]' . '[' . $args['field']['id'] . ']';
1076 1076
 
1077 1077
 		//Converts item_meta[field_id] => item_meta[other][field_id] and
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
 		// Count should only be greater than 3 if inside of a repeating section
1098 1098
 		if ( count( $temp_array ) > 3 ) {
1099 1099
 			$parent = str_replace( ']', '', $temp_array[1] );
1100
-			$pointer = str_replace( ']', '', $temp_array[2]);
1100
+			$pointer = str_replace( ']', '', $temp_array[2] );
1101 1101
 		}
1102 1102
 
1103 1103
 		// Get text for "other" text field
@@ -1164,11 +1164,11 @@  discard block
 block discarded – undo
1164 1164
 
1165 1165
 			if ( $display['default_blank'] ) {
1166 1166
 				self::show_default_blank_js( $field['default_blank'] );
1167
-				echo '<input type="hidden" name="field_options[default_blank_'. esc_attr( $field['id'] ) .']" value="' . esc_attr( $field['default_blank'] ) .'" />';
1167
+				echo '<input type="hidden" name="field_options[default_blank_' . esc_attr( $field['id'] ) . ']" value="' . esc_attr( $field['default_blank'] ) . '" />';
1168 1168
 			}
1169 1169
 
1170 1170
 			self::show_onfocus_js( $field['clear_on_focus'] );
1171
-			echo '<input type="hidden" name="field_options[clear_on_focus_'. esc_attr( $field['id'] ) .']" value="' . esc_attr( $field['default_blank'] ) .'" />';
1171
+			echo '<input type="hidden" name="field_options[clear_on_focus_' . esc_attr( $field['id'] ) . ']" value="' . esc_attr( $field['default_blank'] ) . '" />';
1172 1172
 
1173 1173
 			echo '</span>';
1174 1174
 		}
@@ -1202,29 +1202,29 @@  discard block
 block discarded – undo
1202 1202
         $replace = array();
1203 1203
         $replace_with = array();
1204 1204
         foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1205
-            $replace[] = '[if '. $old .']';
1206
-            $replace_with[] = '[if '. $new .']';
1207
-            $replace[] = '[if '. $old .' ';
1208
-            $replace_with[] = '[if '. $new .' ';
1209
-            $replace[] = '[/if '. $old .']';
1210
-            $replace_with[] = '[/if '. $new .']';
1211
-            $replace[] = '[foreach '. $old .']';
1212
-            $replace_with[] = '[foreach '. $new .']';
1213
-            $replace[] = '[/foreach '. $old .']';
1214
-            $replace_with[] = '[/foreach '. $new .']';
1215
-            $replace[] = '['. $old .']';
1216
-            $replace_with[] = '['. $new .']';
1217
-            $replace[] = '['. $old .' ';
1218
-            $replace_with[] = '['. $new .' ';
1219
-            unset($old, $new);
1205
+            $replace[] = '[if ' . $old . ']';
1206
+            $replace_with[] = '[if ' . $new . ']';
1207
+            $replace[] = '[if ' . $old . ' ';
1208
+            $replace_with[] = '[if ' . $new . ' ';
1209
+            $replace[] = '[/if ' . $old . ']';
1210
+            $replace_with[] = '[/if ' . $new . ']';
1211
+            $replace[] = '[foreach ' . $old . ']';
1212
+            $replace_with[] = '[foreach ' . $new . ']';
1213
+            $replace[] = '[/foreach ' . $old . ']';
1214
+            $replace_with[] = '[/foreach ' . $new . ']';
1215
+            $replace[] = '[' . $old . ']';
1216
+            $replace_with[] = '[' . $new . ']';
1217
+            $replace[] = '[' . $old . ' ';
1218
+            $replace_with[] = '[' . $new . ' ';
1219
+            unset( $old, $new );
1220 1220
         }
1221 1221
 		if ( is_array( $val ) ) {
1222 1222
 			foreach ( $val as $k => $v ) {
1223
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1224
-                unset($k, $v);
1223
+                $val[$k] = str_replace( $replace, $replace_with, $v );
1224
+                unset( $k, $v );
1225 1225
             }
1226 1226
         } else {
1227
-            $val = str_replace($replace, $replace_with, $val);
1227
+            $val = str_replace( $replace, $replace_with, $val );
1228 1228
         }
1229 1229
 
1230 1230
         return $val;
@@ -1237,7 +1237,7 @@  discard block
 block discarded – undo
1237 1237
             'DC' => 'District of Columbia',
1238 1238
             'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1239 1239
             'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1240
-            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1240
+            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine', 'MD' => 'Maryland',
1241 1241
             'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1242 1242
             'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1243 1243
             'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
@@ -1328,35 +1328,35 @@  discard block
 block discarded – undo
1328 1328
     }
1329 1329
 
1330 1330
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1331
-		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1331
+		$prepop[__( 'Countries', 'formidable' )] = FrmFieldsHelper::get_countries();
1332 1332
 
1333 1333
         $states = FrmFieldsHelper::get_us_states();
1334
-        $state_abv = array_keys($states);
1335
-        sort($state_abv);
1336
-		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1334
+        $state_abv = array_keys( $states );
1335
+        sort( $state_abv );
1336
+		$prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv;
1337 1337
 
1338
-        $states = array_values($states);
1339
-        sort($states);
1340
-		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1341
-        unset($state_abv, $states);
1338
+        $states = array_values( $states );
1339
+        sort( $states );
1340
+		$prepop[__( 'U.S. States', 'formidable' )] = $states;
1341
+        unset( $state_abv, $states );
1342 1342
 
1343
-		$prepop[ __( 'Age', 'formidable' ) ] = array(
1343
+		$prepop[__( 'Age', 'formidable' )] = array(
1344 1344
             __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1345 1345
             __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1346 1346
             __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1347 1347
         );
1348 1348
 
1349
-		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1349
+		$prepop[__( 'Satisfaction', 'formidable' )] = array(
1350 1350
             __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1351 1351
             __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1352 1352
         );
1353 1353
 
1354
-		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1354
+		$prepop[__( 'Importance', 'formidable' )] = array(
1355 1355
             __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1356 1356
             __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1357 1357
         );
1358 1358
 
1359
-		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1359
+		$prepop[__( 'Agreement', 'formidable' )] = array(
1360 1360
             __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1361 1361
             __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1362 1362
         );
Please login to merge, or discard this patch.