Completed
Push — master ( 54eb7f...5d7e04 )
by Jamie
03:28
created
classes/controllers/FrmFieldsController.php 1 patch
Indentation   +428 added lines, -428 removed lines patch added patch discarded remove patch
@@ -2,129 +2,129 @@  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 36
 			$field_name = 'item_meta[' . $field_id . ']';
37
-            $html_id = FrmFieldsHelper::get_html_id($field);
37
+			$html_id = FrmFieldsHelper::get_html_id($field);
38 38
 
39
-            ob_start();
39
+			ob_start();
40 40
 			include( $path . '/classes/views/frm-forms/add_field.php' );
41
-            $field_html[ $field_id ] = ob_get_contents();
42
-            ob_end_clean();
43
-        }
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 52
 	/**
53 53
 	 * Create a new field with ajax
54 54
 	 */
55
-    public static function create() {
55
+	public static function create() {
56 56
 		FrmAppHelper::permission_check('frm_edit_forms');
57
-        check_ajax_referer( 'frm_ajax', 'nonce' );
57
+		check_ajax_referer( 'frm_ajax', 'nonce' );
58 58
 
59 59
 		$field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' );
60 60
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
61 61
 
62 62
 		$field = self::include_new_field( $field_type, $form_id );
63 63
 
64
-        // this hook will allow for multiple fields to be added at once
65
-        do_action('frm_after_field_created', $field, $form_id);
64
+		// this hook will allow for multiple fields to be added at once
65
+		do_action('frm_after_field_created', $field, $form_id);
66 66
 
67
-        wp_die();
68
-    }
67
+		wp_die();
68
+	}
69 69
 
70
-    /**
71
-     * Set up and create a new field
72
-     *
73
-     * @param string $field_type
74
-     * @param integer $form_id
75
-     * @return array|bool
76
-     */
70
+	/**
71
+	 * Set up and create a new field
72
+	 *
73
+	 * @param string $field_type
74
+	 * @param integer $form_id
75
+	 * @return array|bool
76
+	 */
77 77
 	public static function include_new_field( $field_type, $form_id ) {
78
-        $values = array();
79
-        if ( FrmAppHelper::pro_is_installed() ) {
80
-            $values['post_type'] = FrmProFormsHelper::post_type($form_id);
81
-        }
78
+		$values = array();
79
+		if ( FrmAppHelper::pro_is_installed() ) {
80
+			$values['post_type'] = FrmProFormsHelper::post_type($form_id);
81
+		}
82 82
 
83 83
 		$field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id );
84
-        $field_values = apply_filters( 'frm_before_field_created', $field_values );
84
+		$field_values = apply_filters( 'frm_before_field_created', $field_values );
85 85
 
86
-        $field_id = FrmField::create( $field_values );
86
+		$field_id = FrmField::create( $field_values );
87 87
 
88
-        if ( ! $field_id ) {
89
-            return false;
90
-        }
88
+		if ( ! $field_id ) {
89
+			return false;
90
+		}
91 91
 
92
-        $field = self::include_single_field($field_id, $values, $form_id);
92
+		$field = self::include_single_field($field_id, $values, $form_id);
93 93
 
94
-        return $field;
95
-    }
94
+		return $field;
95
+	}
96 96
 
97 97
 	public static function edit_name( $field = 'name', $id = '' ) {
98 98
 		FrmAppHelper::permission_check('frm_edit_forms');
99
-        check_ajax_referer( 'frm_ajax', 'nonce' );
99
+		check_ajax_referer( 'frm_ajax', 'nonce' );
100 100
 
101
-        if ( empty($field) ) {
102
-            $field = 'name';
103
-        }
101
+		if ( empty($field) ) {
102
+			$field = 'name';
103
+		}
104 104
 
105
-        if ( empty($id) ) {
105
+		if ( empty($id) ) {
106 106
 			$id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
107 107
 			$id = str_replace( 'field_label_', '', $id );
108
-        }
108
+		}
109 109
 
110 110
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' );
111 111
 		$value = trim( $value );
112
-        if ( trim(strip_tags($value)) == '' ) {
113
-            // set blank value if there is no content
114
-            $value = '';
115
-        }
112
+		if ( trim(strip_tags($value)) == '' ) {
113
+			// set blank value if there is no content
114
+			$value = '';
115
+		}
116 116
 
117 117
 		FrmField::update( $id, array( $field => $value ) );
118 118
 
119 119
 		do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) );
120 120
 
121 121
 		echo stripslashes( wp_kses_post( $value ) );
122
-        wp_die();
123
-    }
122
+		wp_die();
123
+	}
124 124
 
125
-    public static function update_ajax_option() {
125
+	public static function update_ajax_option() {
126 126
 		FrmAppHelper::permission_check('frm_edit_forms');
127
-        check_ajax_referer( 'frm_ajax', 'nonce' );
127
+		check_ajax_referer( 'frm_ajax', 'nonce' );
128 128
 
129 129
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
130 130
 		if ( ! $field_id ) {
@@ -139,143 +139,143 @@  discard block
 block discarded – undo
139 139
 			unset($new_val);
140 140
 		}
141 141
 
142
-        FrmField::update( $field_id, array(
143
-            'field_options' => $field->field_options,
142
+		FrmField::update( $field_id, array(
143
+			'field_options' => $field->field_options,
144 144
 			'form_id'		=> $field->form_id,
145
-        ) );
146
-        wp_die();
147
-    }
145
+		) );
146
+		wp_die();
147
+	}
148 148
 
149
-    public static function duplicate() {
149
+	public static function duplicate() {
150 150
 		FrmAppHelper::permission_check('frm_edit_forms');
151
-        check_ajax_referer( 'frm_ajax', 'nonce' );
151
+		check_ajax_referer( 'frm_ajax', 'nonce' );
152 152
 
153
-        global $wpdb;
153
+		global $wpdb;
154 154
 
155 155
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
156 156
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
157 157
 
158 158
 		$copy_field = FrmField::getOne( $field_id );
159
-        if ( ! $copy_field ) {
160
-            wp_die();
161
-        }
159
+		if ( ! $copy_field ) {
160
+			wp_die();
161
+		}
162 162
 
163 163
 		do_action( 'frm_duplicate_field', $copy_field, $form_id );
164 164
 		do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id );
165 165
 
166 166
 		$values = array();
167
-        FrmFieldsHelper::fill_field( $values, $copy_field, $form_id );
167
+		FrmFieldsHelper::fill_field( $values, $copy_field, $form_id );
168 168
 
169 169
 		$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 ) );
170 170
 
171
-        $values['field_order'] = $field_count + 1;
171
+		$values['field_order'] = $field_count + 1;
172 172
 
173
-	    $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values );
173
+		$values = apply_filters( 'frm_prepare_single_field_for_duplication', $values );
174 174
 
175
-        if ( ! $field_id = FrmField::create($values) ) {
176
-            wp_die();
177
-        }
175
+		if ( ! $field_id = FrmField::create($values) ) {
176
+			wp_die();
177
+		}
178 178
 
179
-        self::include_single_field($field_id, $values);
179
+		self::include_single_field($field_id, $values);
180 180
 
181
-        wp_die();
182
-    }
181
+		wp_die();
182
+	}
183 183
 
184
-    /**
185
-     * Load a single field in the form builder along with all needed variables
186
-     */
187
-    public static function include_single_field( $field_id, $values, $form_id = 0 ) {
188
-        $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
184
+	/**
185
+	 * Load a single field in the form builder along with all needed variables
186
+	 */
187
+	public static function include_single_field( $field_id, $values, $form_id = 0 ) {
188
+		$field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
189 189
 		$field_name = 'item_meta[' . $field_id . ']';
190
-        $html_id = FrmFieldsHelper::get_html_id($field);
191
-        $id = $form_id ? $form_id : $field['form_id'];
192
-        if ( $field['type'] == 'html' ) {
193
-            $field['stop_filter'] = true;
194
-        }
190
+		$html_id = FrmFieldsHelper::get_html_id($field);
191
+		$id = $form_id ? $form_id : $field['form_id'];
192
+		if ( $field['type'] == 'html' ) {
193
+			$field['stop_filter'] = true;
194
+		}
195 195
 
196 196
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' );
197 197
 
198
-        return $field;
199
-    }
198
+		return $field;
199
+	}
200 200
 
201
-    public static function destroy() {
201
+	public static function destroy() {
202 202
 		FrmAppHelper::permission_check('frm_edit_forms');
203
-        check_ajax_referer( 'frm_ajax', 'nonce' );
203
+		check_ajax_referer( 'frm_ajax', 'nonce' );
204 204
 
205 205
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
206 206
 		FrmField::destroy( $field_id );
207
-        wp_die();
208
-    }
207
+		wp_die();
208
+	}
209 209
 
210
-    /* Field Options */
210
+	/* Field Options */
211 211
 
212
-    //Add Single Option or Other Option
213
-    public static function add_option() {
212
+	//Add Single Option or Other Option
213
+	public static function add_option() {
214 214
 		FrmAppHelper::permission_check('frm_edit_forms');
215
-        check_ajax_referer( 'frm_ajax', 'nonce' );
215
+		check_ajax_referer( 'frm_ajax', 'nonce' );
216 216
 
217 217
 		$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
218 218
 		$opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
219 219
 
220
-        //Get the field
221
-        $field = FrmField::getOne($id);
220
+		//Get the field
221
+		$field = FrmField::getOne($id);
222 222
 
223 223
 		if ( ! empty( $field->options ) ) {
224 224
 			$keys = array_keys( $field->options );
225
-            $last = str_replace( 'other_', '', end( $keys ) );
226
-        } else {
227
-            $last = 0;
228
-        }
229
-        $opt_key = $last + 1;
225
+			$last = str_replace( 'other_', '', end( $keys ) );
226
+		} else {
227
+			$last = 0;
228
+		}
229
+		$opt_key = $last + 1;
230 230
 
231
-        if ( 'other' == $opt_type ) {
231
+		if ( 'other' == $opt_type ) {
232 232
 			$opt = esc_html__( 'Other', 'formidable' );
233
-            $other_val = '';
234
-            $opt_key = 'other_' . $opt_key;
235
-
236
-            //Update value of "other" in DB
237
-            $field_options = maybe_unserialize( $field->field_options );
238
-            $field_options['other'] = 1;
239
-            FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) );
240
-        } else {
233
+			$other_val = '';
234
+			$opt_key = 'other_' . $opt_key;
235
+
236
+			//Update value of "other" in DB
237
+			$field_options = maybe_unserialize( $field->field_options );
238
+			$field_options['other'] = 1;
239
+			FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) );
240
+		} else {
241 241
 			$first_opt = reset( $field->options );
242 242
 			$next_opt = count( $field->options );
243
-            if ( $first_opt != '' ) {
244
-                $next_opt++;
245
-            }
243
+			if ( $first_opt != '' ) {
244
+				$next_opt++;
245
+			}
246 246
 			$opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt;
247
-            unset($next_opt);
248
-        }
249
-        $field_val = $opt;
247
+			unset($next_opt);
248
+		}
249
+		$field_val = $opt;
250 250
 		$field->options[ $opt_key ] = $opt;
251 251
 
252
-        //Update options in DB
252
+		//Update options in DB
253 253
 		FrmField::update( $id, array( 'options' => $field->options ) );
254 254
 
255
-        $field_data = $field;
256
-        $field = array(
257
-            'type'  => $field_data->type,
258
-            'id'    => $id,
259
-            'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
260
-            'form_id' => $field_data->form_id,
261
-            'field_key' => $field_data->field_key,
262
-        );
255
+		$field_data = $field;
256
+		$field = array(
257
+			'type'  => $field_data->type,
258
+			'id'    => $id,
259
+			'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
260
+			'form_id' => $field_data->form_id,
261
+			'field_key' => $field_data->field_key,
262
+		);
263 263
 
264 264
 		$field_name = 'item_meta[' . $id . ']';
265
-        $html_id = FrmFieldsHelper::get_html_id($field);
266
-        $checked = '';
265
+		$html_id = FrmFieldsHelper::get_html_id($field);
266
+		$checked = '';
267 267
 
268
-        if ( 'other' == $opt_type ) {
268
+		if ( 'other' == $opt_type ) {
269 269
 			require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' );
270
-        } else {
270
+		} else {
271 271
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
272
-        }
273
-        wp_die();
274
-    }
272
+		}
273
+		wp_die();
274
+	}
275 275
 
276
-    public static function edit_option() {
276
+	public static function edit_option() {
277 277
 		FrmAppHelper::permission_check('frm_edit_forms');
278
-        check_ajax_referer( 'frm_ajax', 'nonce' );
278
+		check_ajax_referer( 'frm_ajax', 'nonce' );
279 279
 
280 280
 		$element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
281 281
 		$ids = explode( '-', $element_id );
@@ -283,43 +283,43 @@  discard block
 block discarded – undo
283 283
 
284 284
 		$orig_update_value = $update_value = trim( FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ) );
285 285
 		if ( strpos( $element_id, 'key_' ) ) {
286
-            $new_value = $update_value;
287
-        } else {
288
-            $new_label = $update_value;
289
-        }
286
+			$new_value = $update_value;
287
+		} else {
288
+			$new_label = $update_value;
289
+		}
290 290
 
291
-        $field = FrmField::getOne($id);
292
-        $separate_values = FrmField::is_option_true( $field, 'separate_value' );
291
+		$field = FrmField::getOne($id);
292
+		$separate_values = FrmField::is_option_true( $field, 'separate_value' );
293 293
 
294
-        $this_opt_id = end($ids);
294
+		$this_opt_id = end($ids);
295 295
 		$this_opt = (array) $field->options[ $this_opt_id ];
296 296
 		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false );
297 297
 
298
-        $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
299
-        $value = isset($this_opt['value']) ? $this_opt['value'] : '';
298
+		$label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
299
+		$value = isset($this_opt['value']) ? $this_opt['value'] : '';
300 300
 
301
-        if ( ! isset( $new_label ) ) {
302
-            $new_label = $label;
303
-        }
301
+		if ( ! isset( $new_label ) ) {
302
+			$new_label = $label;
303
+		}
304 304
 
305
-        if ( isset($new_value) || isset($value) ) {
306
-            $update_value = isset($new_value) ? $new_value : $value;
307
-        }
305
+		if ( isset($new_value) || isset($value) ) {
306
+			$update_value = isset($new_value) ? $new_value : $value;
307
+		}
308 308
 
309 309
 		if ( $update_value != $new_label && $other_opt === false && $separate_values ) {
310 310
 			$field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label );
311
-        } else {
311
+		} else {
312 312
 			$field->options[ $this_opt_id ] = $orig_update_value;
313
-        }
313
+		}
314 314
 
315 315
 		FrmField::update( $field->id, array( 'options' => $field->options ) );
316 316
 		echo ( $orig_update_value == '' ) ? esc_html__( '(Blank)', 'formidable' ) : stripslashes( $orig_update_value );
317
-        wp_die();
318
-    }
317
+		wp_die();
318
+	}
319 319
 
320
-    public static function delete_option() {
320
+	public static function delete_option() {
321 321
 		FrmAppHelper::permission_check('frm_edit_forms');
322
-        check_ajax_referer( 'frm_ajax', 'nonce' );
322
+		check_ajax_referer( 'frm_ajax', 'nonce' );
323 323
 
324 324
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
325 325
 		$field = FrmField::getOne( $field_id );
@@ -327,307 +327,307 @@  discard block
 block discarded – undo
327 327
 		$opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' );
328 328
 
329 329
 		$options = $field->options;
330
-        unset( $options[ $opt_key ] );
331
-        $response = array( 'other' => true );
330
+		unset( $options[ $opt_key ] );
331
+		$response = array( 'other' => true );
332 332
 
333
-        //If the deleted option is an "other" option
333
+		//If the deleted option is an "other" option
334 334
 		if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
335
-            //Assume all other options are gone, unless proven otherwise
336
-            $other = false;
335
+			//Assume all other options are gone, unless proven otherwise
336
+			$other = false;
337 337
 
338
-            //Check if all other options are really gone
339
-            foreach ( $options as $o_key => $o_val ) {
340
-                //If there is still an other option in the field, set other to true
338
+			//Check if all other options are really gone
339
+			foreach ( $options as $o_key => $o_val ) {
340
+				//If there is still an other option in the field, set other to true
341 341
 				if ( FrmFieldsHelper::is_other_opt( $o_key ) ) {
342
-                    $other = true;
343
-                    break;
344
-                }
345
-                unset( $o_key, $o_val );
346
-            }
347
-
348
-            //If all other options are gone
349
-            if ( false === $other ) {
350
-                $field_options = maybe_unserialize( $field->field_options );
351
-                $field_options['other'] = 0;
342
+					$other = true;
343
+					break;
344
+				}
345
+				unset( $o_key, $o_val );
346
+			}
347
+
348
+			//If all other options are gone
349
+			if ( false === $other ) {
350
+				$field_options = maybe_unserialize( $field->field_options );
351
+				$field_options['other'] = 0;
352 352
 				FrmField::update( $field_id, array( 'field_options' => maybe_serialize( $field_options ) ) );
353
-                $response = array( 'other' => false );
354
-            }
355
-        }
356
-        echo json_encode( $response );
353
+				$response = array( 'other' => false );
354
+			}
355
+		}
356
+		echo json_encode( $response );
357 357
 
358 358
 		FrmField::update( $field_id, array( 'options' => maybe_serialize( $options ) ) );
359 359
 
360
-        wp_die();
361
-    }
360
+		wp_die();
361
+	}
362 362
 
363
-    public static function import_choices() {
364
-        FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
363
+	public static function import_choices() {
364
+		FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
365 365
 
366 366
 		$field_id = absint( $_REQUEST['field_id'] );
367 367
 
368
-        global $current_screen, $hook_suffix;
368
+		global $current_screen, $hook_suffix;
369 369
 
370
-        // Catch plugins that include admin-header.php before admin.php completes.
371
-        if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
372
-            $hook_suffix = '';
373
-        	set_current_screen();
374
-        }
370
+		// Catch plugins that include admin-header.php before admin.php completes.
371
+		if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
372
+			$hook_suffix = '';
373
+			set_current_screen();
374
+		}
375 375
 
376
-        if ( function_exists( 'register_admin_color_schemes' ) ) {
377
-            register_admin_color_schemes();
378
-        }
376
+		if ( function_exists( 'register_admin_color_schemes' ) ) {
377
+			register_admin_color_schemes();
378
+		}
379 379
 
380
-        $hook_suffix = $admin_body_class = '';
380
+		$hook_suffix = $admin_body_class = '';
381 381
 
382
-        if ( get_user_setting( 'mfold' ) == 'f' ) {
383
-        	$admin_body_class .= ' folded';
384
-        }
382
+		if ( get_user_setting( 'mfold' ) == 'f' ) {
383
+			$admin_body_class .= ' folded';
384
+		}
385 385
 
386
-        if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
387
-        	$admin_body_class .= ' admin-bar';
388
-        }
386
+		if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
387
+			$admin_body_class .= ' admin-bar';
388
+		}
389 389
 
390
-        if ( is_rtl() ) {
391
-        	$admin_body_class .= ' rtl';
392
-        }
390
+		if ( is_rtl() ) {
391
+			$admin_body_class .= ' rtl';
392
+		}
393 393
 
394
-        $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
395
-        $prepop = array();
396
-        FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
394
+		$admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
395
+		$prepop = array();
396
+		FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
397 397
 
398
-        $field = FrmField::getOne($field_id);
398
+		$field = FrmField::getOne($field_id);
399 399
 
400
-        wp_enqueue_script( 'utils' );
400
+		wp_enqueue_script( 'utils' );
401 401
 		wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' );
402
-        FrmAppHelper::load_admin_wide_js();
402
+		FrmAppHelper::load_admin_wide_js();
403 403
 
404 404
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' );
405
-        wp_die();
406
-    }
405
+		wp_die();
406
+	}
407 407
 
408
-    public static function import_options() {
408
+	public static function import_options() {
409 409
 		FrmAppHelper::permission_check('frm_edit_forms');
410
-        check_ajax_referer( 'frm_ajax', 'nonce' );
410
+		check_ajax_referer( 'frm_ajax', 'nonce' );
411 411
 
412
-        if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
413
-            return;
414
-        }
412
+		if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
413
+			return;
414
+		}
415 415
 
416 416
 		$field_id = absint( $_POST['field_id'] );
417
-        $field = FrmField::getOne($field_id);
417
+		$field = FrmField::getOne($field_id);
418 418
 
419 419
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
420
-            return;
421
-        }
420
+			return;
421
+		}
422 422
 
423
-        $field = FrmFieldsHelper::setup_edit_vars($field);
423
+		$field = FrmFieldsHelper::setup_edit_vars($field);
424 424
 		$opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' );
425 425
 		$opts = explode( "\n", rtrim( $opts, "\n" ) );
426 426
 		$opts = array_map( 'trim', $opts );
427 427
 
428
-        if ( $field['separate_value'] ) {
429
-            foreach ( $opts as $opt_key => $opt ) {
430
-                if ( strpos($opt, '|') !== false ) {
431
-                    $vals = explode('|', $opt);
432
-                    if ( $vals[0] != $vals[1] ) {
433
-                        $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
434
-                    }
435
-                    unset($vals);
436
-                }
437
-                unset($opt_key, $opt);
438
-            }
439
-        }
440
-
441
-        //Keep other options after bulk update
442
-        if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
443
-            $other_array = array();
444
-            foreach ( $field['options'] as $opt_key => $opt ) {
445
-                if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
446
-                    $other_array[ $opt_key ] = $opt;
447
-                }
448
-                unset($opt_key, $opt);
449
-            }
450
-            if ( ! empty($other_array) ) {
451
-                $opts = array_merge( $opts, $other_array);
452
-            }
453
-        }
454
-
455
-        FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) );
456
-
457
-        $field['options'] = $opts;
458
-        $field_name = $field['name'];
459
-
460
-        // Get html_id which will be used in single-option.php
461
-        $html_id = FrmFieldsHelper::get_html_id( $field );
462
-
463
-        if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
428
+		if ( $field['separate_value'] ) {
429
+			foreach ( $opts as $opt_key => $opt ) {
430
+				if ( strpos($opt, '|') !== false ) {
431
+					$vals = explode('|', $opt);
432
+					if ( $vals[0] != $vals[1] ) {
433
+						$opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
434
+					}
435
+					unset($vals);
436
+				}
437
+				unset($opt_key, $opt);
438
+			}
439
+		}
440
+
441
+		//Keep other options after bulk update
442
+		if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
443
+			$other_array = array();
444
+			foreach ( $field['options'] as $opt_key => $opt ) {
445
+				if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
446
+					$other_array[ $opt_key ] = $opt;
447
+				}
448
+				unset($opt_key, $opt);
449
+			}
450
+			if ( ! empty($other_array) ) {
451
+				$opts = array_merge( $opts, $other_array);
452
+			}
453
+		}
454
+
455
+		FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) );
456
+
457
+		$field['options'] = $opts;
458
+		$field_name = $field['name'];
459
+
460
+		// Get html_id which will be used in single-option.php
461
+		$html_id = FrmFieldsHelper::get_html_id( $field );
462
+
463
+		if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
464 464
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' );
465
-        } else {
466
-            FrmFieldsHelper::show_single_option($field);
467
-        }
465
+		} else {
466
+			FrmFieldsHelper::show_single_option($field);
467
+		}
468 468
 
469
-        wp_die();
470
-    }
469
+		wp_die();
470
+	}
471 471
 
472
-    public static function update_order() {
472
+	public static function update_order() {
473 473
 		FrmAppHelper::permission_check('frm_edit_forms');
474
-        check_ajax_referer( 'frm_ajax', 'nonce' );
474
+		check_ajax_referer( 'frm_ajax', 'nonce' );
475 475
 
476 476
 		$fields = FrmAppHelper::get_post_param( 'frm_field_id' );
477 477
 		foreach ( (array) $fields as $position => $item ) {
478 478
 			FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) );
479 479
 		}
480
-        wp_die();
481
-    }
480
+		wp_die();
481
+	}
482 482
 
483 483
 	public static function change_type( $type ) {
484
-        $type_switch = array(
485
-            'scale'     => 'radio',
486
-            '10radio'   => 'radio',
487
-            'rte'       => 'textarea',
488
-            'website'   => 'url',
489
-        );
490
-        if ( isset( $type_switch[ $type ] ) ) {
491
-            $type = $type_switch[ $type ];
492
-        }
484
+		$type_switch = array(
485
+			'scale'     => 'radio',
486
+			'10radio'   => 'radio',
487
+			'rte'       => 'textarea',
488
+			'website'   => 'url',
489
+		);
490
+		if ( isset( $type_switch[ $type ] ) ) {
491
+			$type = $type_switch[ $type ];
492
+		}
493 493
 
494 494
 		$frm_field_selection = FrmField::field_selection();
495
-        $types = array_keys($frm_field_selection);
496
-        if ( ! in_array($type, $types) && $type != 'captcha' ) {
497
-            $type = 'text';
498
-        }
495
+		$types = array_keys($frm_field_selection);
496
+		if ( ! in_array($type, $types) && $type != 'captcha' ) {
497
+			$type = 'text';
498
+		}
499 499
 
500
-        return $type;
501
-    }
500
+		return $type;
501
+	}
502 502
 
503 503
 	public static function display_field_options( $display ) {
504 504
 		switch ( $display['type'] ) {
505
-            case 'captcha':
506
-                $display['required'] = false;
507
-                $display['invalid'] = true;
508
-                $display['default_blank'] = false;
505
+			case 'captcha':
506
+				$display['required'] = false;
507
+				$display['invalid'] = true;
508
+				$display['default_blank'] = false;
509 509
 				$display['captcha_size'] = true;
510
-            break;
511
-            case 'radio':
512
-                $display['default_blank'] = false;
513
-            break;
514
-            case 'text':
515
-            case 'textarea':
516
-                $display['size'] = true;
517
-                $display['clear_on_focus'] = true;
518
-            break;
519
-            case 'select':
520
-                $display['size'] = true;
521
-            break;
522
-            case 'url':
523
-            case 'website':
524
-            case 'email':
525
-                $display['size'] = true;
526
-                $display['clear_on_focus'] = true;
527
-                $display['invalid'] = true;
528
-        }
529
-
530
-        return $display;
531
-    }
532
-
533
-    public static function input_html( $field, $echo = true ) {
534
-        $class = array(); //$field['type'];
535
-        self::add_input_classes($field, $class);
536
-
537
-        $add_html = array();
538
-        self::add_html_size($field, $add_html);
539
-        self::add_html_length($field, $add_html);
540
-        self::add_html_placeholder($field, $add_html, $class);
510
+			break;
511
+			case 'radio':
512
+				$display['default_blank'] = false;
513
+			break;
514
+			case 'text':
515
+			case 'textarea':
516
+				$display['size'] = true;
517
+				$display['clear_on_focus'] = true;
518
+			break;
519
+			case 'select':
520
+				$display['size'] = true;
521
+			break;
522
+			case 'url':
523
+			case 'website':
524
+			case 'email':
525
+				$display['size'] = true;
526
+				$display['clear_on_focus'] = true;
527
+				$display['invalid'] = true;
528
+		}
529
+
530
+		return $display;
531
+	}
532
+
533
+	public static function input_html( $field, $echo = true ) {
534
+		$class = array(); //$field['type'];
535
+		self::add_input_classes($field, $class);
536
+
537
+		$add_html = array();
538
+		self::add_html_size($field, $add_html);
539
+		self::add_html_length($field, $add_html);
540
+		self::add_html_placeholder($field, $add_html, $class);
541 541
 		self::add_validation_messages( $field, $add_html );
542 542
 
543
-        $class = apply_filters('frm_field_classes', implode(' ', $class), $field);
543
+		$class = apply_filters('frm_field_classes', implode(' ', $class), $field);
544 544
 
545 545
 		FrmFormsHelper::add_html_attr( $class, 'class', $add_html );
546 546
 
547
-        self::add_shortcodes_to_html($field, $add_html);
547
+		self::add_shortcodes_to_html($field, $add_html);
548 548
 
549 549
 		$add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
550 550
 		$add_html = ' ' . implode( ' ', $add_html ) . '  ';
551 551
 
552
-        if ( $echo ) {
553
-            echo $add_html;
554
-        }
552
+		if ( $echo ) {
553
+			echo $add_html;
554
+		}
555 555
 
556
-        return $add_html;
557
-    }
556
+		return $add_html;
557
+	}
558 558
 
559 559
 	private static function add_input_classes( $field, array &$class ) {
560
-        if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
561
-            $class[] = $field['input_class'];
562
-        }
560
+		if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
561
+			$class[] = $field['input_class'];
562
+		}
563 563
 
564
-        if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
565
-            return;
566
-        }
564
+		if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
565
+			return;
566
+		}
567 567
 
568
-        if ( isset($field['size']) && $field['size'] > 0 ) {
569
-            $class[] = 'auto_width';
570
-        }
571
-    }
568
+		if ( isset($field['size']) && $field['size'] > 0 ) {
569
+			$class[] = 'auto_width';
570
+		}
571
+	}
572 572
 
573 573
 	private static function add_html_size( $field, array &$add_html ) {
574 574
 		if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden', 'file', 'lookup' ) ) ) {
575
-            return;
576
-        }
575
+			return;
576
+		}
577 577
 
578
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
579
-            return;
580
-        }
578
+		if ( FrmAppHelper::is_admin_page('formidable' ) ) {
579
+			return;
580
+		}
581 581
 
582
-        if ( is_numeric($field['size']) ) {
583
-            $field['size'] .= 'px';
584
-        }
582
+		if ( is_numeric($field['size']) ) {
583
+			$field['size'] .= 'px';
584
+		}
585 585
 
586
-        $important = apply_filters('frm_use_important_width', 1, $field);
587
-        // Note: This inline styling must stay since we cannot realistically set a class for every possible field size
586
+		$important = apply_filters('frm_use_important_width', 1, $field);
587
+		// Note: This inline styling must stay since we cannot realistically set a class for every possible field size
588 588
 		$add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"';
589 589
 
590
-        self::add_html_cols($field, $add_html);
591
-    }
590
+		self::add_html_cols($field, $add_html);
591
+	}
592 592
 
593 593
 	private static function add_html_cols( $field, array &$add_html ) {
594 594
 		if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) {
595
-            return;
596
-        }
595
+			return;
596
+		}
597 597
 
598
-        // convert to cols for textareas
599
-        $calc = array(
600
-            ''      => 9,
601
-            'px'    => 9,
602
-            'rem'   => 0.444,
603
-            'em'    => 0.544,
604
-        );
598
+		// convert to cols for textareas
599
+		$calc = array(
600
+			''      => 9,
601
+			'px'    => 9,
602
+			'rem'   => 0.444,
603
+			'em'    => 0.544,
604
+		);
605 605
 
606
-        // include "col" for valid html
607
-        $unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
606
+		// include "col" for valid html
607
+		$unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
608 608
 
609
-        if ( ! isset( $calc[ $unit ] ) ) {
610
-            return;
611
-        }
609
+		if ( ! isset( $calc[ $unit ] ) ) {
610
+			return;
611
+		}
612 612
 
613
-        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
613
+		$size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
614 614
 
615 615
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
616
-    }
616
+	}
617 617
 
618 618
 	private static function add_html_length( $field, array &$add_html ) {
619
-        // check for max setting and if this field accepts maxlength
619
+		// check for max setting and if this field accepts maxlength
620 620
 		if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden', 'file' ) ) ) {
621
-            return;
622
-        }
621
+			return;
622
+		}
623 623
 
624
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
625
-            // don't load on form builder page
626
-            return;
627
-        }
624
+		if ( FrmAppHelper::is_admin_page('formidable' ) ) {
625
+			// don't load on form builder page
626
+			return;
627
+		}
628 628
 
629 629
 		$add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"';
630
-    }
630
+	}
631 631
 
632 632
 	private static function add_html_placeholder( $field, array &$add_html, array &$class ) {
633 633
 		if ( empty( $field['default_value'] ) || FrmAppHelper::is_admin_page( 'formidable' ) ) {
@@ -635,35 +635,35 @@  discard block
 block discarded – undo
635 635
 		}
636 636
 
637 637
 		$default_value_array = is_array( $field['default_value'] );
638
-        if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
638
+		if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
639 639
 			if ( $default_value_array ) {
640 640
 				$field['default_value'] = json_encode( $field['default_value'] );
641 641
 			}
642 642
 			$add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"';
643
-            return;
644
-        }
643
+			return;
644
+		}
645 645
 
646 646
 		if ( $default_value_array ) {
647 647
 			// don't include a json placeholder
648 648
 			return;
649 649
 		}
650 650
 
651
-        $frm_settings = FrmAppHelper::get_settings();
651
+		$frm_settings = FrmAppHelper::get_settings();
652 652
 
653 653
 		if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) {
654
-            // use HMTL5 placeholder with js fallback
654
+			// use HMTL5 placeholder with js fallback
655 655
 			$add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"';
656
-            wp_enqueue_script('jquery-placeholder');
657
-        } else if ( ! $frm_settings->use_html ) {
656
+			wp_enqueue_script('jquery-placeholder');
657
+		} else if ( ! $frm_settings->use_html ) {
658 658
 			$val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( '&#039;', "'", esc_attr( $field['default_value'] ) ) ) );
659 659
 			$add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"';
660
-            $class[] = 'frm_toggle_default';
660
+			$class[] = 'frm_toggle_default';
661 661
 
662
-            if ( $field['value'] == $field['default_value'] ) {
663
-                $class[] = 'frm_default';
664
-            }
665
-        }
666
-    }
662
+			if ( $field['value'] == $field['default_value'] ) {
663
+				$class[] = 'frm_default';
664
+			}
665
+		}
666
+	}
667 667
 
668 668
 	private static function add_validation_messages( $field, array &$add_html ) {
669 669
 		if ( FrmField::is_required( $field ) ) {
@@ -677,44 +677,44 @@  discard block
 block discarded – undo
677 677
 		}
678 678
 	}
679 679
 
680
-    private static function add_shortcodes_to_html( $field, array &$add_html ) {
681
-        if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
682
-            return;
683
-        }
680
+	private static function add_shortcodes_to_html( $field, array &$add_html ) {
681
+		if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
682
+			return;
683
+		}
684 684
 
685
-        foreach ( $field['shortcodes'] as $k => $v ) {
686
-            if ( 'opt' === $k ) {
687
-                continue;
688
-            }
685
+		foreach ( $field['shortcodes'] as $k => $v ) {
686
+			if ( 'opt' === $k ) {
687
+				continue;
688
+			}
689 689
 
690
-            if ( is_numeric($k) && strpos($v, '=') ) {
691
-                $add_html[] = $v;
692
-            } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
690
+			if ( is_numeric($k) && strpos($v, '=') ) {
691
+				$add_html[] = $v;
692
+			} else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
693 693
 				$add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] );
694
-            } else {
694
+			} else {
695 695
 				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
696
-            }
697
-
698
-            unset($k, $v);
699
-        }
700
-    }
701
-
702
-    public static function check_value( $opt, $opt_key, $field ) {
703
-        if ( is_array( $opt ) ) {
704
-            if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
705
-                $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
706
-            } else {
707
-                $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
708
-            }
709
-        }
710
-        return $opt;
711
-    }
696
+			}
697
+
698
+			unset($k, $v);
699
+		}
700
+	}
701
+
702
+	public static function check_value( $opt, $opt_key, $field ) {
703
+		if ( is_array( $opt ) ) {
704
+			if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
705
+				$opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
706
+			} else {
707
+				$opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
708
+			}
709
+		}
710
+		return $opt;
711
+	}
712 712
 
713 713
 	public static function check_label( $opt ) {
714
-        if ( is_array($opt) ) {
715
-            $opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
716
-        }
714
+		if ( is_array($opt) ) {
715
+			$opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
716
+		}
717 717
 
718
-        return $opt;
719
-    }
718
+		return $opt;
719
+	}
720 720
 }
Please login to merge, or discard this patch.
classes/views/frm-forms/add_field.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-$display = apply_filters('frm_display_field_options', array(
3
+$display = apply_filters( 'frm_display_field_options', array(
4 4
     'type' => $field['type'], 'field_data' => $field,
5 5
     'required' => true, 'unique' => false, 'read_only' => false,
6 6
     'description' => true, 'options' => true, 'label_position' => true,
7 7
     'invalid' => false, 'size' => false, 'clear_on_focus' => false,
8 8
     'default_blank' => true, 'css' => true, 'conf_field' => false,
9 9
 	'max' => true, 'captcha_size' => false,
10
-));
10
+) );
11 11
 
12 12
 $li_classes = 'form-field edit_form_item frm_field_box frm_top_container frm_not_divider edit_field_type_' . $display['type'];
13
-$li_classes = apply_filters('frm_build_field_class', $li_classes, $field );
13
+$li_classes = apply_filters( 'frm_build_field_class', $li_classes, $field );
14 14
 
15 15
 if ( isset( $values ) && isset( $values['ajax_load'] ) && $values['ajax_load'] && isset( $count ) && $count > 10 && ! in_array( $field['type'], array( 'divider', 'end_divider' ) ) ) {
16 16
 ?>
17 17
 <li id="frm_field_id_<?php echo esc_attr( $field['id'] ); ?>" class="<?php echo esc_attr( $li_classes ) ?> frm_field_loading" data-fid="<?php echo esc_attr( $field['id'] ) ?>" data-formid="<?php echo esc_attr( 'divider' == $field['type'] ? $field['form_select'] : $field['form_id'] ); ?>" data-ftype="<?php echo esc_attr( $display['type'] ) ?>">
18 18
 <img src="<?php echo FrmAppHelper::plugin_url() ?>/images/ajax_loader.gif" alt="<?php esc_attr_e( 'Loading', 'formidable' ) ?>" />
19
-<span class="frm_hidden_fdata frm_hidden"><?php echo htmlspecialchars(json_encode($field)) ?></span>
19
+<span class="frm_hidden_fdata frm_hidden"><?php echo htmlspecialchars( json_encode( $field ) ) ?></span>
20 20
 </li>
21 21
 <?php
22 22
    return;
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
 $frm_settings = FrmAppHelper::get_settings();
26 26
 
27 27
 if ( ! isset( $frm_all_field_selection ) ) {
28
-    if ( isset($frm_field_selection) && isset($pro_field_selection) ) {
29
-        $frm_all_field_selection = array_merge($frm_field_selection, $pro_field_selection);
28
+    if ( isset( $frm_field_selection ) && isset( $pro_field_selection ) ) {
29
+        $frm_all_field_selection = array_merge( $frm_field_selection, $pro_field_selection );
30 30
     } else {
31 31
 		$pro_field_selection = FrmField::pro_field_selection();
32 32
 		$frm_all_field_selection = array_merge( FrmField::field_selection(), $pro_field_selection );
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
     <a href="javascript:void(0);" class="frm_bstooltip alignright frm-show-hover frm-move frm-hover-icon frm_icon_font frm_move_icon" title="<?php esc_attr_e( 'Move Field', 'formidable' ) ?>"> </a>
52 52
     <a href="#" class="frm_bstooltip alignright frm-show-hover frm-hover-icon frm_icon_font frm_delete_icon frm_delete_field" title="<?php esc_attr_e( 'Delete Field', 'formidable' ) ?>"> </a>
53 53
     <a href="#" class="frm_bstooltip alignright frm-show-hover frm-hover-icon frm_icon_font frm_duplicate_icon" title="<?php ( $field['type'] == 'divider' ) ? esc_attr_e( 'Duplicate Section', 'formidable' ) : esc_attr_e( 'Duplicate Field', 'formidable' ) ?>"> </a>
54
-    <input type="hidden" name="frm_fields_submitted[]" value="<?php echo esc_attr($field['id']) ?>" />
55
-    <?php do_action('frm_extra_field_actions', $field['id']); ?>
54
+    <input type="hidden" name="frm_fields_submitted[]" value="<?php echo esc_attr( $field['id'] ) ?>" />
55
+    <?php do_action( 'frm_extra_field_actions', $field['id'] ); ?>
56 56
     <?php if ( $display['required'] ) { ?>
57 57
     <span id="require_field_<?php echo esc_attr( $field['id'] ); ?>">
58 58
 		<a href="javascript:void(0);" class="frm_req_field frm_action_icon frm_required_icon frm_icon_font alignleft frm_required<?php echo (int) $field['required'] ?>" id="req_field_<?php echo esc_attr( $field['id'] ); ?>" title="Click to Mark as <?php echo FrmField::is_required( $field ) ? 'not ' : ''; ?>Required"></a>
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     <?php }
61 61
 
62 62
     ?>
63
-    <label class="<?php echo ( $field['type'] == 'end_divider' ) ? '' : 'frm_ipe_field_label'; ?> frm_primary_label <?php echo ( $field['type'] == 'break' ) ? 'button': ''; ?>" id="field_label_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ( $field['name'] == '' ) ? __( '(no label)', 'formidable' ) : force_balance_tags( $field['name'] ); ?></label>
63
+    <label class="<?php echo ( $field['type'] == 'end_divider' ) ? '' : 'frm_ipe_field_label'; ?> frm_primary_label <?php echo ( $field['type'] == 'break' ) ? 'button' : ''; ?>" id="field_label_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ( $field['name'] == '' ) ? __( '(no label)', 'formidable' ) : force_balance_tags( $field['name'] ); ?></label>
64 64
 
65 65
 
66 66
 <div id="field_<?php echo esc_attr( $field['id'] ) ?>_inner_container" class="frm_inner_field_container">
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 </div>
79 79
 <?php
80 80
 if ( $display['description'] ) { ?>
81
-    <div class="frm_ipe_field_desc description <?php echo ($field['description'] == '') ? 'frm-show-click' : '' ?>" id="field_description_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ($field['description'] == '') ? __( '(Click to add description)', 'formidable' ) : force_balance_tags( $field['description'] ); ?></div>
81
+    <div class="frm_ipe_field_desc description <?php echo ( $field['description'] == '' ) ? 'frm-show-click' : '' ?>" id="field_description_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ( $field['description'] == '' ) ? __( '(Click to add description)', 'formidable' ) : force_balance_tags( $field['description'] ); ?></div>
82 82
     <input type="hidden" name="field_options[description_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['description'] ); ?>" />
83 83
 
84 84
 <?php } ?>
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
 		<div class="frm_form_fields">
91 91
 			<input type="text" id="conf_field_<?php echo esc_attr( $field['field_key'] ) ?>" name="field_options[conf_input_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['conf_input'] ); ?>" class="dyn_default_value" />
92 92
 		</div>
93
-    	<div id="conf_field_description_<?php echo esc_attr( $field['id'] ) ?>" class="frm_ipe_field_conf_desc description <?php echo ($field['conf_desc'] == '') ? 'frm-show-click' : '' ?>"><?php
94
-			echo ($field['conf_desc'] == '') ? __( '(Click to add description)', 'formidable' ) : force_balance_tags($field['conf_desc']); ?></div>
93
+    	<div id="conf_field_description_<?php echo esc_attr( $field['id'] ) ?>" class="frm_ipe_field_conf_desc description <?php echo ( $field['conf_desc'] == '' ) ? 'frm-show-click' : '' ?>"><?php
94
+			echo ( $field['conf_desc'] == '' ) ? __( '(Click to add description)', 'formidable' ) : force_balance_tags( $field['conf_desc'] ); ?></div>
95 95
     	<input type="hidden" name="field_options[conf_desc_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['conf_desc'] ); ?>" />
96 96
 </div>
97 97
 	<?php if ( $display['clear_on_focus'] ) { ?>
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 if ( in_array( $field['type'], array( 'select', 'radio', 'checkbox' ) ) ) { ?>
107 107
     <div class="frm-show-click frm_small_top_margin"><?php
108 108
 
109
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
109
+    if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) {
110 110
 		echo '<p class="howto">' . FrmFieldsHelper::get_term_link( $field['taxonomy'] ) . '</p>';
111 111
 	} else if ( ! isset( $field['post_field'] ) || ! in_array( $field['post_field'], array( 'post_category' ) ) ) {
112 112
 ?>
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
             <?php
121 121
             }
122 122
 
123
-            if ( ! isset($field['post_field']) || $field['post_field'] != 'post_category' ) { ?>
123
+            if ( ! isset( $field['post_field'] ) || $field['post_field'] != 'post_category' ) { ?>
124 124
 			<a href="<?php echo esc_url( admin_url( 'admin-ajax.php?action=frm_import_choices&field_id=' . $field['id'] . '&TB_iframe=1' ) ) ?>" title="<?php echo esc_attr( FrmAppHelper::truncate( strip_tags( str_replace( '"', '&quot;', $field['name'] ) ), 20 ) . ' ' . __( 'Field Choices', 'formidable' ) ); ?>" class="thickbox frm_orange">
125 125
 				<?php _e( 'Bulk Edit Options', 'formidable' ) ?>
126 126
 			</a>
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 <?php
134 134
 }
135 135
 
136
-do_action('frm_before_field_options', $field);
136
+do_action( 'frm_before_field_options', $field );
137 137
 
138 138
 if ( $display['options'] ) { ?>
139 139
     <div class="widget">
@@ -143,13 +143,13 @@  discard block
 block discarded – undo
143 143
         </div>
144 144
     	<div class="widget-inside">
145 145
             <table class="form-table frm_clear_none">
146
-                <?php $field_types = FrmFieldsHelper::get_field_types($field['type']); ?>
146
+                <?php $field_types = FrmFieldsHelper::get_field_types( $field['type'] ); ?>
147 147
 				<tr><td class="frm_150_width"><label><?php _e( 'Field Type', 'formidable' ) ?></label></td>
148 148
                     <td>
149
-                <select <?php if ( count($field_types) == 1 ) { ?>disabled="disabled"<?php } else { ?>name="field_options[type_<?php echo esc_attr( $field['id'] ) ?>]"<?php } ?>>
149
+                <select <?php if ( count( $field_types ) == 1 ) { ?>disabled="disabled"<?php } else { ?>name="field_options[type_<?php echo esc_attr( $field['id'] ) ?>]"<?php } ?>>
150 150
                     <?php
151 151
 					foreach ( $field_types as $fkey => $ftype ) { ?>
152
-                        <option value="<?php echo esc_attr( $fkey ) ?>" <?php echo ( $fkey == $field['type'] ) ? ' selected="selected"' : ''; ?> <?php echo array_key_exists($fkey, $disabled_fields ) ? 'disabled="disabled"' : '';  ?>><?php echo is_array($ftype) ? $ftype['name'] : $ftype ?> </option>
152
+                        <option value="<?php echo esc_attr( $fkey ) ?>" <?php echo ( $fkey == $field['type'] ) ? ' selected="selected"' : ''; ?> <?php echo array_key_exists( $fkey, $disabled_fields ) ? 'disabled="disabled"' : ''; ?>><?php echo is_array( $ftype ) ? $ftype['name'] : $ftype ?> </option>
153 153
                     <?php
154 154
 						unset( $fkey, $ftype );
155 155
 					} ?>
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 				</label>
185 185
                 <?php }
186 186
 
187
-                do_action('frm_field_options_form_top', $field, $display, $values);
187
+                do_action( 'frm_field_options_form_top', $field, $display, $values );
188 188
 
189 189
                 ?>
190 190
                 <?php
@@ -221,13 +221,13 @@  discard block
 block discarded – undo
221 221
 				if ( $display['label_position'] ) { ?>
222 222
                     <tr><td class="frm_150_width"><label><?php _e( 'Label Position', 'formidable' ) ?></label></td>
223 223
                         <td><select name="field_options[label_<?php echo esc_attr( $field['id'] ) ?>]">
224
-                            <option value=""<?php selected($field['label'], ''); ?>><?php _e( 'Default', 'formidable' ) ?></option>
225
-                            <option value="top"<?php selected($field['label'], 'top'); ?>><?php _e( 'Top', 'formidable' ) ?></option>
226
-                            <option value="left"<?php selected($field['label'], 'left'); ?>><?php _e( 'Left', 'formidable' ) ?></option>
227
-                            <option value="right"<?php selected($field['label'], 'right'); ?>><?php _e( 'Right', 'formidable' ) ?></option>
228
-                            <option value="inline"<?php selected($field['label'], 'inline'); ?>><?php _e( 'Inline (left without a set width)', 'formidable' ) ?></option>
229
-                            <option value="none"<?php selected($field['label'], 'none'); ?>><?php _e( 'None', 'formidable' ) ?></option>
230
-                            <option value="hidden"<?php selected($field['label'], 'hidden'); ?>><?php _e( 'Hidden (but leave the space)', 'formidable' ) ?></option>
224
+                            <option value=""<?php selected( $field['label'], '' ); ?>><?php _e( 'Default', 'formidable' ) ?></option>
225
+                            <option value="top"<?php selected( $field['label'], 'top' ); ?>><?php _e( 'Top', 'formidable' ) ?></option>
226
+                            <option value="left"<?php selected( $field['label'], 'left' ); ?>><?php _e( 'Left', 'formidable' ) ?></option>
227
+                            <option value="right"<?php selected( $field['label'], 'right' ); ?>><?php _e( 'Right', 'formidable' ) ?></option>
228
+                            <option value="inline"<?php selected( $field['label'], 'inline' ); ?>><?php _e( 'Inline (left without a set width)', 'formidable' ) ?></option>
229
+                            <option value="none"<?php selected( $field['label'], 'none' ); ?>><?php _e( 'None', 'formidable' ) ?></option>
230
+                            <option value="hidden"<?php selected( $field['label'], 'hidden' ); ?>><?php _e( 'Hidden (but leave the space)', 'formidable' ) ?></option>
231 231
                         </select>
232 232
                         </td>
233 233
                     </tr>
@@ -250,8 +250,8 @@  discard block
 block discarded – undo
250 250
 					<span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'Set the size of the captcha field. The compact option is best if your form is in a small area.', 'formidable' ) ?>" ></span>
251 251
                     </td>
252 252
                     <td><select name="field_options[captcha_size_<?php echo esc_attr( $field['id'] ) ?>]">
253
-                        <option value="default"<?php selected($field['captcha_size'], 'default'); ?>><?php _e( 'Default', 'formidable' ) ?></option>
254
-                        <option value="compact"<?php selected($field['captcha_size'], 'compact'); ?>><?php _e( 'Compact', 'formidable' ) ?></option>
253
+                        <option value="default"<?php selected( $field['captcha_size'], 'default' ); ?>><?php _e( 'Default', 'formidable' ) ?></option>
254
+                        <option value="compact"<?php selected( $field['captcha_size'], 'compact' ); ?>><?php _e( 'Compact', 'formidable' ) ?></option>
255 255
                     </select>
256 256
                     </td>
257 257
                 </tr>
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 				do_action( 'frm_field_options_form', $field, $display, $values );
274 274
 
275 275
                 if ( $display['required'] || $display['invalid'] || $display['unique'] || $display['conf_field'] ) { ?>
276
-					<tr class="frm_validation_msg <?php echo ($display['invalid'] || $field['required'] || FrmField::is_option_true( $field, 'unique' ) || FrmField::is_option_true( $field, 'conf_field' ) ) ? '' : 'frm_hidden'; ?>">
276
+					<tr class="frm_validation_msg <?php echo ( $display['invalid'] || $field['required'] || FrmField::is_option_true( $field, 'unique' ) || FrmField::is_option_true( $field, 'conf_field' ) ) ? '' : 'frm_hidden'; ?>">
277 277
 					<td colspan="2">
278 278
                     <div class="menu-settings">
279 279
                     <h3 class="frm_no_bg"><?php _e( 'Validation', 'formidable' ) ?></h3>
@@ -337,4 +337,4 @@  discard block
 block discarded – undo
337 337
 <?php
338 338
 }
339 339
 
340
-unset($display);
340
+unset( $display );
Please login to merge, or discard this patch.