Completed
Push — master ( 14d726...4e3bcd )
by Jamie
03:31
created
classes/helpers/FrmXMLHelper.php 2 patches
Indentation   +584 added lines, -584 removed lines patch added patch discarded remove patch
@@ -23,30 +23,30 @@  discard block
 block discarded – undo
23 23
 	}
24 24
 
25 25
 	public static function import_xml( $file ) {
26
-        $defaults = array(
27
-            'forms' => 0, 'fields' => 0, 'terms' => 0,
28
-            'posts' => 0, 'views' => 0, 'actions' => 0,
29
-            'styles' => 0,
30
-        );
31
-
32
-        $imported = array(
33
-            'imported' => $defaults,
26
+		$defaults = array(
27
+			'forms' => 0, 'fields' => 0, 'terms' => 0,
28
+			'posts' => 0, 'views' => 0, 'actions' => 0,
29
+			'styles' => 0,
30
+		);
31
+
32
+		$imported = array(
33
+			'imported' => $defaults,
34 34
 			'updated'  => $defaults,
35 35
 			'forms'    => array(),
36 36
 			'terms'    => array(),
37
-        );
37
+		);
38 38
 
39
-        unset($defaults);
39
+		unset($defaults);
40 40
 
41 41
 		if ( ! defined( 'WP_IMPORTING' ) ) {
42
-            define('WP_IMPORTING', true);
43
-        }
42
+			define('WP_IMPORTING', true);
43
+		}
44 44
 
45 45
 		if ( ! class_exists( 'DOMDocument' ) ) {
46
-            return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() );
47
-        }
46
+			return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() );
47
+		}
48 48
 
49
-        $dom = new DOMDocument;
49
+		$dom = new DOMDocument;
50 50
 		$success = $dom->loadXML( file_get_contents( $file ) );
51 51
 		if ( ! $success ) {
52 52
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
@@ -64,45 +64,45 @@  discard block
 block discarded – undo
64 64
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
65 65
 		}
66 66
 
67
-        // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
67
+		// add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
68 68
 		foreach ( array( 'term', 'form', 'view' ) as $item_type ) {
69
-            // grab cats, tags, and terms, or forms or posts
70
-            if ( isset($xml->{$item_type} ) ) {
69
+			// grab cats, tags, and terms, or forms or posts
70
+			if ( isset($xml->{$item_type} ) ) {
71 71
 				$function_name = 'import_xml_' . $item_type . 's';
72 72
 				$imported = self::$function_name( $xml->{$item_type}, $imported );
73 73
 				unset( $function_name, $xml->{$item_type} );
74
-            }
75
-        }
74
+			}
75
+		}
76 76
 
77
-	    $return = apply_filters('frm_importing_xml', $imported, $xml );
77
+		$return = apply_filters('frm_importing_xml', $imported, $xml );
78 78
 
79
-	    return $return;
80
-    }
79
+		return $return;
80
+	}
81 81
 
82 82
 	public static function import_xml_terms( $terms, $imported ) {
83
-        foreach ( $terms as $t ) {
83
+		foreach ( $terms as $t ) {
84 84
 			if ( term_exists((string) $t->term_slug, (string) $t->term_taxonomy) ) {
85
-			    continue;
85
+				continue;
86 86
 			}
87 87
 
88 88
 			$parent = self::get_term_parent_id( $t );
89 89
 
90 90
 			$term = wp_insert_term( (string) $t->term_name, (string) $t->term_taxonomy, array(
91
-                'slug'          => (string) $t->term_slug,
92
-                'description'   => (string) $t->term_description,
91
+				'slug'          => (string) $t->term_slug,
92
+				'description'   => (string) $t->term_description,
93 93
 				'parent'        => empty( $parent ) ? 0 : $parent,
94
-            ));
94
+			));
95 95
 
96 96
 			if ( $term && is_array( $term ) ) {
97
-                $imported['imported']['terms']++;
97
+				$imported['imported']['terms']++;
98 98
 				$imported['terms'][ (int) $t->term_id ] = $term['term_id'];
99
-            }
99
+			}
100 100
 
101 101
 			unset( $term, $t );
102 102
 		}
103 103
 
104 104
 		return $imported;
105
-    }
105
+	}
106 106
 
107 107
 	/**
108 108
 	 * @since 2.0.8
@@ -127,99 +127,99 @@  discard block
 block discarded – undo
127 127
 		self::put_child_forms_first( $forms );
128 128
 
129 129
 		foreach ( $forms as $item ) {
130
-            $form = array(
131
-                'id'            => (int) $item->id,
132
-                'form_key'      => (string) $item->form_key,
133
-                'name'          => (string) $item->name,
134
-                'description'   => (string) $item->description,
135
-                'options'       => (string) $item->options,
136
-                'logged_in'     => (int) $item->logged_in,
137
-                'is_template'   => (int) $item->is_template,
138
-                'default_template' => (int) $item->default_template,
139
-                'editable'      => (int) $item->editable,
140
-                'status'        => (string) $item->status,
141
-                'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0,
142
-                'created_at'    => date('Y-m-d H:i:s', strtotime((string) $item->created_at)),
143
-            );
144
-
145
-            $form['options'] = FrmAppHelper::maybe_json_decode($form['options']);
130
+			$form = array(
131
+				'id'            => (int) $item->id,
132
+				'form_key'      => (string) $item->form_key,
133
+				'name'          => (string) $item->name,
134
+				'description'   => (string) $item->description,
135
+				'options'       => (string) $item->options,
136
+				'logged_in'     => (int) $item->logged_in,
137
+				'is_template'   => (int) $item->is_template,
138
+				'default_template' => (int) $item->default_template,
139
+				'editable'      => (int) $item->editable,
140
+				'status'        => (string) $item->status,
141
+				'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0,
142
+				'created_at'    => date('Y-m-d H:i:s', strtotime((string) $item->created_at)),
143
+			);
144
+
145
+			$form['options'] = FrmAppHelper::maybe_json_decode($form['options']);
146 146
 
147 147
 			self::update_custom_style_setting_on_import( $form );
148 148
 
149
-            // if template, allow to edit if form keys match, otherwise, creation date must also match
149
+			// if template, allow to edit if form keys match, otherwise, creation date must also match
150 150
 			$edit_query = array( 'form_key' => $form['form_key'], 'is_template' => $form['is_template'] );
151
-            if ( ! $form['is_template'] ) {
152
-                $edit_query['created_at'] = $form['created_at'];
153
-            }
151
+			if ( ! $form['is_template'] ) {
152
+				$edit_query['created_at'] = $form['created_at'];
153
+			}
154 154
 
155
-            $edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
155
+			$edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
156 156
 
157
-            $this_form = FrmForm::getAll($edit_query, '', 1);
158
-            unset($edit_query);
157
+			$this_form = FrmForm::getAll($edit_query, '', 1);
158
+			unset($edit_query);
159 159
 
160
-            if ( ! empty( $this_form ) ) {
161
-                $old_id = $form_id = $this_form->id;
162
-                FrmForm::update($form_id, $form );
163
-                $imported['updated']['forms']++;
164
-                // Keep track of whether this specific form was updated or not
160
+			if ( ! empty( $this_form ) ) {
161
+				$old_id = $form_id = $this_form->id;
162
+				FrmForm::update($form_id, $form );
163
+				$imported['updated']['forms']++;
164
+				// Keep track of whether this specific form was updated or not
165 165
 				$imported['form_status'][ $form_id ] = 'updated';
166 166
 
167 167
 				$form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' );
168
-                $old_fields = array();
169
-                foreach ( $form_fields as $f ) {
168
+				$old_fields = array();
169
+				foreach ( $form_fields as $f ) {
170 170
 					$old_fields[ $f->id ] = $f;
171 171
 					$old_fields[ $f->field_key ] = $f->id;
172
-                    unset($f);
173
-                }
174
-                $form_fields = $old_fields;
175
-                unset($old_fields);
176
-            } else {
177
-                $old_id = false;
178
-                //form does not exist, so create it
172
+					unset($f);
173
+				}
174
+				$form_fields = $old_fields;
175
+				unset($old_fields);
176
+			} else {
177
+				$old_id = false;
178
+				//form does not exist, so create it
179 179
 				$form_id = FrmForm::create( $form );
180
-                if ( $form_id ) {
181
-                    $imported['imported']['forms']++;
182
-                    // Keep track of whether this specific form was updated or not
180
+				if ( $form_id ) {
181
+					$imported['imported']['forms']++;
182
+					// Keep track of whether this specific form was updated or not
183 183
 					$imported['form_status'][ $form_id ] = 'imported';
184 184
 					self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms );
185
-                }
186
-            }
185
+				}
186
+			}
187 187
 
188
-    		self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported );
188
+			self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported );
189 189
 
190
-    		// Delete any fields attached to this form that were not included in the template
191
-    		if ( isset( $form_fields ) && ! empty( $form_fields ) ) {
190
+			// Delete any fields attached to this form that were not included in the template
191
+			if ( isset( $form_fields ) && ! empty( $form_fields ) ) {
192 192
 				foreach ( $form_fields as $field ) {
193
-                    if ( is_object($field) ) {
194
-                        FrmField::destroy($field->id);
195
-                    }
196
-                    unset($field);
197
-                }
198
-                unset($form_fields);
199
-            }
200
-
201
-		    // Update field ids/keys to new ones
193
+					if ( is_object($field) ) {
194
+						FrmField::destroy($field->id);
195
+					}
196
+					unset($field);
197
+				}
198
+				unset($form_fields);
199
+			}
200
+
201
+			// Update field ids/keys to new ones
202 202
 			do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) );
203 203
 
204 204
 			$imported['forms'][ (int) $item->id ] = $form_id;
205 205
 
206
-            // Send pre 2.0 form options through function that creates actions
207
-            self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true );
206
+			// Send pre 2.0 form options through function that creates actions
207
+			self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true );
208 208
 
209
-		    unset($form, $item);
209
+			unset($form, $item);
210 210
 		}
211 211
 
212 212
 		self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms );
213 213
 
214 214
 		return $imported;
215
-    }
215
+	}
216 216
 
217 217
 	/**
218
-	* Put child forms first so they will be imported before parents
219
-	*
220
-	* @since 2.0.16
221
-	* @param array $forms
222
-	*/
218
+	 * Put child forms first so they will be imported before parents
219
+	 *
220
+	 * @since 2.0.16
221
+	 * @param array $forms
222
+	 */
223 223
 	private static function put_child_forms_first( &$forms ) {
224 224
 		$child_forms = array();
225 225
 		$regular_forms = array();
@@ -238,13 +238,13 @@  discard block
 block discarded – undo
238 238
 	}
239 239
 
240 240
 	/**
241
-	* Keep track of all imported child forms
242
-	*
243
-	* @since 2.0.16
244
-	* @param int $form_id
245
-	* @param int $parent_form_id
246
-	* @param array $child_forms
247
-	*/
241
+	 * Keep track of all imported child forms
242
+	 *
243
+	 * @since 2.0.16
244
+	 * @param int $form_id
245
+	 * @param int $parent_form_id
246
+	 * @param array $child_forms
247
+	 */
248 248
 	private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) {
249 249
 		if ( $parent_form_id ) {
250 250
 			$child_forms[ $form_id ] = $parent_form_id;
@@ -252,13 +252,13 @@  discard block
 block discarded – undo
252 252
 	}
253 253
 
254 254
 	/**
255
-	* Update the parent_form_id on imported child forms
256
-	* Child forms are imported first so their parent_form_id will need to be updated after the parent is imported
257
-	*
258
-	* @since 2.0.6
259
-	* @param array $imported_forms
260
-	* @param array $child_forms
261
-	*/
255
+	 * Update the parent_form_id on imported child forms
256
+	 * Child forms are imported first so their parent_form_id will need to be updated after the parent is imported
257
+	 *
258
+	 * @since 2.0.6
259
+	 * @param array $imported_forms
260
+	 * @param array $child_forms
261
+	 */
262 262
 	private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) {
263 263
 		foreach ( $child_forms as $child_form_id => $old_parent_form_id ) {
264 264
 
@@ -272,61 +272,61 @@  discard block
 block discarded – undo
272 272
 	}
273 273
 
274 274
 	/**
275
-	* Import all fields for a form
276
-	* @since 2.0.13
277
-	*
278
-	* TODO: Cut down on params
279
-	*/
275
+	 * Import all fields for a form
276
+	 * @since 2.0.13
277
+	 *
278
+	 * TODO: Cut down on params
279
+	 */
280 280
 	private static function import_xml_fields( $xml_fields, $form_id, $this_form, &$form_fields, &$imported ) {
281 281
 		foreach ( $xml_fields as $field ) {
282
-		    $f = array(
283
-		        'id'            => (int) $field->id,
284
-		        'field_key'     => (string) $field->field_key,
285
-		        'name'          => (string) $field->name,
286
-		        'description'   => (string) $field->description,
287
-		        'type'          => (string) $field->type,
288
-		        'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value),
289
-		        'field_order'   => (int) $field->field_order,
290
-		        'form_id'       => (int) $form_id,
291
-		        'required'      => (int) $field->required,
292
-		        'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options),
282
+			$f = array(
283
+				'id'            => (int) $field->id,
284
+				'field_key'     => (string) $field->field_key,
285
+				'name'          => (string) $field->name,
286
+				'description'   => (string) $field->description,
287
+				'type'          => (string) $field->type,
288
+				'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value),
289
+				'field_order'   => (int) $field->field_order,
290
+				'form_id'       => (int) $form_id,
291
+				'required'      => (int) $field->required,
292
+				'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options),
293 293
 				'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ),
294
-		    );
295
-
296
-		    if ( is_array($f['default_value']) && in_array($f['type'], array(
297
-		        'text', 'email', 'url', 'textarea',
298
-		        'number','phone', 'date', 'time',
299
-		        'hidden', 'password', 'tag', 'image',
300
-		    )) ) {
301
-		        if ( count($f['default_value']) === 1 ) {
294
+			);
295
+
296
+			if ( is_array($f['default_value']) && in_array($f['type'], array(
297
+				'text', 'email', 'url', 'textarea',
298
+				'number','phone', 'date', 'time',
299
+				'hidden', 'password', 'tag', 'image',
300
+			)) ) {
301
+				if ( count($f['default_value']) === 1 ) {
302 302
 					$f['default_value'] = '[' . reset( $f['default_value'] ) . ']';
303
-		        } else {
304
-		            $f['default_value'] = reset($f['default_value']);
305
-		        }
306
-		    }
303
+				} else {
304
+					$f['default_value'] = reset($f['default_value']);
305
+				}
306
+			}
307 307
 
308
-		    $f = apply_filters('frm_duplicated_field', $f);
308
+			$f = apply_filters('frm_duplicated_field', $f);
309 309
 
310 310
 			self::maybe_update_form_select( $f, $imported );
311 311
 
312
-		    if ( ! empty($this_form) ) {
313
-		        // check for field to edit by field id
312
+			if ( ! empty($this_form) ) {
313
+				// check for field to edit by field id
314 314
 				if ( isset( $form_fields[ $f['id'] ] ) ) {
315
-		            FrmField::update( $f['id'], $f );
316
-		            $imported['updated']['fields']++;
315
+					FrmField::update( $f['id'], $f );
316
+					$imported['updated']['fields']++;
317 317
 
318 318
 					unset( $form_fields[ $f['id'] ] );
319 319
 
320
-		            //unset old field key
320
+					//unset old field key
321 321
 					if ( isset( $form_fields[ $f['field_key'] ] ) ) {
322 322
 						unset( $form_fields[ $f['field_key'] ] );
323 323
 					}
324 324
 				} else if ( isset( $form_fields[ $f['field_key'] ] ) ) {
325
-		            // check for field to edit by field key
326
-		            unset($f['id']);
325
+					// check for field to edit by field key
326
+					unset($f['id']);
327 327
 
328 328
 					FrmField::update( $form_fields[ $f['field_key'] ], $f );
329
-		            $imported['updated']['fields']++;
329
+					$imported['updated']['fields']++;
330 330
 
331 331
 					unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id
332 332
 					unset( $form_fields[ $f['field_key'] ] ); //unset old field key
@@ -336,29 +336,29 @@  discard block
 block discarded – undo
336 336
 						continue;
337 337
 					}
338 338
 
339
-		            // if no matching field id or key in this form, create the field
340
-		            $imported['imported']['fields']++;
341
-		        }
339
+					// if no matching field id or key in this form, create the field
340
+					$imported['imported']['fields']++;
341
+				}
342 342
 			} else {
343 343
 				$new_id = FrmField::create( $f );
344 344
 				if ( $new_id == false ) {
345 345
 					continue;
346 346
 				}
347 347
 
348
-	            $imported['imported']['fields']++;
349
-		    }
348
+				$imported['imported']['fields']++;
349
+			}
350 350
 
351 351
 			unset($field, $new_id);
352 352
 		}
353 353
 	}
354 354
 
355 355
 	/**
356
-	* Switch the form_select on a repeating field or embedded form if it needs to be switched
357
-	*
358
-	* @since 2.0.16
359
-	* @param array $f
360
-	* @param array $imported
361
-	*/
356
+	 * Switch the form_select on a repeating field or embedded form if it needs to be switched
357
+	 *
358
+	 * @since 2.0.16
359
+	 * @param array $f
360
+	 * @param array $imported
361
+	 */
362 362
 	private static function maybe_update_form_select( &$f, $imported ) {
363 363
 		if ( ! isset( $imported['forms'] ) ) {
364 364
 			return;
@@ -375,12 +375,12 @@  discard block
 block discarded – undo
375 375
 	}
376 376
 
377 377
 	/**
378
-	* Updates the custom style setting on import
379
-	*
380
-	* @since 2.0.19
381
-	* @param array $form
382
-	*
383
-	*/
378
+	 * Updates the custom style setting on import
379
+	 *
380
+	 * @since 2.0.19
381
+	 * @param array $form
382
+	 *
383
+	 */
384 384
 	private static function update_custom_style_setting_on_import( &$form ) {
385 385
 		if ( ! isset( $form['options']['custom_style'] ) ) {
386 386
 			return;
@@ -410,16 +410,16 @@  discard block
 block discarded – undo
410 410
 	}
411 411
 
412 412
 	public static function import_xml_views( $views, $imported ) {
413
-        $imported['posts'] = array();
414
-        $form_action_type = FrmFormActionsController::$action_post_type;
413
+		$imported['posts'] = array();
414
+		$form_action_type = FrmFormActionsController::$action_post_type;
415 415
 
416
-        $post_types = array(
417
-            'frm_display' => 'views',
418
-            $form_action_type => 'actions',
419
-            'frm_styles'    => 'styles',
420
-        );
416
+		$post_types = array(
417
+			'frm_display' => 'views',
418
+			$form_action_type => 'actions',
419
+			'frm_styles'    => 'styles',
420
+		);
421 421
 
422
-        foreach ( $views as $item ) {
422
+		foreach ( $views as $item ) {
423 423
 			$post = array(
424 424
 				'post_title'    => (string) $item->title,
425 425
 				'post_name'     => (string) $item->post_name,
@@ -438,52 +438,52 @@  discard block
 block discarded – undo
438 438
 				'post_date'     => (string) $item->post_date,
439 439
 				'post_date_gmt' => (string) $item->post_date_gmt,
440 440
 				'ping_status'   => (string) $item->ping_status,
441
-                'postmeta'      => array(),
442
-                'tax_input'     => array(),
441
+				'postmeta'      => array(),
442
+				'tax_input'     => array(),
443 443
 			);
444 444
 
445
-            $old_id = $post['post_id'];
446
-            self::populate_post($post, $item, $imported);
445
+			$old_id = $post['post_id'];
446
+			self::populate_post($post, $item, $imported);
447 447
 
448 448
 			unset($item);
449 449
 
450 450
 			$post_id = false;
451
-            if ( $post['post_type'] == $form_action_type ) {
452
-                $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] );
451
+			if ( $post['post_type'] == $form_action_type ) {
452
+				$action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] );
453 453
 				if ( $action_control ) {
454 454
 					$post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
455 455
 				}
456
-                unset($action_control);
457
-            } else if ( $post['post_type'] == 'frm_styles' ) {
458
-                // Properly encode post content before inserting the post
459
-                $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
460
-                $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
461
-
462
-                // Create/update post now
463
-                $post_id = wp_insert_post( $post );
464
-            } else {
465
-                // Create/update post now
466
-                $post_id = wp_insert_post( $post );
467
-            }
468
-
469
-            if ( ! is_numeric($post_id) ) {
470
-                continue;
471
-            }
472
-
473
-            self::update_postmeta($post, $post_id);
474
-
475
-            $this_type = 'posts';
456
+				unset($action_control);
457
+			} else if ( $post['post_type'] == 'frm_styles' ) {
458
+				// Properly encode post content before inserting the post
459
+				$post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
460
+				$post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
461
+
462
+				// Create/update post now
463
+				$post_id = wp_insert_post( $post );
464
+			} else {
465
+				// Create/update post now
466
+				$post_id = wp_insert_post( $post );
467
+			}
468
+
469
+			if ( ! is_numeric($post_id) ) {
470
+				continue;
471
+			}
472
+
473
+			self::update_postmeta($post, $post_id);
474
+
475
+			$this_type = 'posts';
476 476
 			if ( isset( $post_types[ $post['post_type'] ] ) ) {
477 477
 				$this_type = $post_types[ $post['post_type'] ];
478
-            }
478
+			}
479 479
 
480
-            if ( isset($post['ID']) && $post_id == $post['ID'] ) {
481
-                $imported['updated'][ $this_type ]++;
482
-            } else {
483
-                $imported['imported'][ $this_type ]++;
484
-            }
480
+			if ( isset($post['ID']) && $post_id == $post['ID'] ) {
481
+				$imported['updated'][ $this_type ]++;
482
+			} else {
483
+				$imported['imported'][ $this_type ]++;
484
+			}
485 485
 
486
-            unset($post);
486
+			unset($post);
487 487
 
488 488
 			$imported['posts'][ (int) $old_id ] = $post_id;
489 489
 		}
@@ -491,157 +491,157 @@  discard block
 block discarded – undo
491 491
 		self::maybe_update_stylesheet( $imported );
492 492
 
493 493
 		return $imported;
494
-    }
494
+	}
495 495
 
496
-    private static function populate_post( &$post, $item, $imported ) {
496
+	private static function populate_post( &$post, $item, $imported ) {
497 497
 		if ( isset($item->attachment_url) ) {
498 498
 			$post['attachment_url'] = (string) $item->attachment_url;
499 499
 		}
500 500
 
501 501
 		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) {
502
-		    // update to new form id
503
-		    $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
502
+			// update to new form id
503
+			$post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
504 504
 		}
505 505
 
506 506
 		foreach ( $item->postmeta as $meta ) {
507
-		    self::populate_postmeta($post, $meta, $imported);
507
+			self::populate_postmeta($post, $meta, $imported);
508 508
 			unset($meta);
509 509
 		}
510 510
 
511
-        self::populate_taxonomies($post, $item);
511
+		self::populate_taxonomies($post, $item);
512 512
 
513
-        self::maybe_editing_post($post);
514
-    }
513
+		self::maybe_editing_post($post);
514
+	}
515 515
 
516
-    private static function populate_postmeta( &$post, $meta, $imported ) {
517
-        global $frm_duplicate_ids;
516
+	private static function populate_postmeta( &$post, $meta, $imported ) {
517
+		global $frm_duplicate_ids;
518 518
 
519
-	    $m = array(
519
+		$m = array(
520 520
 			'key'   => (string) $meta->meta_key,
521 521
 			'value' => (string) $meta->meta_value,
522 522
 		);
523 523
 
524 524
 		//switch old form and field ids to new ones
525 525
 		if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) {
526
-		    $m['value'] = $imported['forms'][ (int) $m['value'] ];
526
+			$m['value'] = $imported['forms'][ (int) $m['value'] ];
527 527
 		} else {
528
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
528
+			$m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
529 529
 
530
-		    if ( ! empty($frm_duplicate_ids) ) {
530
+			if ( ! empty($frm_duplicate_ids) ) {
531 531
 
532
-		        if ( $m['key'] == 'frm_dyncontent' ) {
533
-		            $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
534
-    		    } else if ( $m['key'] == 'frm_options' ) {
532
+				if ( $m['key'] == 'frm_dyncontent' ) {
533
+					$m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
534
+				} else if ( $m['key'] == 'frm_options' ) {
535 535
 
536 536
 					foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
537 537
 						if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) {
538 538
 							$m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ];
539
-    		            }
540
-    		        }
541
-
542
-                    $check_dup_array = array();
543
-    		        if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
544
-    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
545
-    		                $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
546
-    		            } else if ( is_array( $m['value']['order_by'] ) ) {
547
-                            $check_dup_array[] = 'order_by';
548
-    		            }
549
-    		        }
550
-
551
-    		        if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) {
552
-    		            $check_dup_array[] = 'where';
553
-    		        }
554
-
555
-                    foreach ( $check_dup_array as $check_k ) {
539
+						}
540
+					}
541
+
542
+					$check_dup_array = array();
543
+					if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
544
+						if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
545
+							$m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
546
+						} else if ( is_array( $m['value']['order_by'] ) ) {
547
+							$check_dup_array[] = 'order_by';
548
+						}
549
+					}
550
+
551
+					if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) {
552
+						$check_dup_array[] = 'where';
553
+					}
554
+
555
+					foreach ( $check_dup_array as $check_k ) {
556 556
 						foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) {
557 557
 							if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
558 558
 								$m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
559
-		                    }
560
-		                    unset($mk, $mv);
561
-		                }
562
-                    }
563
-    		    }
564
-		    }
559
+							}
560
+							unset($mk, $mv);
561
+						}
562
+					}
563
+				}
564
+			}
565 565
 		}
566 566
 
567 567
 		if ( ! is_array($m['value']) ) {
568
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
568
+			$m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
569 569
 		}
570 570
 
571 571
 		$post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
572
-    }
573
-
574
-    /**
575
-     * Add terms to post
576
-     * @param array $post by reference
577
-     * @param object $item The XML object data
578
-     */
579
-    private static function populate_taxonomies( &$post, $item ) {
572
+	}
573
+
574
+	/**
575
+	 * Add terms to post
576
+	 * @param array $post by reference
577
+	 * @param object $item The XML object data
578
+	 */
579
+	private static function populate_taxonomies( &$post, $item ) {
580 580
 		foreach ( $item->category as $c ) {
581 581
 			$att = $c->attributes();
582 582
 			if ( ! isset( $att['nicename'] ) ) {
583
-                continue;
584
-            }
585
-
586
-		    $taxonomy = (string) $att['domain'];
587
-		    if ( is_taxonomy_hierarchical($taxonomy) ) {
588
-		        $name = (string) $att['nicename'];
589
-		        $h_term = get_term_by('slug', $name, $taxonomy);
590
-		        if ( $h_term ) {
591
-		            $name = $h_term->term_id;
592
-		        }
593
-		        unset($h_term);
594
-		    } else {
595
-		        $name = (string) $c;
596
-		    }
583
+				continue;
584
+			}
585
+
586
+			$taxonomy = (string) $att['domain'];
587
+			if ( is_taxonomy_hierarchical($taxonomy) ) {
588
+				$name = (string) $att['nicename'];
589
+				$h_term = get_term_by('slug', $name, $taxonomy);
590
+				if ( $h_term ) {
591
+					$name = $h_term->term_id;
592
+				}
593
+				unset($h_term);
594
+			} else {
595
+				$name = (string) $c;
596
+			}
597 597
 
598 598
 			if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) {
599 599
 				$post['tax_input'][ $taxonomy ] = array();
600 600
 			}
601 601
 
602 602
 			$post['tax_input'][ $taxonomy ][] = $name;
603
-		    unset($name);
603
+			unset($name);
604 604
 		}
605
-    }
605
+	}
606 606
 
607
-    /**
608
-     * Edit post if the key and created time match
609
-     */
610
-    private static function maybe_editing_post( &$post ) {
607
+	/**
608
+	 * Edit post if the key and created time match
609
+	 */
610
+	private static function maybe_editing_post( &$post ) {
611 611
 		$match_by = array(
612
-		    'post_type'     => $post['post_type'],
613
-		    'name'          => $post['post_name'],
614
-		    'post_status'   => $post['post_status'],
615
-		    'posts_per_page' => 1,
612
+			'post_type'     => $post['post_type'],
613
+			'name'          => $post['post_name'],
614
+			'post_status'   => $post['post_status'],
615
+			'posts_per_page' => 1,
616 616
 		);
617 617
 
618 618
 		if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) {
619
-		    $match_by['include'] = $post['post_id'];
620
-		    unset($match_by['name']);
619
+			$match_by['include'] = $post['post_id'];
620
+			unset($match_by['name']);
621 621
 		}
622 622
 
623 623
 		$editing = get_posts($match_by);
624 624
 
625
-        if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
626
-            // set the id of the post to edit
627
-            $post['ID'] = current($editing)->ID;
628
-        }
629
-    }
625
+		if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
626
+			// set the id of the post to edit
627
+			$post['ID'] = current($editing)->ID;
628
+		}
629
+	}
630 630
 
631
-    private static function update_postmeta( &$post, $post_id ) {
632
-        foreach ( $post['postmeta'] as $k => $v ) {
633
-            if ( '_edit_last' == $k ) {
634
-                $v = FrmAppHelper::get_user_id_param($v);
635
-            } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
636
-                //change the attachment ID
637
-                $v = FrmProXMLHelper::get_file_id($v);
638
-            }
631
+	private static function update_postmeta( &$post, $post_id ) {
632
+		foreach ( $post['postmeta'] as $k => $v ) {
633
+			if ( '_edit_last' == $k ) {
634
+				$v = FrmAppHelper::get_user_id_param($v);
635
+			} else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
636
+				//change the attachment ID
637
+				$v = FrmProXMLHelper::get_file_id($v);
638
+			}
639 639
 
640
-            update_post_meta($post_id, $k, $v);
640
+			update_post_meta($post_id, $k, $v);
641 641
 
642
-            unset($k, $v);
643
-        }
644
-    }
642
+			unset($k, $v);
643
+		}
644
+	}
645 645
 
646 646
 	private static function maybe_update_stylesheet( $imported ) {
647 647
 		if ( ( isset( $imported['imported']['styles'] ) && ! empty( $imported['imported']['styles'] ) ) || ( isset( $imported['updated']['styles'] ) && ! empty( $imported['updated']['styles'] ) ) ) {
@@ -652,72 +652,72 @@  discard block
 block discarded – undo
652 652
 		}
653 653
 	}
654 654
 
655
-    /**
656
-     * @param string $message
657
-     */
655
+	/**
656
+	 * @param string $message
657
+	 */
658 658
 	public static function parse_message( $result, &$message, &$errors ) {
659
-        if ( is_wp_error($result) ) {
660
-            $errors[] = $result->get_error_message();
661
-        } else if ( ! $result ) {
662
-            return;
663
-        }
664
-
665
-        if ( ! is_array($result) ) {
666
-            $message = is_string( $result ) ? $result : print_r( $result, 1 );
667
-            return;
668
-        }
669
-
670
-        $t_strings = array(
671
-            'imported'  => __( 'Imported', 'formidable' ),
672
-            'updated'   => __( 'Updated', 'formidable' ),
673
-        );
674
-
675
-        $message = '<ul>';
676
-        foreach ( $result as $type => $results ) {
659
+		if ( is_wp_error($result) ) {
660
+			$errors[] = $result->get_error_message();
661
+		} else if ( ! $result ) {
662
+			return;
663
+		}
664
+
665
+		if ( ! is_array($result) ) {
666
+			$message = is_string( $result ) ? $result : print_r( $result, 1 );
667
+			return;
668
+		}
669
+
670
+		$t_strings = array(
671
+			'imported'  => __( 'Imported', 'formidable' ),
672
+			'updated'   => __( 'Updated', 'formidable' ),
673
+		);
674
+
675
+		$message = '<ul>';
676
+		foreach ( $result as $type => $results ) {
677 677
 			if ( ! isset( $t_strings[ $type ] ) ) {
678
-                // only print imported and updated
679
-                continue;
680
-            }
678
+				// only print imported and updated
679
+				continue;
680
+			}
681 681
 
682
-            $s_message = array();
683
-            foreach ( $results as $k => $m ) {
684
-                self::item_count_message($m, $k, $s_message);
685
-                unset($k, $m);
686
-            }
682
+			$s_message = array();
683
+			foreach ( $results as $k => $m ) {
684
+				self::item_count_message($m, $k, $s_message);
685
+				unset($k, $m);
686
+			}
687 687
 
688
-            if ( ! empty($s_message) ) {
688
+			if ( ! empty($s_message) ) {
689 689
 				$message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> ';
690
-                $message .= implode(', ', $s_message);
691
-                $message .= '</li>';
692
-            }
693
-        }
694
-
695
-        if ( $message == '<ul>' ) {
696
-            $message = '';
697
-            $errors[] = __( 'Nothing was imported or updated', 'formidable' );
698
-        } else {
699
-            $message .= '</ul>';
700
-        }
701
-    }
690
+				$message .= implode(', ', $s_message);
691
+				$message .= '</li>';
692
+			}
693
+		}
694
+
695
+		if ( $message == '<ul>' ) {
696
+			$message = '';
697
+			$errors[] = __( 'Nothing was imported or updated', 'formidable' );
698
+		} else {
699
+			$message .= '</ul>';
700
+		}
701
+	}
702 702
 
703 703
 	public static function item_count_message( $m, $type, &$s_message ) {
704
-        if ( ! $m ) {
705
-            return;
706
-        }
707
-
708
-        $strings = array(
709
-            'forms'     => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ),
710
-            'fields'    => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ),
711
-            'items'     => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ),
712
-            'views'     => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ),
713
-            'posts'     => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ),
714
-            'styles'     => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ),
715
-            'terms'     => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ),
716
-            'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
717
-        );
704
+		if ( ! $m ) {
705
+			return;
706
+		}
707
+
708
+		$strings = array(
709
+			'forms'     => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ),
710
+			'fields'    => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ),
711
+			'items'     => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ),
712
+			'views'     => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ),
713
+			'posts'     => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ),
714
+			'styles'     => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ),
715
+			'terms'     => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ),
716
+			'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
717
+		);
718 718
 
719 719
 		$s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type );
720
-    }
720
+	}
721 721
 
722 722
 	/**
723 723
 	 * Prepare the form options for export
@@ -748,16 +748,16 @@  discard block
 block discarded – undo
748 748
 	}
749 749
 
750 750
 	public static function cdata( $str ) {
751
-	    $str = maybe_unserialize($str);
752
-	    if ( is_array($str) ) {
753
-	        $str = json_encode($str);
751
+		$str = maybe_unserialize($str);
752
+		if ( is_array($str) ) {
753
+			$str = json_encode($str);
754 754
 		} else if ( seems_utf8( $str ) == false ) {
755 755
 			$str = utf8_encode( $str );
756 756
 		}
757 757
 
758
-        if ( is_numeric($str) ) {
759
-            return $str;
760
-        }
758
+		if ( is_numeric($str) ) {
759
+			return $str;
760
+		}
761 761
 
762 762
 		self::remove_invalid_characters_from_xml( $str );
763 763
 
@@ -778,58 +778,58 @@  discard block
 block discarded – undo
778 778
 		$str = str_replace( '\x1F', '', $str );
779 779
 	}
780 780
 
781
-    public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) {
782
-        // Get post type
783
-        $post_type = FrmFormActionsController::$action_post_type;
784
-
785
-        // Set up imported index, if not set up yet
786
-        if ( ! isset( $imported['imported']['actions'] ) ) {
787
-            $imported['imported']['actions'] = 0;
788
-        }
789
-
790
-        // Migrate post settings to action
791
-        self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
792
-
793
-        // Migrate email settings to action
794
-        self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
795
-    }
796
-
797
-    /**
798
-    * Migrate post settings to form action
799
-    *
800
-    * @param string $post_type
801
-    */
802
-    private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
803
-        if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
804
-            return;
805
-        }
806
-
807
-        $new_action = array(
808
-            'post_type'     => $post_type,
809
-            'post_excerpt'  => 'wppost',
781
+	public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) {
782
+		// Get post type
783
+		$post_type = FrmFormActionsController::$action_post_type;
784
+
785
+		// Set up imported index, if not set up yet
786
+		if ( ! isset( $imported['imported']['actions'] ) ) {
787
+			$imported['imported']['actions'] = 0;
788
+		}
789
+
790
+		// Migrate post settings to action
791
+		self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
792
+
793
+		// Migrate email settings to action
794
+		self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
795
+	}
796
+
797
+	/**
798
+	 * Migrate post settings to form action
799
+	 *
800
+	 * @param string $post_type
801
+	 */
802
+	private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
803
+		if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
804
+			return;
805
+		}
806
+
807
+		$new_action = array(
808
+			'post_type'     => $post_type,
809
+			'post_excerpt'  => 'wppost',
810 810
 			'post_title'    => __( 'Create Posts', 'formidable' ),
811
-            'menu_order'    => $form_id,
812
-            'post_status'   => 'publish',
813
-            'post_content'  => array(),
811
+			'menu_order'    => $form_id,
812
+			'post_status'   => 'publish',
813
+			'post_content'  => array(),
814 814
 			'post_name'     => $form_id . '_wppost_1',
815
-        );
815
+		);
816 816
 
817
-        $post_settings = array(
818
-            'post_type', 'post_category', 'post_content',
819
-            'post_excerpt', 'post_title', 'post_name', 'post_date',
817
+		$post_settings = array(
818
+			'post_type', 'post_category', 'post_content',
819
+			'post_excerpt', 'post_title', 'post_name', 'post_date',
820 820
 			'post_status', 'post_custom_fields', 'post_password',
821
-        );
821
+		);
822 822
 
823
-        foreach ( $post_settings as $post_setting ) {
823
+		foreach ( $post_settings as $post_setting ) {
824 824
 			if ( isset( $form_options[ $post_setting ] ) ) {
825 825
 				$new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
826
-            }
827
-            unset($post_setting);
828
-        }
826
+			}
827
+			unset($post_setting);
828
+		}
829 829
 
830 830
 		$new_action['event'] = array( 'create', 'update' );
831 831
 
832
-        if ( $switch ) {
832
+		if ( $switch ) {
833 833
 			// Fields with string or int saved
834 834
 			$basic_fields = array( 'post_title', 'post_content', 'post_excerpt', 'post_password', 'post_date', 'post_status' );
835 835
 
@@ -837,22 +837,22 @@  discard block
 block discarded – undo
837 837
 			$array_fields = array( 'post_category', 'post_custom_fields' );
838 838
 
839 839
 			$new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields );
840
-        }
841
-        $new_action['post_content'] = json_encode($new_action['post_content']);
840
+		}
841
+		$new_action['post_content'] = json_encode($new_action['post_content']);
842 842
 
843
-        $exists = get_posts( array(
844
-            'name'          => $new_action['post_name'],
845
-            'post_type'     => $new_action['post_type'],
846
-            'post_status'   => $new_action['post_status'],
847
-            'numberposts'   => 1,
848
-        ) );
843
+		$exists = get_posts( array(
844
+			'name'          => $new_action['post_name'],
845
+			'post_type'     => $new_action['post_type'],
846
+			'post_status'   => $new_action['post_status'],
847
+			'numberposts'   => 1,
848
+		) );
849 849
 
850
-        if ( ! $exists ) {
850
+		if ( ! $exists ) {
851 851
 			// this isn't an email, but we need to use a class that will always be included
852 852
 			FrmAppHelper::save_json_post( $new_action );
853
-            $imported['imported']['actions']++;
854
-        }
855
-    }
853
+			$imported['imported']['actions']++;
854
+		}
855
+	}
856 856
 
857 857
 	/**
858 858
 	 * Switch old field IDs for new field IDs in emails and post
@@ -865,211 +865,211 @@  discard block
 block discarded – undo
865 865
 	 * @return string $post_content - new field IDs
866 866
 	 */
867 867
 	private static function switch_action_field_ids( $post_content, $basic_fields, $array_fields = array() ) {
868
-        global $frm_duplicate_ids;
868
+		global $frm_duplicate_ids;
869 869
 
870
-        // If there aren't IDs that were switched, end now
871
-        if ( ! $frm_duplicate_ids ) {
872
-            return;
873
-        }
870
+		// If there aren't IDs that were switched, end now
871
+		if ( ! $frm_duplicate_ids ) {
872
+			return;
873
+		}
874 874
 
875
-        // Get old IDs
876
-        $old = array_keys( $frm_duplicate_ids );
875
+		// Get old IDs
876
+		$old = array_keys( $frm_duplicate_ids );
877 877
 
878
-        // Get new IDs
879
-        $new = array_values( $frm_duplicate_ids );
878
+		// Get new IDs
879
+		$new = array_values( $frm_duplicate_ids );
880 880
 
881
-        // Do a str_replace with each item to set the new IDs
882
-        foreach ( $post_content as $key => $setting ) {
883
-            if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
884
-                // Replace old IDs with new IDs
881
+		// Do a str_replace with each item to set the new IDs
882
+		foreach ( $post_content as $key => $setting ) {
883
+			if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
884
+				// Replace old IDs with new IDs
885 885
 				$post_content[ $key ] = str_replace( $old, $new, $setting );
886
-            } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
887
-                foreach ( $setting as $k => $val ) {
888
-                    // Replace old IDs with new IDs
886
+			} else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
887
+				foreach ( $setting as $k => $val ) {
888
+					// Replace old IDs with new IDs
889 889
 					$post_content[ $key ][ $k ] = str_replace( $old, $new, $val );
890
-                }
891
-            }
892
-            unset( $key, $setting );
893
-        }
894
-        return $post_content;
895
-    }
896
-
897
-    private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
898
-        // No old notifications or autoresponders to carry over
890
+				}
891
+			}
892
+			unset( $key, $setting );
893
+		}
894
+		return $post_content;
895
+	}
896
+
897
+	private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
898
+		// No old notifications or autoresponders to carry over
899 899
 		if ( ! isset( $form_options['auto_responder'] ) && ! isset( $form_options['notification'] ) && ! isset( $form_options['email_to'] ) ) {
900
-            return;
901
-        }
900
+			return;
901
+		}
902 902
 
903
-        // Initialize notifications array
904
-        $notifications = array();
903
+		// Initialize notifications array
904
+		$notifications = array();
905 905
 
906
-        // Migrate regular notifications
907
-        self::migrate_notifications_to_action( $form_options, $form_id, $notifications );
906
+		// Migrate regular notifications
907
+		self::migrate_notifications_to_action( $form_options, $form_id, $notifications );
908 908
 
909
-        // Migrate autoresponders
910
-        self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
909
+		// Migrate autoresponders
910
+		self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
911 911
 
912
-        if (  empty( $notifications ) ) {
913
-            return;
914
-        }
912
+		if (  empty( $notifications ) ) {
913
+			return;
914
+		}
915 915
 
916
-        foreach ( $notifications as $new_notification ) {
917
-            $new_notification['post_type']      = $post_type;
918
-            $new_notification['post_excerpt']   = 'email';
916
+		foreach ( $notifications as $new_notification ) {
917
+			$new_notification['post_type']      = $post_type;
918
+			$new_notification['post_excerpt']   = 'email';
919 919
 			$new_notification['post_title']     = __( 'Email Notification', 'formidable' );
920
-            $new_notification['menu_order']     = $form_id;
921
-            $new_notification['post_status']    = 'publish';
920
+			$new_notification['menu_order']     = $form_id;
921
+			$new_notification['post_status']    = 'publish';
922 922
 
923
-            // Switch field IDs and keys, if needed
924
-            if ( $switch ) {
923
+			// Switch field IDs and keys, if needed
924
+			if ( $switch ) {
925 925
 
926 926
 				// Switch field IDs in email conditional logic
927 927
 				self::switch_email_contition_field_ids( $new_notification['post_content'] );
928 928
 
929 929
 				// Switch all other field IDs in email
930
-                $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
931
-            }
932
-            $new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
933
-
934
-            $exists = get_posts( array(
935
-                'name'          => $new_notification['post_name'],
936
-                'post_type'     => $new_notification['post_type'],
937
-                'post_status'   => $new_notification['post_status'],
938
-                'numberposts'   => 1,
939
-            ) );
940
-
941
-            if ( empty($exists) ) {
930
+				$new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
931
+			}
932
+			$new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
933
+
934
+			$exists = get_posts( array(
935
+				'name'          => $new_notification['post_name'],
936
+				'post_type'     => $new_notification['post_type'],
937
+				'post_status'   => $new_notification['post_status'],
938
+				'numberposts'   => 1,
939
+			) );
940
+
941
+			if ( empty($exists) ) {
942 942
 				FrmAppHelper::save_json_post( $new_notification );
943
-                $imported['imported']['actions']++;
944
-            }
945
-            unset($new_notification);
946
-        }
947
-    }
948
-
949
-    private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) {
950
-        if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) {
951
-            // add old settings into notification array
943
+				$imported['imported']['actions']++;
944
+			}
945
+			unset($new_notification);
946
+		}
947
+	}
948
+
949
+	private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) {
950
+		if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) {
951
+			// add old settings into notification array
952 952
 			$form_options['notification'] = array( 0 => $form_options );
953
-        } else if ( isset( $form_options['notification']['email_to'] ) ) {
954
-            // make sure it's in the correct format
953
+		} else if ( isset( $form_options['notification']['email_to'] ) ) {
954
+			// make sure it's in the correct format
955 955
 			$form_options['notification'] = array( 0 => $form_options['notification'] );
956
-        }
956
+		}
957 957
 
958
-        if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
959
-            foreach ( $form_options['notification'] as $email_key => $notification ) {
958
+		if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
959
+			foreach ( $form_options['notification'] as $email_key => $notification ) {
960 960
 
961
-                $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
961
+				$atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
962 962
 
963
-                // Format the email data
964
-                self::format_email_data( $atts, $notification );
963
+				// Format the email data
964
+				self::format_email_data( $atts, $notification );
965 965
 
966 966
 				if ( isset( $notification['twilio'] ) && $notification['twilio'] ) {
967 967
 					do_action( 'frm_create_twilio_action', $atts, $notification );
968 968
 				}
969 969
 
970
-                // Setup the new notification
971
-                $new_notification = array();
972
-                self::setup_new_notification( $new_notification, $notification, $atts );
970
+				// Setup the new notification
971
+				$new_notification = array();
972
+				self::setup_new_notification( $new_notification, $notification, $atts );
973 973
 
974
-                $notifications[] = $new_notification;
975
-            }
976
-        }
977
-    }
974
+				$notifications[] = $new_notification;
975
+			}
976
+		}
977
+	}
978 978
 
979
-    private static function format_email_data( &$atts, $notification ) {
980
-        // Format email_to
981
-        self::format_email_to_data( $atts, $notification );
979
+	private static function format_email_data( &$atts, $notification ) {
980
+		// Format email_to
981
+		self::format_email_to_data( $atts, $notification );
982 982
 
983
-        // Format the reply to email and name
984
-        $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
985
-        foreach ( $reply_fields as $f => $val ) {
983
+		// Format the reply to email and name
984
+		$reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
985
+		foreach ( $reply_fields as $f => $val ) {
986 986
 			if ( isset( $notification[ $f ] ) ) {
987 987
 				$atts[ $f ] = $notification[ $f ];
988 988
 				if ( 'custom' == $notification[ $f ] ) {
989 989
 					$atts[ $f ] = $notification[ 'cust_' . $f ];
990 990
 				} else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) {
991 991
 					$atts[ $f ] = '[' . $atts[ $f ] . ']';
992
-                }
993
-            }
994
-            unset( $f, $val );
995
-        }
992
+				}
993
+			}
994
+			unset( $f, $val );
995
+		}
996 996
 
997
-        // Format event
997
+		// Format event
998 998
 		$atts['event'] = array( 'create' );
999
-        if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1000
-            $atts['event'][] = 'update';
1001
-        } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
999
+		if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1000
+			$atts['event'][] = 'update';
1001
+		} else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1002 1002
 			$atts['event'] = array( 'update' );
1003
-        }
1004
-    }
1003
+		}
1004
+	}
1005 1005
 
1006
-    private static function format_email_to_data( &$atts, $notification ) {
1007
-        if ( isset( $notification['email_to'] ) ) {
1006
+	private static function format_email_to_data( &$atts, $notification ) {
1007
+		if ( isset( $notification['email_to'] ) ) {
1008 1008
 			$atts['email_to'] = preg_split( '/ (,|;) /', $notification['email_to'] );
1009
-        } else {
1010
-            $atts['email_to'] = array();
1011
-        }
1009
+		} else {
1010
+			$atts['email_to'] = array();
1011
+		}
1012 1012
 
1013
-        if ( isset( $notification['also_email_to'] ) ) {
1014
-            $email_fields = (array) $notification['also_email_to'];
1015
-            $atts['email_to'] = array_merge( $email_fields, $atts['email_to'] );
1016
-            unset( $email_fields );
1017
-        }
1013
+		if ( isset( $notification['also_email_to'] ) ) {
1014
+			$email_fields = (array) $notification['also_email_to'];
1015
+			$atts['email_to'] = array_merge( $email_fields, $atts['email_to'] );
1016
+			unset( $email_fields );
1017
+		}
1018 1018
 
1019
-        foreach ( $atts['email_to'] as $key => $email_field ) {
1019
+		foreach ( $atts['email_to'] as $key => $email_field ) {
1020 1020
 
1021
-            if ( is_numeric( $email_field ) ) {
1021
+			if ( is_numeric( $email_field ) ) {
1022 1022
 				$atts['email_to'][ $key ] = '[' . $email_field . ']';
1023
-            }
1023
+			}
1024 1024
 
1025
-            if ( strpos( $email_field, '|') ) {
1026
-                $email_opt = explode( '|', $email_field );
1027
-                if ( isset( $email_opt[0] ) ) {
1025
+			if ( strpos( $email_field, '|') ) {
1026
+				$email_opt = explode( '|', $email_field );
1027
+				if ( isset( $email_opt[0] ) ) {
1028 1028
 					$atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1029
-                }
1030
-                unset( $email_opt );
1031
-            }
1032
-        }
1033
-        $atts['email_to'] = implode(', ', $atts['email_to']);
1034
-    }
1035
-
1036
-    private static function setup_new_notification( &$new_notification, $notification, $atts ) {
1037
-        // Set up new notification
1038
-        $new_notification = array(
1039
-            'post_content'  => array(
1040
-                'email_to'      => $atts['email_to'],
1041
-                'event'         => $atts['event'],
1042
-            ),
1029
+				}
1030
+				unset( $email_opt );
1031
+			}
1032
+		}
1033
+		$atts['email_to'] = implode(', ', $atts['email_to']);
1034
+	}
1035
+
1036
+	private static function setup_new_notification( &$new_notification, $notification, $atts ) {
1037
+		// Set up new notification
1038
+		$new_notification = array(
1039
+			'post_content'  => array(
1040
+				'email_to'      => $atts['email_to'],
1041
+				'event'         => $atts['event'],
1042
+			),
1043 1043
 			'post_name'         => $atts['form_id'] . '_email_' . $atts['email_key'],
1044
-        );
1044
+		);
1045 1045
 
1046
-        // Add more fields to the new notification
1047
-        $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1048
-        foreach ( $add_fields as $add_field ) {
1046
+		// Add more fields to the new notification
1047
+		$add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1048
+		foreach ( $add_fields as $add_field ) {
1049 1049
 			if ( isset( $notification[ $add_field ] ) ) {
1050 1050
 				$new_notification['post_content'][ $add_field ] = $notification[ $add_field ];
1051
-            } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1051
+			} else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1052 1052
 				$new_notification['post_content'][ $add_field ] = 0;
1053
-            } else {
1053
+			} else {
1054 1054
 				$new_notification['post_content'][ $add_field ] = '';
1055
-            }
1056
-            unset( $add_field );
1057
-        }
1055
+			}
1056
+			unset( $add_field );
1057
+		}
1058 1058
 
1059 1059
 		// Set reply to
1060 1060
 		$new_notification['post_content']['reply_to'] = $atts['reply_to'];
1061 1061
 
1062
-        // Set from
1062
+		// Set from
1063 1063
 		if ( ! empty( $atts['reply_to'] ) || ! empty( $atts['reply_to_name'] ) ) {
1064 1064
 			$new_notification['post_content']['from'] = ( empty( $atts['reply_to_name'] ) ? '[sitename]' : $atts['reply_to_name'] ) . ' <' . ( empty( $atts['reply_to'] ) ? '[admin_email]' : $atts['reply_to'] ) . '>';
1065
-        }
1066
-    }
1065
+		}
1066
+	}
1067 1067
 
1068 1068
 	/**
1069
-	* Switch field IDs in pre-2.0 email conditional logic
1070
-	*
1071
-	* @param $post_content array, pass by reference
1072
-	*/
1069
+	 * Switch field IDs in pre-2.0 email conditional logic
1070
+	 *
1071
+	 * @param $post_content array, pass by reference
1072
+	 */
1073 1073
 	private static function switch_email_contition_field_ids( &$post_content ) {
1074 1074
 		// Switch field IDs in conditional logic
1075 1075
 		if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
@@ -1082,36 +1082,36 @@  discard block
 block discarded – undo
1082 1082
 		}
1083 1083
 	}
1084 1084
 
1085
-    private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1086
-        if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1087
-            // migrate autoresponder
1088
-
1089
-            $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1090
-            if ( strpos($email_field, '|') ) {
1091
-                // data from entries field
1092
-                $email_field = explode('|', $email_field);
1093
-                if ( isset($email_field[1]) ) {
1094
-                    $email_field = $email_field[1];
1095
-                }
1096
-            }
1097
-            if ( is_numeric($email_field) && ! empty($email_field) ) {
1085
+	private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1086
+		if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1087
+			// migrate autoresponder
1088
+
1089
+			$email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1090
+			if ( strpos($email_field, '|') ) {
1091
+				// data from entries field
1092
+				$email_field = explode('|', $email_field);
1093
+				if ( isset($email_field[1]) ) {
1094
+					$email_field = $email_field[1];
1095
+				}
1096
+			}
1097
+			if ( is_numeric($email_field) && ! empty($email_field) ) {
1098 1098
 				$email_field = '[' . $email_field . ']';
1099
-            }
1100
-
1101
-            $notification = $form_options;
1102
-            $new_notification2 = array(
1103
-                'post_content'  => array(
1104
-                    'email_message' => $notification['ar_email_message'],
1105
-                    'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1106
-                    'email_to'      => $email_field,
1107
-                    'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1108
-                    'inc_user_info' => 0,
1109
-                ),
1099
+			}
1100
+
1101
+			$notification = $form_options;
1102
+			$new_notification2 = array(
1103
+				'post_content'  => array(
1104
+					'email_message' => $notification['ar_email_message'],
1105
+					'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1106
+					'email_to'      => $email_field,
1107
+					'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1108
+					'inc_user_info' => 0,
1109
+				),
1110 1110
 				'post_name'     => $form_id . '_email_' . count( $notifications ),
1111
-            );
1111
+			);
1112 1112
 
1113
-            $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1114
-            $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1113
+			$reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1114
+			$reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1115 1115
 
1116 1116
 			if ( ! empty( $reply_to ) ) {
1117 1117
 				$new_notification2['post_content']['reply_to'] = $reply_to;
@@ -1121,9 +1121,9 @@  discard block
 block discarded – undo
1121 1121
 				$new_notification2['post_content']['from'] = ( empty( $reply_to_name ) ? '[sitename]' : $reply_to_name ) . ' <' . ( empty( $reply_to ) ? '[admin_email]' : $reply_to ) . '>';
1122 1122
 			}
1123 1123
 
1124
-            $notifications[] = $new_notification2;
1125
-            unset( $new_notification2 );
1126
-        }
1127
-    }
1124
+			$notifications[] = $new_notification2;
1125
+			unset( $new_notification2 );
1126
+		}
1127
+	}
1128 1128
 }
1129 1129
 
Please login to merge, or discard this patch.
Spacing   +167 added lines, -167 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
 
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
 			'terms'    => array(),
37 37
         );
38 38
 
39
-        unset($defaults);
39
+        unset( $defaults );
40 40
 
41 41
 		if ( ! defined( 'WP_IMPORTING' ) ) {
42
-            define('WP_IMPORTING', true);
42
+            define( 'WP_IMPORTING', true );
43 43
         }
44 44
 
45 45
 		if ( ! class_exists( 'DOMDocument' ) ) {
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
53 53
 		}
54 54
 
55
-		if ( ! function_exists('simplexml_import_dom') ) {
55
+		if ( ! function_exists( 'simplexml_import_dom' ) ) {
56 56
 			return new WP_Error( 'SimpleXML_parse_error', __( 'Your server is missing the simplexml_import_dom function', 'formidable' ), libxml_get_errors() );
57 57
 		}
58 58
 
@@ -67,21 +67,21 @@  discard block
 block discarded – undo
67 67
         // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
68 68
 		foreach ( array( 'term', 'form', 'view' ) as $item_type ) {
69 69
             // grab cats, tags, and terms, or forms or posts
70
-            if ( isset($xml->{$item_type} ) ) {
70
+            if ( isset( $xml->{$item_type} ) ) {
71 71
 				$function_name = 'import_xml_' . $item_type . 's';
72 72
 				$imported = self::$function_name( $xml->{$item_type}, $imported );
73 73
 				unset( $function_name, $xml->{$item_type} );
74 74
             }
75 75
         }
76 76
 
77
-	    $return = apply_filters('frm_importing_xml', $imported, $xml );
77
+	    $return = apply_filters( 'frm_importing_xml', $imported, $xml );
78 78
 
79 79
 	    return $return;
80 80
     }
81 81
 
82 82
 	public static function import_xml_terms( $terms, $imported ) {
83 83
         foreach ( $terms as $t ) {
84
-			if ( term_exists((string) $t->term_slug, (string) $t->term_taxonomy) ) {
84
+			if ( term_exists( (string) $t->term_slug, (string) $t->term_taxonomy ) ) {
85 85
 			    continue;
86 86
 			}
87 87
 
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
                 'slug'          => (string) $t->term_slug,
92 92
                 'description'   => (string) $t->term_description,
93 93
 				'parent'        => empty( $parent ) ? 0 : $parent,
94
-            ));
94
+            ) );
95 95
 
96 96
 			if ( $term && is_array( $term ) ) {
97
-                $imported['imported']['terms']++;
98
-				$imported['terms'][ (int) $t->term_id ] = $term['term_id'];
97
+                $imported['imported']['terms'] ++;
98
+				$imported['terms'][(int) $t->term_id] = $term['term_id'];
99 99
             }
100 100
 
101 101
 			unset( $term, $t );
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
                 'default_template' => (int) $item->default_template,
139 139
                 'editable'      => (int) $item->editable,
140 140
                 'status'        => (string) $item->status,
141
-                'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0,
142
-                'created_at'    => date('Y-m-d H:i:s', strtotime((string) $item->created_at)),
141
+                'parent_form_id' => isset( $item->parent_form_id ) ? (int) $item->parent_form_id : 0,
142
+                'created_at'    => date( 'Y-m-d H:i:s', strtotime( (string) $item->created_at ) ),
143 143
             );
144 144
 
145
-            $form['options'] = FrmAppHelper::maybe_json_decode($form['options']);
145
+            $form['options'] = FrmAppHelper::maybe_json_decode( $form['options'] );
146 146
 
147 147
 			self::update_custom_style_setting_on_import( $form );
148 148
 
@@ -152,35 +152,35 @@  discard block
 block discarded – undo
152 152
                 $edit_query['created_at'] = $form['created_at'];
153 153
             }
154 154
 
155
-            $edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
155
+            $edit_query = apply_filters( 'frm_match_xml_form', $edit_query, $form );
156 156
 
157
-            $this_form = FrmForm::getAll($edit_query, '', 1);
158
-            unset($edit_query);
157
+            $this_form = FrmForm::getAll( $edit_query, '', 1 );
158
+            unset( $edit_query );
159 159
 
160 160
             if ( ! empty( $this_form ) ) {
161 161
                 $old_id = $form_id = $this_form->id;
162
-                FrmForm::update($form_id, $form );
163
-                $imported['updated']['forms']++;
162
+                FrmForm::update( $form_id, $form );
163
+                $imported['updated']['forms'] ++;
164 164
                 // Keep track of whether this specific form was updated or not
165
-				$imported['form_status'][ $form_id ] = 'updated';
165
+				$imported['form_status'][$form_id] = 'updated';
166 166
 
167 167
 				$form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' );
168 168
                 $old_fields = array();
169 169
                 foreach ( $form_fields as $f ) {
170
-					$old_fields[ $f->id ] = $f;
171
-					$old_fields[ $f->field_key ] = $f->id;
172
-                    unset($f);
170
+					$old_fields[$f->id] = $f;
171
+					$old_fields[$f->field_key] = $f->id;
172
+                    unset( $f );
173 173
                 }
174 174
                 $form_fields = $old_fields;
175
-                unset($old_fields);
175
+                unset( $old_fields );
176 176
             } else {
177 177
                 $old_id = false;
178 178
                 //form does not exist, so create it
179 179
 				$form_id = FrmForm::create( $form );
180 180
                 if ( $form_id ) {
181
-                    $imported['imported']['forms']++;
181
+                    $imported['imported']['forms'] ++;
182 182
                     // Keep track of whether this specific form was updated or not
183
-					$imported['form_status'][ $form_id ] = 'imported';
183
+					$imported['form_status'][$form_id] = 'imported';
184 184
 					self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms );
185 185
                 }
186 186
             }
@@ -190,23 +190,23 @@  discard block
 block discarded – undo
190 190
     		// Delete any fields attached to this form that were not included in the template
191 191
     		if ( isset( $form_fields ) && ! empty( $form_fields ) ) {
192 192
 				foreach ( $form_fields as $field ) {
193
-                    if ( is_object($field) ) {
194
-                        FrmField::destroy($field->id);
193
+                    if ( is_object( $field ) ) {
194
+                        FrmField::destroy( $field->id );
195 195
                     }
196
-                    unset($field);
196
+                    unset( $field );
197 197
                 }
198
-                unset($form_fields);
198
+                unset( $form_fields );
199 199
             }
200 200
 
201 201
 		    // Update field ids/keys to new ones
202 202
 			do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) );
203 203
 
204
-			$imported['forms'][ (int) $item->id ] = $form_id;
204
+			$imported['forms'][(int) $item->id] = $form_id;
205 205
 
206 206
             // Send pre 2.0 form options through function that creates actions
207 207
             self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true );
208 208
 
209
-		    unset($form, $item);
209
+		    unset( $form, $item );
210 210
 		}
211 211
 
212 212
 		self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms );
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 		$regular_forms = array();
226 226
 
227 227
 		foreach ( $forms as $form ) {
228
-			$parent_form_id = isset( $form->parent_form_id) ? (int) $form->parent_form_id : 0;
228
+			$parent_form_id = isset( $form->parent_form_id ) ? (int) $form->parent_form_id : 0;
229 229
 
230 230
 			if ( $parent_form_id ) {
231 231
 				$child_forms[] = $form;
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 	*/
248 248
 	private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) {
249 249
 		if ( $parent_form_id ) {
250
-			$child_forms[ $form_id ] = $parent_form_id;
250
+			$child_forms[$form_id] = $parent_form_id;
251 251
 		}
252 252
 	}
253 253
 
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
 	private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) {
263 263
 		foreach ( $child_forms as $child_form_id => $old_parent_form_id ) {
264 264
 
265
-			if ( isset( $imported_forms[ $old_parent_form_id ] ) && $imported_forms[ $old_parent_form_id ] != $old_parent_form_id ) {
265
+			if ( isset( $imported_forms[$old_parent_form_id] ) && $imported_forms[$old_parent_form_id] != $old_parent_form_id ) {
266 266
 				// Update all children with this old parent_form_id
267
-				$new_parent_form_id = (int) $imported_forms[ $old_parent_form_id ];
267
+				$new_parent_form_id = (int) $imported_forms[$old_parent_form_id];
268 268
 
269 269
 				FrmForm::update( $child_form_id, array( 'parent_form_id' => $new_parent_form_id ) );
270 270
 			}
@@ -285,51 +285,51 @@  discard block
 block discarded – undo
285 285
 		        'name'          => (string) $field->name,
286 286
 		        'description'   => (string) $field->description,
287 287
 		        'type'          => (string) $field->type,
288
-		        'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value),
288
+		        'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value ),
289 289
 		        'field_order'   => (int) $field->field_order,
290 290
 		        'form_id'       => (int) $form_id,
291 291
 		        'required'      => (int) $field->required,
292
-		        'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options),
292
+		        'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options ),
293 293
 				'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ),
294 294
 		    );
295 295
 
296
-		    if ( is_array($f['default_value']) && in_array($f['type'], array(
296
+		    if ( is_array( $f['default_value'] ) && in_array( $f['type'], array(
297 297
 		        'text', 'email', 'url', 'textarea',
298
-		        'number','phone', 'date', 'time',
298
+		        'number', 'phone', 'date', 'time',
299 299
 		        'hidden', 'password', 'tag', 'image',
300
-		    )) ) {
301
-		        if ( count($f['default_value']) === 1 ) {
300
+		    ) ) ) {
301
+		        if ( count( $f['default_value'] ) === 1 ) {
302 302
 					$f['default_value'] = '[' . reset( $f['default_value'] ) . ']';
303 303
 		        } else {
304
-		            $f['default_value'] = reset($f['default_value']);
304
+		            $f['default_value'] = reset( $f['default_value'] );
305 305
 		        }
306 306
 		    }
307 307
 
308
-		    $f = apply_filters('frm_duplicated_field', $f);
308
+		    $f = apply_filters( 'frm_duplicated_field', $f );
309 309
 
310 310
 			self::maybe_update_form_select( $f, $imported );
311 311
 
312
-		    if ( ! empty($this_form) ) {
312
+		    if ( ! empty( $this_form ) ) {
313 313
 		        // check for field to edit by field id
314
-				if ( isset( $form_fields[ $f['id'] ] ) ) {
314
+				if ( isset( $form_fields[$f['id']] ) ) {
315 315
 		            FrmField::update( $f['id'], $f );
316
-		            $imported['updated']['fields']++;
316
+		            $imported['updated']['fields'] ++;
317 317
 
318
-					unset( $form_fields[ $f['id'] ] );
318
+					unset( $form_fields[$f['id']] );
319 319
 
320 320
 		            //unset old field key
321
-					if ( isset( $form_fields[ $f['field_key'] ] ) ) {
322
-						unset( $form_fields[ $f['field_key'] ] );
321
+					if ( isset( $form_fields[$f['field_key']] ) ) {
322
+						unset( $form_fields[$f['field_key']] );
323 323
 					}
324
-				} else if ( isset( $form_fields[ $f['field_key'] ] ) ) {
324
+				} else if ( isset( $form_fields[$f['field_key']] ) ) {
325 325
 		            // check for field to edit by field key
326
-		            unset($f['id']);
326
+		            unset( $f['id'] );
327 327
 
328
-					FrmField::update( $form_fields[ $f['field_key'] ], $f );
329
-		            $imported['updated']['fields']++;
328
+					FrmField::update( $form_fields[$f['field_key']], $f );
329
+		            $imported['updated']['fields'] ++;
330 330
 
331
-					unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id
332
-					unset( $form_fields[ $f['field_key'] ] ); //unset old field key
331
+					unset( $form_fields[$form_fields[$f['field_key']]] ); //unset old field id
332
+					unset( $form_fields[$f['field_key']] ); //unset old field key
333 333
 				} else {
334 334
 					$new_id = FrmField::create( $f );
335 335
 					if ( $new_id == false ) {
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 					}
338 338
 
339 339
 		            // if no matching field id or key in this form, create the field
340
-		            $imported['imported']['fields']++;
340
+		            $imported['imported']['fields'] ++;
341 341
 		        }
342 342
 			} else {
343 343
 				$new_id = FrmField::create( $f );
@@ -345,10 +345,10 @@  discard block
 block discarded – undo
345 345
 					continue;
346 346
 				}
347 347
 
348
-	            $imported['imported']['fields']++;
348
+	            $imported['imported']['fields'] ++;
349 349
 		    }
350 350
 
351
-			unset($field, $new_id);
351
+			unset( $field, $new_id );
352 352
 		}
353 353
 	}
354 354
 
@@ -367,8 +367,8 @@  discard block
 block discarded – undo
367 367
 		if ( $f['type'] == 'form' || ( $f['type'] == 'divider' && FrmField::is_option_true( $f['field_options'], 'repeat' ) ) ) {
368 368
 			if ( FrmField::is_option_true( $f['field_options'], 'form_select' ) ) {
369 369
 				$form_select = $f['field_options']['form_select'];
370
-				if ( isset( $imported['forms'][ $form_select ] ) ) {
371
-					$f['field_options']['form_select'] = $imported['forms'][ $form_select ];
370
+				if ( isset( $imported['forms'][$form_select] ) ) {
371
+					$f['field_options']['form_select'] = $imported['forms'][$form_select];
372 372
 				}
373 373
 			}
374 374
 		}
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 				'post_id'       => (int) $item->post_id,
432 432
 				'post_parent'   => (int) $item->post_parent,
433 433
 				'menu_order'    => (int) $item->menu_order,
434
-				'post_content'  => FrmFieldsHelper::switch_field_ids((string) $item->content),
435
-				'post_excerpt'  => FrmFieldsHelper::switch_field_ids((string) $item->excerpt),
434
+				'post_content'  => FrmFieldsHelper::switch_field_ids( (string) $item->content ),
435
+				'post_excerpt'  => FrmFieldsHelper::switch_field_ids( (string) $item->excerpt ),
436 436
 				'is_sticky'     => (string) $item->is_sticky,
437 437
 				'comment_status' => (string) $item->comment_status,
438 438
 				'post_date'     => (string) $item->post_date,
@@ -443,9 +443,9 @@  discard block
 block discarded – undo
443 443
 			);
444 444
 
445 445
             $old_id = $post['post_id'];
446
-            self::populate_post($post, $item, $imported);
446
+            self::populate_post( $post, $item, $imported );
447 447
 
448
-			unset($item);
448
+			unset( $item );
449 449
 
450 450
 			$post_id = false;
451 451
             if ( $post['post_type'] == $form_action_type ) {
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 				if ( $action_control ) {
454 454
 					$post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
455 455
 				}
456
-                unset($action_control);
456
+                unset( $action_control );
457 457
             } else if ( $post['post_type'] == 'frm_styles' ) {
458 458
                 // Properly encode post content before inserting the post
459 459
                 $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
@@ -466,26 +466,26 @@  discard block
 block discarded – undo
466 466
                 $post_id = wp_insert_post( $post );
467 467
             }
468 468
 
469
-            if ( ! is_numeric($post_id) ) {
469
+            if ( ! is_numeric( $post_id ) ) {
470 470
                 continue;
471 471
             }
472 472
 
473
-            self::update_postmeta($post, $post_id);
473
+            self::update_postmeta( $post, $post_id );
474 474
 
475 475
             $this_type = 'posts';
476
-			if ( isset( $post_types[ $post['post_type'] ] ) ) {
477
-				$this_type = $post_types[ $post['post_type'] ];
476
+			if ( isset( $post_types[$post['post_type']] ) ) {
477
+				$this_type = $post_types[$post['post_type']];
478 478
             }
479 479
 
480
-            if ( isset($post['ID']) && $post_id == $post['ID'] ) {
481
-                $imported['updated'][ $this_type ]++;
480
+            if ( isset( $post['ID'] ) && $post_id == $post['ID'] ) {
481
+                $imported['updated'][$this_type] ++;
482 482
             } else {
483
-                $imported['imported'][ $this_type ]++;
483
+                $imported['imported'][$this_type] ++;
484 484
             }
485 485
 
486
-            unset($post);
486
+            unset( $post );
487 487
 
488
-			$imported['posts'][ (int) $old_id ] = $post_id;
488
+			$imported['posts'][(int) $old_id] = $post_id;
489 489
 		}
490 490
 
491 491
 		self::maybe_update_stylesheet( $imported );
@@ -494,23 +494,23 @@  discard block
 block discarded – undo
494 494
     }
495 495
 
496 496
     private static function populate_post( &$post, $item, $imported ) {
497
-		if ( isset($item->attachment_url) ) {
497
+		if ( isset( $item->attachment_url ) ) {
498 498
 			$post['attachment_url'] = (string) $item->attachment_url;
499 499
 		}
500 500
 
501
-		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) {
501
+		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][(int) $post['menu_order']] ) ) {
502 502
 		    // update to new form id
503
-		    $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
503
+		    $post['menu_order'] = $imported['forms'][(int) $post['menu_order']];
504 504
 		}
505 505
 
506 506
 		foreach ( $item->postmeta as $meta ) {
507
-		    self::populate_postmeta($post, $meta, $imported);
508
-			unset($meta);
507
+		    self::populate_postmeta( $post, $meta, $imported );
508
+			unset( $meta );
509 509
 		}
510 510
 
511
-        self::populate_taxonomies($post, $item);
511
+        self::populate_taxonomies( $post, $item );
512 512
 
513
-        self::maybe_editing_post($post);
513
+        self::maybe_editing_post( $post );
514 514
     }
515 515
 
516 516
     private static function populate_postmeta( &$post, $meta, $imported ) {
@@ -522,27 +522,27 @@  discard block
 block discarded – undo
522 522
 		);
523 523
 
524 524
 		//switch old form and field ids to new ones
525
-		if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) {
526
-		    $m['value'] = $imported['forms'][ (int) $m['value'] ];
525
+		if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][(int) $m['value']] ) ) {
526
+		    $m['value'] = $imported['forms'][(int) $m['value']];
527 527
 		} else {
528
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
528
+		    $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
529 529
 
530
-		    if ( ! empty($frm_duplicate_ids) ) {
530
+		    if ( ! empty( $frm_duplicate_ids ) ) {
531 531
 
532 532
 		        if ( $m['key'] == 'frm_dyncontent' ) {
533
-		            $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
533
+		            $m['value'] = FrmFieldsHelper::switch_field_ids( $m['value'] );
534 534
     		    } else if ( $m['key'] == 'frm_options' ) {
535 535
 
536 536
 					foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
537
-						if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) {
538
-							$m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ];
537
+						if ( isset( $m['value'][$setting_name] ) && is_numeric( $m['value'][$setting_name] ) && isset( $frm_duplicate_ids[$m['value'][$setting_name]] ) ) {
538
+							$m['value'][$setting_name] = $frm_duplicate_ids[$m['value'][$setting_name]];
539 539
     		            }
540 540
     		        }
541 541
 
542 542
                     $check_dup_array = array();
543 543
     		        if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
544
-    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
545
-    		                $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
544
+    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[$m['value']['order_by']] ) ) {
545
+    		                $m['value']['order_by'] = $frm_duplicate_ids[$m['value']['order_by']];
546 546
     		            } else if ( is_array( $m['value']['order_by'] ) ) {
547 547
                             $check_dup_array[] = 'order_by';
548 548
     		            }
@@ -553,22 +553,22 @@  discard block
 block discarded – undo
553 553
     		        }
554 554
 
555 555
                     foreach ( $check_dup_array as $check_k ) {
556
-						foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) {
557
-							if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
558
-								$m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
556
+						foreach ( (array) $m['value'][$check_k] as $mk => $mv ) {
557
+							if ( isset( $frm_duplicate_ids[$mv] ) ) {
558
+								$m['value'][$check_k][$mk] = $frm_duplicate_ids[$mv];
559 559
 		                    }
560
-		                    unset($mk, $mv);
560
+		                    unset( $mk, $mv );
561 561
 		                }
562 562
                     }
563 563
     		    }
564 564
 		    }
565 565
 		}
566 566
 
567
-		if ( ! is_array($m['value']) ) {
568
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
567
+		if ( ! is_array( $m['value'] ) ) {
568
+		    $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
569 569
 		}
570 570
 
571
-		$post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
571
+		$post['postmeta'][(string) $meta->meta_key] = $m['value'];
572 572
     }
573 573
 
574 574
     /**
@@ -584,23 +584,23 @@  discard block
 block discarded – undo
584 584
             }
585 585
 
586 586
 		    $taxonomy = (string) $att['domain'];
587
-		    if ( is_taxonomy_hierarchical($taxonomy) ) {
587
+		    if ( is_taxonomy_hierarchical( $taxonomy ) ) {
588 588
 		        $name = (string) $att['nicename'];
589
-		        $h_term = get_term_by('slug', $name, $taxonomy);
589
+		        $h_term = get_term_by( 'slug', $name, $taxonomy );
590 590
 		        if ( $h_term ) {
591 591
 		            $name = $h_term->term_id;
592 592
 		        }
593
-		        unset($h_term);
593
+		        unset( $h_term );
594 594
 		    } else {
595 595
 		        $name = (string) $c;
596 596
 		    }
597 597
 
598
-			if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) {
599
-				$post['tax_input'][ $taxonomy ] = array();
598
+			if ( ! isset( $post['tax_input'][$taxonomy] ) ) {
599
+				$post['tax_input'][$taxonomy] = array();
600 600
 			}
601 601
 
602
-			$post['tax_input'][ $taxonomy ][] = $name;
603
-		    unset($name);
602
+			$post['tax_input'][$taxonomy][] = $name;
603
+		    unset( $name );
604 604
 		}
605 605
     }
606 606
 
@@ -617,29 +617,29 @@  discard block
 block discarded – undo
617 617
 
618 618
 		if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) {
619 619
 		    $match_by['include'] = $post['post_id'];
620
-		    unset($match_by['name']);
620
+		    unset( $match_by['name'] );
621 621
 		}
622 622
 
623
-		$editing = get_posts($match_by);
623
+		$editing = get_posts( $match_by );
624 624
 
625
-        if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
625
+        if ( ! empty( $editing ) && current( $editing )->post_date == $post['post_date'] ) {
626 626
             // set the id of the post to edit
627
-            $post['ID'] = current($editing)->ID;
627
+            $post['ID'] = current( $editing )->ID;
628 628
         }
629 629
     }
630 630
 
631 631
     private static function update_postmeta( &$post, $post_id ) {
632 632
         foreach ( $post['postmeta'] as $k => $v ) {
633 633
             if ( '_edit_last' == $k ) {
634
-                $v = FrmAppHelper::get_user_id_param($v);
634
+                $v = FrmAppHelper::get_user_id_param( $v );
635 635
             } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
636 636
                 //change the attachment ID
637
-                $v = FrmProXMLHelper::get_file_id($v);
637
+                $v = FrmProXMLHelper::get_file_id( $v );
638 638
             }
639 639
 
640
-            update_post_meta($post_id, $k, $v);
640
+            update_post_meta( $post_id, $k, $v );
641 641
 
642
-            unset($k, $v);
642
+            unset( $k, $v );
643 643
         }
644 644
     }
645 645
 
@@ -656,13 +656,13 @@  discard block
 block discarded – undo
656 656
      * @param string $message
657 657
      */
658 658
 	public static function parse_message( $result, &$message, &$errors ) {
659
-        if ( is_wp_error($result) ) {
659
+        if ( is_wp_error( $result ) ) {
660 660
             $errors[] = $result->get_error_message();
661 661
         } else if ( ! $result ) {
662 662
             return;
663 663
         }
664 664
 
665
-        if ( ! is_array($result) ) {
665
+        if ( ! is_array( $result ) ) {
666 666
             $message = is_string( $result ) ? $result : print_r( $result, 1 );
667 667
             return;
668 668
         }
@@ -674,20 +674,20 @@  discard block
 block discarded – undo
674 674
 
675 675
         $message = '<ul>';
676 676
         foreach ( $result as $type => $results ) {
677
-			if ( ! isset( $t_strings[ $type ] ) ) {
677
+			if ( ! isset( $t_strings[$type] ) ) {
678 678
                 // only print imported and updated
679 679
                 continue;
680 680
             }
681 681
 
682 682
             $s_message = array();
683 683
             foreach ( $results as $k => $m ) {
684
-                self::item_count_message($m, $k, $s_message);
685
-                unset($k, $m);
684
+                self::item_count_message( $m, $k, $s_message );
685
+                unset( $k, $m );
686 686
             }
687 687
 
688
-            if ( ! empty($s_message) ) {
689
-				$message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> ';
690
-                $message .= implode(', ', $s_message);
688
+            if ( ! empty( $s_message ) ) {
689
+				$message .= '<li><strong>' . $t_strings[$type] . ':</strong> ';
690
+                $message .= implode( ', ', $s_message );
691 691
                 $message .= '</li>';
692 692
             }
693 693
         }
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
             'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
717 717
         );
718 718
 
719
-		$s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type );
719
+		$s_message[] = isset( $strings[$type] ) ? $strings[$type] : ' ' . $m . ' ' . ucfirst( $type );
720 720
     }
721 721
 
722 722
 	/**
@@ -748,14 +748,14 @@  discard block
 block discarded – undo
748 748
 	}
749 749
 
750 750
 	public static function cdata( $str ) {
751
-	    $str = maybe_unserialize($str);
752
-	    if ( is_array($str) ) {
753
-	        $str = json_encode($str);
751
+	    $str = maybe_unserialize( $str );
752
+	    if ( is_array( $str ) ) {
753
+	        $str = json_encode( $str );
754 754
 		} else if ( seems_utf8( $str ) == false ) {
755 755
 			$str = utf8_encode( $str );
756 756
 		}
757 757
 
758
-        if ( is_numeric($str) ) {
758
+        if ( is_numeric( $str ) ) {
759 759
             return $str;
760 760
         }
761 761
 
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
     * @param string $post_type
801 801
     */
802 802
     private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
803
-        if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
803
+        if ( ! isset( $form_options['create_post'] ) || ! $form_options['create_post'] ) {
804 804
             return;
805 805
         }
806 806
 
@@ -821,10 +821,10 @@  discard block
 block discarded – undo
821 821
         );
822 822
 
823 823
         foreach ( $post_settings as $post_setting ) {
824
-			if ( isset( $form_options[ $post_setting ] ) ) {
825
-				$new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
824
+			if ( isset( $form_options[$post_setting] ) ) {
825
+				$new_action['post_content'][$post_setting] = $form_options[$post_setting];
826 826
             }
827
-            unset($post_setting);
827
+            unset( $post_setting );
828 828
         }
829 829
 
830 830
 		$new_action['event'] = array( 'create', 'update' );
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
 
839 839
 			$new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields );
840 840
         }
841
-        $new_action['post_content'] = json_encode($new_action['post_content']);
841
+        $new_action['post_content'] = json_encode( $new_action['post_content'] );
842 842
 
843 843
         $exists = get_posts( array(
844 844
             'name'          => $new_action['post_name'],
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
         if ( ! $exists ) {
851 851
 			// this isn't an email, but we need to use a class that will always be included
852 852
 			FrmAppHelper::save_json_post( $new_action );
853
-            $imported['imported']['actions']++;
853
+            $imported['imported']['actions'] ++;
854 854
         }
855 855
     }
856 856
 
@@ -882,11 +882,11 @@  discard block
 block discarded – undo
882 882
         foreach ( $post_content as $key => $setting ) {
883 883
             if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
884 884
                 // Replace old IDs with new IDs
885
-				$post_content[ $key ] = str_replace( $old, $new, $setting );
885
+				$post_content[$key] = str_replace( $old, $new, $setting );
886 886
             } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
887 887
                 foreach ( $setting as $k => $val ) {
888 888
                     // Replace old IDs with new IDs
889
-					$post_content[ $key ][ $k ] = str_replace( $old, $new, $val );
889
+					$post_content[$key][$k] = str_replace( $old, $new, $val );
890 890
                 }
891 891
             }
892 892
             unset( $key, $setting );
@@ -909,14 +909,14 @@  discard block
 block discarded – undo
909 909
         // Migrate autoresponders
910 910
         self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
911 911
 
912
-        if (  empty( $notifications ) ) {
912
+        if ( empty( $notifications ) ) {
913 913
             return;
914 914
         }
915 915
 
916 916
         foreach ( $notifications as $new_notification ) {
917 917
             $new_notification['post_type']      = $post_type;
918 918
             $new_notification['post_excerpt']   = 'email';
919
-			$new_notification['post_title']     = __( 'Email Notification', 'formidable' );
919
+			$new_notification['post_title'] = __( 'Email Notification', 'formidable' );
920 920
             $new_notification['menu_order']     = $form_id;
921 921
             $new_notification['post_status']    = 'publish';
922 922
 
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
 				// Switch all other field IDs in email
930 930
                 $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
931 931
             }
932
-            $new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
932
+            $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
933 933
 
934 934
             $exists = get_posts( array(
935 935
                 'name'          => $new_notification['post_name'],
@@ -938,11 +938,11 @@  discard block
 block discarded – undo
938 938
                 'numberposts'   => 1,
939 939
             ) );
940 940
 
941
-            if ( empty($exists) ) {
941
+            if ( empty( $exists ) ) {
942 942
 				FrmAppHelper::save_json_post( $new_notification );
943
-                $imported['imported']['actions']++;
943
+                $imported['imported']['actions'] ++;
944 944
             }
945
-            unset($new_notification);
945
+            unset( $new_notification );
946 946
         }
947 947
     }
948 948
 
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
 			$form_options['notification'] = array( 0 => $form_options['notification'] );
956 956
         }
957 957
 
958
-        if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
958
+        if ( isset( $form_options['notification'] ) && is_array( $form_options['notification'] ) ) {
959 959
             foreach ( $form_options['notification'] as $email_key => $notification ) {
960 960
 
961 961
                 $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
@@ -983,12 +983,12 @@  discard block
 block discarded – undo
983 983
         // Format the reply to email and name
984 984
         $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
985 985
         foreach ( $reply_fields as $f => $val ) {
986
-			if ( isset( $notification[ $f ] ) ) {
987
-				$atts[ $f ] = $notification[ $f ];
988
-				if ( 'custom' == $notification[ $f ] ) {
989
-					$atts[ $f ] = $notification[ 'cust_' . $f ];
990
-				} else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) {
991
-					$atts[ $f ] = '[' . $atts[ $f ] . ']';
986
+			if ( isset( $notification[$f] ) ) {
987
+				$atts[$f] = $notification[$f];
988
+				if ( 'custom' == $notification[$f] ) {
989
+					$atts[$f] = $notification['cust_' . $f];
990
+				} else if ( is_numeric( $atts[$f] ) && ! empty( $atts[$f] ) ) {
991
+					$atts[$f] = '[' . $atts[$f] . ']';
992 992
                 }
993 993
             }
994 994
             unset( $f, $val );
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
 		$atts['event'] = array( 'create' );
999 999
         if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1000 1000
             $atts['event'][] = 'update';
1001
-        } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1001
+        } else if ( isset( $notification['update_email'] ) && 2 == $notification['update_email'] ) {
1002 1002
 			$atts['event'] = array( 'update' );
1003 1003
         }
1004 1004
     }
@@ -1019,18 +1019,18 @@  discard block
 block discarded – undo
1019 1019
         foreach ( $atts['email_to'] as $key => $email_field ) {
1020 1020
 
1021 1021
             if ( is_numeric( $email_field ) ) {
1022
-				$atts['email_to'][ $key ] = '[' . $email_field . ']';
1022
+				$atts['email_to'][$key] = '[' . $email_field . ']';
1023 1023
             }
1024 1024
 
1025
-            if ( strpos( $email_field, '|') ) {
1025
+            if ( strpos( $email_field, '|' ) ) {
1026 1026
                 $email_opt = explode( '|', $email_field );
1027 1027
                 if ( isset( $email_opt[0] ) ) {
1028
-					$atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1028
+					$atts['email_to'][$key] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1029 1029
                 }
1030 1030
                 unset( $email_opt );
1031 1031
             }
1032 1032
         }
1033
-        $atts['email_to'] = implode(', ', $atts['email_to']);
1033
+        $atts['email_to'] = implode( ', ', $atts['email_to'] );
1034 1034
     }
1035 1035
 
1036 1036
     private static function setup_new_notification( &$new_notification, $notification, $atts ) {
@@ -1046,12 +1046,12 @@  discard block
 block discarded – undo
1046 1046
         // Add more fields to the new notification
1047 1047
         $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1048 1048
         foreach ( $add_fields as $add_field ) {
1049
-			if ( isset( $notification[ $add_field ] ) ) {
1050
-				$new_notification['post_content'][ $add_field ] = $notification[ $add_field ];
1049
+			if ( isset( $notification[$add_field] ) ) {
1050
+				$new_notification['post_content'][$add_field] = $notification[$add_field];
1051 1051
             } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1052
-				$new_notification['post_content'][ $add_field ] = 0;
1052
+				$new_notification['post_content'][$add_field] = 0;
1053 1053
             } else {
1054
-				$new_notification['post_content'][ $add_field ] = '';
1054
+				$new_notification['post_content'][$add_field] = '';
1055 1055
             }
1056 1056
             unset( $add_field );
1057 1057
         }
@@ -1075,26 +1075,26 @@  discard block
 block discarded – undo
1075 1075
 		if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
1076 1076
 			foreach ( $post_content['conditions'] as $email_key => $val ) {
1077 1077
 				if ( is_numeric( $email_key ) ) {
1078
-					$post_content['conditions'][ $email_key ] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
1078
+					$post_content['conditions'][$email_key] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
1079 1079
 				}
1080
-				unset( $email_key, $val);
1080
+				unset( $email_key, $val );
1081 1081
 			}
1082 1082
 		}
1083 1083
 	}
1084 1084
 
1085 1085
     private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1086
-        if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1086
+        if ( isset( $form_options['auto_responder'] ) && $form_options['auto_responder'] && isset( $form_options['ar_email_message'] ) && $form_options['ar_email_message'] ) {
1087 1087
             // migrate autoresponder
1088 1088
 
1089
-            $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1090
-            if ( strpos($email_field, '|') ) {
1089
+            $email_field = isset( $form_options['ar_email_to'] ) ? $form_options['ar_email_to'] : 0;
1090
+            if ( strpos( $email_field, '|' ) ) {
1091 1091
                 // data from entries field
1092
-                $email_field = explode('|', $email_field);
1093
-                if ( isset($email_field[1]) ) {
1092
+                $email_field = explode( '|', $email_field );
1093
+                if ( isset( $email_field[1] ) ) {
1094 1094
                     $email_field = $email_field[1];
1095 1095
                 }
1096 1096
             }
1097
-            if ( is_numeric($email_field) && ! empty($email_field) ) {
1097
+            if ( is_numeric( $email_field ) && ! empty( $email_field ) ) {
1098 1098
 				$email_field = '[' . $email_field . ']';
1099 1099
             }
1100 1100
 
@@ -1102,16 +1102,16 @@  discard block
 block discarded – undo
1102 1102
             $new_notification2 = array(
1103 1103
                 'post_content'  => array(
1104 1104
                     'email_message' => $notification['ar_email_message'],
1105
-                    'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1105
+                    'email_subject' => isset( $notification['ar_email_subject'] ) ? $notification['ar_email_subject'] : '',
1106 1106
                     'email_to'      => $email_field,
1107
-                    'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1107
+                    'plain_text'    => isset( $notification['ar_plain_text'] ) ? $notification['ar_plain_text'] : 0,
1108 1108
                     'inc_user_info' => 0,
1109 1109
                 ),
1110 1110
 				'post_name'     => $form_id . '_email_' . count( $notifications ),
1111 1111
             );
1112 1112
 
1113
-            $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1114
-            $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1113
+            $reply_to = isset( $notification['ar_reply_to'] ) ? $notification['ar_reply_to'] : '';
1114
+            $reply_to_name = isset( $notification['ar_reply_to_name'] ) ? $notification['ar_reply_to_name'] : '';
1115 1115
 
1116 1116
 			if ( ! empty( $reply_to ) ) {
1117 1117
 				$new_notification2['post_content']['reply_to'] = $reply_to;
Please login to merge, or discard this patch.
classes/helpers/FrmFormsListHelper.php 2 patches
Indentation   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 }
5 5
 
6 6
 class FrmFormsListHelper extends FrmListHelper {
7
-    var $status = '';
7
+	var $status = '';
8 8
 
9 9
 	public function __construct( $args ) {
10 10
 		$this->status = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
 	}
14 14
 
15 15
 	public function prepare_items() {
16
-	    global $wpdb, $per_page, $mode;
16
+		global $wpdb, $per_page, $mode;
17 17
 
18
-	    $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
18
+		$mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
19 19
 
20 20
 		$default_orderby = 'name';
21 21
 		$default_order = 'ASC';
22 22
 
23
-        $orderby = ( isset( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : $default_orderby;
23
+		$orderby = ( isset( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : $default_orderby;
24 24
 		$order = ( isset( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : $default_order;
25 25
 
26 26
 		$page = $this->get_pagenum();
@@ -28,40 +28,40 @@  discard block
 block discarded – undo
28 28
 
29 29
 		$start = ( isset( $_REQUEST['start'] ) ) ? $_REQUEST['start'] : (( $page - 1 ) * $per_page);
30 30
 
31
-        $s_query = array();
32
-        $s_query[] = array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 1 );
31
+		$s_query = array();
32
+		$s_query[] = array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 1 );
33 33
 		switch ( $this->status ) {
34
-		    case 'template':
35
-                $s_query['is_template'] = 1;
36
-                $s_query['status !'] = 'trash';
37
-		        break;
38
-		    case 'draft':
39
-                $s_query['is_template'] = 0;
40
-                $s_query['status'] = 'draft';
41
-		        break;
42
-		    case 'trash':
43
-                $s_query['status'] = 'trash';
44
-		        break;
45
-		    default:
46
-                $s_query['is_template'] = 0;
47
-                $s_query['status !'] = 'trash';
48
-		        break;
34
+			case 'template':
35
+				$s_query['is_template'] = 1;
36
+				$s_query['status !'] = 'trash';
37
+				break;
38
+			case 'draft':
39
+				$s_query['is_template'] = 0;
40
+				$s_query['status'] = 'draft';
41
+				break;
42
+			case 'trash':
43
+				$s_query['status'] = 'trash';
44
+				break;
45
+			default:
46
+				$s_query['is_template'] = 0;
47
+				$s_query['status !'] = 'trash';
48
+				break;
49 49
 		}
50 50
 
51
-        $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
52
-	    if ( $s != '' ) {
53
-	        preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
54
-		    $search_terms = array_map('trim', $matches[0]);
55
-	        foreach ( (array) $search_terms as $term ) {
56
-                $s_query[] = array(
57
-                    'or'    => true, 'name LIKE' => $term, 'description LIKE' => $term, 'created_at LIKE' => $term,
58
-                );
59
-	            unset($term);
60
-            }
61
-	    }
51
+		$s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
52
+		if ( $s != '' ) {
53
+			preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
54
+			$search_terms = array_map('trim', $matches[0]);
55
+			foreach ( (array) $search_terms as $term ) {
56
+				$s_query[] = array(
57
+					'or'    => true, 'name LIKE' => $term, 'description LIKE' => $term, 'created_at LIKE' => $term,
58
+				);
59
+				unset($term);
60
+			}
61
+		}
62 62
 
63 63
 		$this->items = FrmForm::getAll( $s_query, $orderby . ' ' . $order, $start . ',' . $per_page );
64
-        $total_items = FrmDb::get_count( 'frm_forms', $s_query );
64
+		$total_items = FrmDb::get_count( 'frm_forms', $s_query );
65 65
 
66 66
 		$this->set_pagination_args( array(
67 67
 			'total_items' => $total_items,
@@ -70,69 +70,69 @@  discard block
 block discarded – undo
70 70
 	}
71 71
 
72 72
 	public function no_items() {
73
-	    if ( 'template' == $this->status ) {
74
-            _e( 'No Templates Found.', 'formidable' ) ?>
73
+		if ( 'template' == $this->status ) {
74
+			_e( 'No Templates Found.', 'formidable' ) ?>
75 75
             <br/><br/><?php _e( 'To add a new template:', 'formidable' ) ?>
76 76
 			<ol><li><?php printf( __( 'Create a new %1$sform%2$s.', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin?page=formidable&frm_action=new' ) ) . '"', '</a>' ) ?></li>
77 77
                 <li><?php printf(__( 'After your form is created, go to Formidable -> %1$sForms%2$s.', 'formidable' ), '<a href="?page=formidable">', '</a>') ?></li>
78 78
                 <li><?php _e( 'Place your mouse over the name of the form you just created, and click the "Create Template" link.', 'formidable' ) ?></li>
79 79
             </ol>
80 80
 <?php   } else {
81
-            _e( 'No Forms Found.', 'formidable' ) ?>
81
+			_e( 'No Forms Found.', 'formidable' ) ?>
82 82
             <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable&frm_action=new' ) ) ?>"><?php _e( 'Add New', 'formidable' ); ?></a>
83 83
 <?php   }
84 84
 	}
85 85
 
86 86
 	public function get_bulk_actions() {
87
-	    $actions = array();
87
+		$actions = array();
88 88
 
89 89
 		if ( in_array( $this->status, array( '', 'published' ) ) ) {
90
-	        $actions['bulk_create_template'] = __( 'Create Template', 'formidable' );
91
-	    }
92
-
93
-	    if ( 'trash' == $this->status ) {
94
-	        if ( current_user_can('frm_edit_forms') ) {
95
-	            $actions['bulk_untrash'] = __( 'Restore', 'formidable' );
96
-	        }
97
-
98
-	        if ( current_user_can('frm_delete_forms') ) {
99
-	            $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' );
100
-	        }
101
-	    } else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) {
102
-	        $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' );
103
-	    } else if ( current_user_can('frm_delete_forms') ) {
104
-	        $actions['bulk_delete'] = __( 'Delete');
105
-	    }
106
-
107
-        return $actions;
108
-    }
90
+			$actions['bulk_create_template'] = __( 'Create Template', 'formidable' );
91
+		}
92
+
93
+		if ( 'trash' == $this->status ) {
94
+			if ( current_user_can('frm_edit_forms') ) {
95
+				$actions['bulk_untrash'] = __( 'Restore', 'formidable' );
96
+			}
97
+
98
+			if ( current_user_can('frm_delete_forms') ) {
99
+				$actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' );
100
+			}
101
+		} else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) {
102
+			$actions['bulk_trash'] = __( 'Move to Trash', 'formidable' );
103
+		} else if ( current_user_can('frm_delete_forms') ) {
104
+			$actions['bulk_delete'] = __( 'Delete');
105
+		}
106
+
107
+		return $actions;
108
+	}
109 109
 
110 110
 	public function extra_tablenav( $which ) {
111
-        if ( 'top' != $which ) {
112
-            return;
113
-        }
111
+		if ( 'top' != $which ) {
112
+			return;
113
+		}
114 114
 
115
-        if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) {
115
+		if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) {
116 116
 ?>
117 117
             <div class="alignleft actions frm_visible_overflow">
118 118
 			<?php submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); ?>
119 119
             </div>
120 120
 <?php
121
-            return;
122
-        }
121
+			return;
122
+		}
123 123
 
124
-        if ( 'template' != $this->status ) {
125
-            return;
126
-        }
124
+		if ( 'template' != $this->status ) {
125
+			return;
126
+		}
127 127
 
128 128
 		$where = apply_filters( 'frm_forms_dropdown', array(), '' );
129 129
 		$forms = FrmForm::get_published_forms( $where );
130 130
 
131
-        $base = admin_url('admin.php?page=formidable&form_type=template');
132
-        $args = array(
133
-            'frm_action'    => 'duplicate',
134
-            'template'      => true,
135
-        );
131
+		$base = admin_url('admin.php?page=formidable&form_type=template');
132
+		$args = array(
133
+			'frm_action'    => 'duplicate',
134
+			'template'      => true,
135
+		);
136 136
 
137 137
 ?>
138 138
     <div class="alignleft actions frm_visible_overflow">
@@ -140,18 +140,18 @@  discard block
 block discarded – undo
140 140
         <a href="#" id="frm-templateDrop" class="frm-dropdown-toggle button" data-toggle="dropdown"><?php _e( 'Create New Template', 'formidable' ) ?> <b class="caret"></b></a>
141 141
 		<ul class="frm-dropdown-menu" role="menu" aria-labelledby="frm-templateDrop">
142 142
 		<?php
143
-        if ( empty( $forms ) ) { ?>
143
+		if ( empty( $forms ) ) { ?>
144 144
             <li class="frm_dropdown_li"><?php _e( 'You have not created any forms yet. <br/>You must create a form before you can make a template.', 'formidable' ) ?></li>
145 145
         <?php
146
-        } else {
147
-            foreach ( $forms as $form ) {
148
-		        $args['id'] = $form->id; ?>
146
+		} else {
147
+			foreach ( $forms as $form ) {
148
+				$args['id'] = $form->id; ?>
149 149
 			<li><a href="<?php echo esc_url( add_query_arg( $args, $base ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li>
150 150
 			<?php
151
-			    unset($form);
151
+				unset($form);
152 152
 			}
153
-        }
154
-        ?>
153
+		}
154
+		?>
155 155
 		</ul>
156 156
 	</div>
157 157
 	</div>
@@ -161,30 +161,30 @@  discard block
 block discarded – undo
161 161
 	public function get_views() {
162 162
 
163 163
 		$statuses = array(
164
-		    'published' => __( 'My Forms', 'formidable' ),
165
-		    'template'  => __( 'Templates', 'formidable' ),
166
-		    'draft'     => __( 'Drafts', 'formidable' ),
167
-		    'trash'     => __( 'Trash', 'formidable' ),
164
+			'published' => __( 'My Forms', 'formidable' ),
165
+			'template'  => __( 'Templates', 'formidable' ),
166
+			'draft'     => __( 'Drafts', 'formidable' ),
167
+			'trash'     => __( 'Trash', 'formidable' ),
168 168
 		);
169 169
 
170
-	    $links = array();
171
-	    $counts = FrmForm::get_count();
172
-        $form_type = isset( $_REQUEST['form_type'] ) ? sanitize_text_field( $_REQUEST['form_type'] ) : 'published';
170
+		$links = array();
171
+		$counts = FrmForm::get_count();
172
+		$form_type = isset( $_REQUEST['form_type'] ) ? sanitize_text_field( $_REQUEST['form_type'] ) : 'published';
173 173
 
174
-	    foreach ( $statuses as $status => $name ) {
174
+		foreach ( $statuses as $status => $name ) {
175 175
 
176
-	        if ( $status == $form_type ) {
177
-    			$class = ' class="current"';
178
-    		} else {
179
-    		    $class = '';
180
-    		}
176
+			if ( $status == $form_type ) {
177
+				$class = ' class="current"';
178
+			} else {
179
+				$class = '';
180
+			}
181 181
 
182
-    		if ( $counts->{$status} || 'published' == $status ) {
182
+			if ( $counts->{$status} || 'published' == $status ) {
183 183
 				$links[ $status ] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>';
184
-		    }
184
+			}
185 185
 
186
-		    unset($status, $name);
187
-	    }
186
+			unset($status, $name);
187
+		}
188 188
 
189 189
 		return $links;
190 190
 	}
@@ -200,16 +200,16 @@  discard block
 block discarded – undo
200 200
 	}
201 201
 
202 202
 	public function single_row( $item, $style = '' ) {
203
-	    global $frm_vars, $mode;
203
+		global $frm_vars, $mode;
204 204
 
205 205
 		// Set up the hover actions for this user
206 206
 		$actions = array();
207 207
 		$edit_link = '?page=formidable&frm_action=edit&id=' . $item->id;
208 208
 		$duplicate_link = '?page=formidable&frm_action=duplicate&id=' . $item->id;
209 209
 
210
-        $this->get_actions($actions, $item, $edit_link, $duplicate_link);
210
+		$this->get_actions($actions, $item, $edit_link, $duplicate_link);
211 211
 
212
-        $action_links = $this->row_actions( $actions );
212
+		$action_links = $this->row_actions( $actions );
213 213
 
214 214
 		// Set up the checkbox ( because the user is editable, otherwise its empty )
215 215
 		$checkbox = '<input type="checkbox" name="item-action[]" id="cb-item-action-' . absint( $item->id ) . '" value="' . esc_attr( $item->id ) . '" />';
@@ -218,9 +218,9 @@  discard block
 block discarded – undo
218 218
 
219 219
 		list( $columns, $hidden ) = $this->get_column_info();
220 220
 
221
-        $format = 'Y/m/d';
222
-        if ( 'list' != $mode ) {
223
-            $format .= ' \<\b\r \/\> g:i:s a';
221
+		$format = 'Y/m/d';
222
+		if ( 'list' != $mode ) {
223
+			$format .= ' \<\b\r \/\> g:i:s a';
224 224
 		}
225 225
 
226 226
 		foreach ( $columns as $column_name => $column_display_name ) {
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 
229 229
 			$style = '';
230 230
 			if ( in_array( $column_name, $hidden ) ) {
231
-                $class .= ' frm_hidden';
231
+				$class .= ' frm_hidden';
232 232
 			}
233 233
 
234 234
 			$class = 'class="' . esc_attr( $class ) . '"';
@@ -241,41 +241,41 @@  discard block
 block discarded – undo
241 241
 					break;
242 242
 				case 'id':
243 243
 				case 'form_key':
244
-				    $val = $item->{$column_name};
245
-				    break;
244
+					$val = $item->{$column_name};
245
+					break;
246 246
 				case 'name':
247
-				    $val = $this->get_form_name( $item, $actions, $edit_link, $mode );
248
-			        $val .= $action_links;
247
+					$val = $this->get_form_name( $item, $actions, $edit_link, $mode );
248
+					$val .= $action_links;
249 249
 
250
-				    break;
250
+					break;
251 251
 				case 'created_at':
252
-				    $date = date($format, strtotime($item->created_at));
252
+					$date = date($format, strtotime($item->created_at));
253 253
 					$val = '<abbr title="' . esc_attr( date( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>';
254 254
 					break;
255 255
 				case 'shortcode':
256 256
 					$val = '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable id=' . $item->id . ']' ) . '" /><br/>';
257
-				    if ( 'excerpt' == $mode ) {
257
+					if ( 'excerpt' == $mode ) {
258 258
 						$val .= '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable key=' . $item->form_key . ']' ) . '" />';
259
-				    }
260
-			        break;
261
-			    case 'entries':
259
+					}
260
+					break;
261
+				case 'entries':
262 262
 					if ( isset( $item->options['no_save'] ) && $item->options['no_save'] ) {
263 263
 						$val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr('Entries are not being saved', 'formidable' ) . '"></i>';
264
-			        } else {
265
-			            $text = FrmEntry::getRecordCount($item->id);
264
+					} else {
265
+						$text = FrmEntry::getRecordCount($item->id);
266 266
 						$val = current_user_can('frm_view_entries') ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text;
267
-                        unset($text);
268
-                    }
269
-			        break;
270
-                case 'type':
271
-                    $val = ( $item->is_template && $item->default_template ) ? __( 'Default', 'formidable' ) : __( 'Custom', 'formidable' );
272
-                    break;
267
+						unset($text);
268
+					}
269
+					break;
270
+				case 'type':
271
+					$val = ( $item->is_template && $item->default_template ) ? __( 'Default', 'formidable' ) : __( 'Custom', 'formidable' );
272
+					break;
273 273
 			}
274 274
 
275 275
 			if ( isset($val) ) {
276
-			    $r .= "<td $attributes>";
277
-			    $r .= $val;
278
-			    $r .= '</td>';
276
+				$r .= "<td $attributes>";
277
+				$r .= $val;
278
+				$r .= '</td>';
279 279
 			}
280 280
 			unset($val);
281 281
 		}
@@ -284,38 +284,38 @@  discard block
 block discarded – undo
284 284
 		return $r;
285 285
 	}
286 286
 
287
-    /**
288
-     * @param string $edit_link
289
-     * @param string $duplicate_link
290
-     */
291
-    private function get_actions( &$actions, $item, $edit_link, $duplicate_link ) {
287
+	/**
288
+	 * @param string $edit_link
289
+	 * @param string $duplicate_link
290
+	 */
291
+	private function get_actions( &$actions, $item, $edit_link, $duplicate_link ) {
292 292
 		if ( 'trash' == $this->status ) {
293 293
 			if ( current_user_can('frm_edit_forms') ) {
294 294
 				$actions['restore'] = FrmFormsHelper::delete_trash_link( $item->id, $item->status, 'short' );
295 295
 			}
296 296
 
297
-		    if ( current_user_can('frm_delete_forms') ) {
297
+			if ( current_user_can('frm_delete_forms') ) {
298 298
 				$trash_url = wp_nonce_url( '?page=formidable&form_status=trash&frm_action=destroy&id=' . $item->id, 'destroy_form_' . $item->id );
299 299
 				$actions['trash'] = '<a href="' . esc_url( $trash_url ) .'" class="submitdelete" onclick="return confirm(\'' . __( 'Are you sure you want to permanently delete that?', 'formidable' ) . '\')">' . __( 'Delete Permanently' ) . '</a>';
300
-    		}
301
-            return;
300
+			}
301
+			return;
302 302
 		}
303 303
 
304 304
 		if ( current_user_can('frm_edit_forms') ) {
305
-            if ( ! $item->is_template || ! $item->default_template ) {
305
+			if ( ! $item->is_template || ! $item->default_template ) {
306 306
 				$actions['frm_edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit' ) . '</a>';
307
-            }
307
+			}
308 308
 
309
-		    if ( $item->is_template ) {
309
+			if ( $item->is_template ) {
310 310
 				$actions['frm_duplicate'] = '<a href="'. esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Create Form from Template', 'formidable' ) . '</a>';
311
-            } else {
311
+			} else {
312 312
 				$actions['frm_settings'] = '<a href="' . esc_url( '?page=formidable&frm_action=settings&id=' . $item->id ) . '">' . __( 'Settings', 'formidable' ) . '</a>';
313 313
 
314
-    		    if ( FrmAppHelper::pro_is_installed() ) {
314
+				if ( FrmAppHelper::pro_is_installed() ) {
315 315
 					$actions['duplicate'] = '<a href="' . esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Duplicate', 'formidable' ) . '</a>';
316
-        	    }
317
-        	}
318
-        }
316
+				}
317
+			}
318
+		}
319 319
 
320 320
 		$actions['trash'] = FrmFormsHelper::delete_trash_link( $item->id, $item->status, 'short' );
321 321
 		if ( empty( $actions['trash'] ) ) {
@@ -324,52 +324,52 @@  discard block
 block discarded – undo
324 324
 		}
325 325
 
326 326
 		$actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview') . '</a>';
327
-    }
327
+	}
328 328
 
329
-    /**
330
-     * @param string $edit_link
331
-     */
329
+	/**
330
+	 * @param string $edit_link
331
+	 */
332 332
 	private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) {
333
-        $form_name = $item->name;
334
-        if ( trim($form_name) == '' ) {
335
-            $form_name = __( '(no title)');
336
-        }
333
+		$form_name = $item->name;
334
+		if ( trim($form_name) == '' ) {
335
+			$form_name = __( '(no title)');
336
+		}
337 337
 		$form_name = FrmAppHelper::kses( $form_name );
338 338
 		if ( 'excerpt' != $mode ) {
339 339
 			$form_name = FrmAppHelper::truncate( $form_name, 50 );
340 340
 		}
341 341
 
342
-        $val = '<strong>';
343
-        if ( 'trash' == $this->status ) {
344
-            $val .= $form_name;
345
-        } else {
342
+		$val = '<strong>';
343
+		if ( 'trash' == $this->status ) {
344
+			$val .= $form_name;
345
+		} else {
346 346
 			$val .= '<a href="' . esc_url( isset( $actions['frm_edit'] ) ? $edit_link : FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" class="row-title">' . FrmAppHelper::kses( $form_name ) . '</a> ';
347
-        }
347
+		}
348 348
 
349
-        $this->add_draft_label( $item, $val );
350
-        $val .= '</strong>';
349
+		$this->add_draft_label( $item, $val );
350
+		$val .= '</strong>';
351 351
 
352
-        $this->add_form_description( $item, $val );
352
+		$this->add_form_description( $item, $val );
353 353
 
354
-        return $val;
355
-    }
354
+		return $val;
355
+	}
356 356
 
357
-    /**
358
-     * @param string $val
359
-     */
360
-    private function add_draft_label( $item, &$val ) {
361
-        if ( 'draft' == $item->status && 'draft' != $this->status ) {
357
+	/**
358
+	 * @param string $val
359
+	 */
360
+	private function add_draft_label( $item, &$val ) {
361
+		if ( 'draft' == $item->status && 'draft' != $this->status ) {
362 362
 			$val .= ' - <span class="post-state">' . __( 'Draft', 'formidable' ) . '</span>';
363
-        }
364
-    }
365
-
366
-    /**
367
-     * @param string $val
368
-     */
369
-    private function add_form_description( $item, &$val ) {
370
-        global $mode;
371
-        if ( 'excerpt' == $mode ) {
372
-            $val .= FrmAppHelper::truncate(strip_tags($item->description), 50);
373
-        }
374
-    }
363
+		}
364
+	}
365
+
366
+	/**
367
+	 * @param string $val
368
+	 */
369
+	private function add_form_description( $item, &$val ) {
370
+		global $mode;
371
+		if ( 'excerpt' == $mode ) {
372
+			$val .= FrmAppHelper::truncate(strip_tags($item->description), 50);
373
+		}
374
+	}
375 375
 }
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 		$page = $this->get_pagenum();
27 27
 		$per_page = $this->get_items_per_page( 'formidable_page_formidable_per_page' );
28 28
 
29
-		$start = ( isset( $_REQUEST['start'] ) ) ? $_REQUEST['start'] : (( $page - 1 ) * $per_page);
29
+		$start = ( isset( $_REQUEST['start'] ) ) ? $_REQUEST['start'] : ( ( $page - 1 ) * $per_page );
30 30
 
31 31
         $s_query = array();
32 32
         $s_query[] = array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 1 );
@@ -48,15 +48,15 @@  discard block
 block discarded – undo
48 48
 		        break;
49 49
 		}
50 50
 
51
-        $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
51
+        $s = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
52 52
 	    if ( $s != '' ) {
53
-	        preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
54
-		    $search_terms = array_map('trim', $matches[0]);
53
+	        preg_match_all( '/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches );
54
+		    $search_terms = array_map( 'trim', $matches[0] );
55 55
 	        foreach ( (array) $search_terms as $term ) {
56 56
                 $s_query[] = array(
57 57
                     'or'    => true, 'name LIKE' => $term, 'description LIKE' => $term, 'created_at LIKE' => $term,
58 58
                 );
59
-	            unset($term);
59
+	            unset( $term );
60 60
             }
61 61
 	    }
62 62
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
             _e( 'No Templates Found.', 'formidable' ) ?>
75 75
             <br/><br/><?php _e( 'To add a new template:', 'formidable' ) ?>
76 76
 			<ol><li><?php printf( __( 'Create a new %1$sform%2$s.', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin?page=formidable&frm_action=new' ) ) . '"', '</a>' ) ?></li>
77
-                <li><?php printf(__( 'After your form is created, go to Formidable -> %1$sForms%2$s.', 'formidable' ), '<a href="?page=formidable">', '</a>') ?></li>
77
+                <li><?php printf( __( 'After your form is created, go to Formidable -> %1$sForms%2$s.', 'formidable' ), '<a href="?page=formidable">', '</a>' ) ?></li>
78 78
                 <li><?php _e( 'Place your mouse over the name of the form you just created, and click the "Create Template" link.', 'formidable' ) ?></li>
79 79
             </ol>
80 80
 <?php   } else {
@@ -91,17 +91,17 @@  discard block
 block discarded – undo
91 91
 	    }
92 92
 
93 93
 	    if ( 'trash' == $this->status ) {
94
-	        if ( current_user_can('frm_edit_forms') ) {
94
+	        if ( current_user_can( 'frm_edit_forms' ) ) {
95 95
 	            $actions['bulk_untrash'] = __( 'Restore', 'formidable' );
96 96
 	        }
97 97
 
98
-	        if ( current_user_can('frm_delete_forms') ) {
98
+	        if ( current_user_can( 'frm_delete_forms' ) ) {
99 99
 	            $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' );
100 100
 	        }
101
-	    } else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) {
101
+	    } else if ( EMPTY_TRASH_DAYS && current_user_can( 'frm_delete_forms' ) ) {
102 102
 	        $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' );
103
-	    } else if ( current_user_can('frm_delete_forms') ) {
104
-	        $actions['bulk_delete'] = __( 'Delete');
103
+	    } else if ( current_user_can( 'frm_delete_forms' ) ) {
104
+	        $actions['bulk_delete'] = __( 'Delete' );
105 105
 	    }
106 106
 
107 107
         return $actions;
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
             return;
113 113
         }
114 114
 
115
-        if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) {
115
+        if ( 'trash' == $this->status && current_user_can( 'frm_delete_forms' ) ) {
116 116
 ?>
117 117
             <div class="alignleft actions frm_visible_overflow">
118 118
 			<?php submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); ?>
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 		$where = apply_filters( 'frm_forms_dropdown', array(), '' );
129 129
 		$forms = FrmForm::get_published_forms( $where );
130 130
 
131
-        $base = admin_url('admin.php?page=formidable&form_type=template');
131
+        $base = admin_url( 'admin.php?page=formidable&form_type=template' );
132 132
         $args = array(
133 133
             'frm_action'    => 'duplicate',
134 134
             'template'      => true,
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 		        $args['id'] = $form->id; ?>
149 149
 			<li><a href="<?php echo esc_url( add_query_arg( $args, $base ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li>
150 150
 			<?php
151
-			    unset($form);
151
+			    unset( $form );
152 152
 			}
153 153
         }
154 154
         ?>
@@ -180,10 +180,10 @@  discard block
 block discarded – undo
180 180
     		}
181 181
 
182 182
     		if ( $counts->{$status} || 'published' == $status ) {
183
-				$links[ $status ] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>';
183
+				$links[$status] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>';
184 184
 		    }
185 185
 
186
-		    unset($status, $name);
186
+		    unset( $status, $name );
187 187
 	    }
188 188
 
189 189
 		return $links;
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 		$edit_link = '?page=formidable&frm_action=edit&id=' . $item->id;
208 208
 		$duplicate_link = '?page=formidable&frm_action=duplicate&id=' . $item->id;
209 209
 
210
-        $this->get_actions($actions, $item, $edit_link, $duplicate_link);
210
+        $this->get_actions( $actions, $item, $edit_link, $duplicate_link );
211 211
 
212 212
         $action_links = $this->row_actions( $actions );
213 213
 
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 
250 250
 				    break;
251 251
 				case 'created_at':
252
-				    $date = date($format, strtotime($item->created_at));
252
+				    $date = date( $format, strtotime( $item->created_at ) );
253 253
 					$val = '<abbr title="' . esc_attr( date( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>';
254 254
 					break;
255 255
 				case 'shortcode':
@@ -260,11 +260,11 @@  discard block
 block discarded – undo
260 260
 			        break;
261 261
 			    case 'entries':
262 262
 					if ( isset( $item->options['no_save'] ) && $item->options['no_save'] ) {
263
-						$val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr('Entries are not being saved', 'formidable' ) . '"></i>';
263
+						$val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr( 'Entries are not being saved', 'formidable' ) . '"></i>';
264 264
 			        } else {
265
-			            $text = FrmEntry::getRecordCount($item->id);
266
-						$val = current_user_can('frm_view_entries') ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text;
267
-                        unset($text);
265
+			            $text = FrmEntry::getRecordCount( $item->id );
266
+						$val = current_user_can( 'frm_view_entries' ) ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text;
267
+                        unset( $text );
268 268
                     }
269 269
 			        break;
270 270
                 case 'type':
@@ -272,12 +272,12 @@  discard block
 block discarded – undo
272 272
                     break;
273 273
 			}
274 274
 
275
-			if ( isset($val) ) {
275
+			if ( isset( $val ) ) {
276 276
 			    $r .= "<td $attributes>";
277 277
 			    $r .= $val;
278 278
 			    $r .= '</td>';
279 279
 			}
280
-			unset($val);
280
+			unset( $val );
281 281
 		}
282 282
 		$r .= '</tr>';
283 283
 
@@ -290,18 +290,18 @@  discard block
 block discarded – undo
290 290
      */
291 291
     private function get_actions( &$actions, $item, $edit_link, $duplicate_link ) {
292 292
 		if ( 'trash' == $this->status ) {
293
-			if ( current_user_can('frm_edit_forms') ) {
293
+			if ( current_user_can( 'frm_edit_forms' ) ) {
294 294
 				$actions['restore'] = FrmFormsHelper::delete_trash_link( $item->id, $item->status, 'short' );
295 295
 			}
296 296
 
297
-		    if ( current_user_can('frm_delete_forms') ) {
297
+		    if ( current_user_can( 'frm_delete_forms' ) ) {
298 298
 				$trash_url = wp_nonce_url( '?page=formidable&form_status=trash&frm_action=destroy&id=' . $item->id, 'destroy_form_' . $item->id );
299 299
 				$actions['trash'] = '<a href="' . esc_url( $trash_url ) . '" class="submitdelete" onclick="return confirm(\'' . __( 'Are you sure you want to permanently delete that?', 'formidable' ) . '\')">' . __( 'Delete Permanently' ) . '</a>';
300 300
     		}
301 301
             return;
302 302
 		}
303 303
 
304
-		if ( current_user_can('frm_edit_forms') ) {
304
+		if ( current_user_can( 'frm_edit_forms' ) ) {
305 305
             if ( ! $item->is_template || ! $item->default_template ) {
306 306
 				$actions['frm_edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit' ) . '</a>';
307 307
             }
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 			unset( $actions['trash'] );
324 324
 		}
325 325
 
326
-		$actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview') . '</a>';
326
+		$actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview' ) . '</a>';
327 327
     }
328 328
 
329 329
     /**
@@ -331,8 +331,8 @@  discard block
 block discarded – undo
331 331
      */
332 332
 	private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) {
333 333
         $form_name = $item->name;
334
-        if ( trim($form_name) == '' ) {
335
-            $form_name = __( '(no title)');
334
+        if ( trim( $form_name ) == '' ) {
335
+            $form_name = __( '(no title)' );
336 336
         }
337 337
 		$form_name = FrmAppHelper::kses( $form_name );
338 338
 		if ( 'excerpt' != $mode ) {
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
     private function add_form_description( $item, &$val ) {
370 370
         global $mode;
371 371
         if ( 'excerpt' == $mode ) {
372
-            $val .= FrmAppHelper::truncate(strip_tags($item->description), 50);
372
+            $val .= FrmAppHelper::truncate( strip_tags( $item->description ), 50 );
373 373
         }
374 374
     }
375 375
 }
Please login to merge, or discard this patch.
classes/helpers/FrmEntriesListHelper.php 2 patches
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -6,46 +6,46 @@  discard block
 block discarded – undo
6 6
 	protected $field;
7 7
 
8 8
 	public function prepare_items() {
9
-        global $wpdb, $per_page;
9
+		global $wpdb, $per_page;
10 10
 
11 11
 		$per_page = $this->get_items_per_page( 'formidable_page_formidable_entries_per_page' );
12 12
 
13
-        $form_id = $this->params['form'];
14
-        if ( ! $form_id ) {
15
-            $this->items = array();
16
-    		$this->set_pagination_args( array(
17
-    			'total_items' => 0,
13
+		$form_id = $this->params['form'];
14
+		if ( ! $form_id ) {
15
+			$this->items = array();
16
+			$this->set_pagination_args( array(
17
+				'total_items' => 0,
18 18
 				'per_page' => $per_page,
19
-    		) );
20
-            return;
21
-        }
19
+			) );
20
+			return;
21
+		}
22 22
 
23 23
 		$default_orderby = 'id';
24 24
 		$default_order = 'DESC';
25 25
 
26
-	    $s_query = array( 'it.form_id' => $form_id );
26
+		$s_query = array( 'it.form_id' => $form_id );
27 27
 
28 28
 		$s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
29 29
 
30
-	    if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
31
-	        $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
32
-	        $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid);
33
-	    }
30
+		if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
31
+			$fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
32
+			$s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid);
33
+		}
34 34
 
35
-        $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
36
-        if ( strpos($orderby, 'meta') !== false ) {
37
-            $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
35
+		$orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
36
+		if ( strpos($orderby, 'meta') !== false ) {
37
+			$order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
38 38
 			$orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : '';
39
-        }
39
+		}
40 40
 
41 41
 		$order = isset( $_REQUEST['order'] ) ? sanitize_title( $_REQUEST['order'] ) : $default_order;
42 42
 		$order = ' ORDER BY ' . $orderby . ' ' . $order;
43 43
 
44
-        $page = $this->get_pagenum();
44
+		$page = $this->get_pagenum();
45 45
 		$start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page );
46 46
 
47 47
 		$this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, false );
48
-        $total_items = FrmEntry::getRecordCount($s_query);
48
+		$total_items = FrmEntry::getRecordCount($s_query);
49 49
 
50 50
 		$this->set_pagination_args( array(
51 51
 			'total_items' => $total_items,
@@ -54,17 +54,17 @@  discard block
 block discarded – undo
54 54
 	}
55 55
 
56 56
 	public function no_items() {
57
-        $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
58
-	    if ( ! empty($s) ) {
59
-            _e( 'No Entries Found', 'formidable' );
60
-            return;
61
-        }
62
-
63
-        $form_id = $form = $this->params['form'];
64
-        if ( $form_id ) {
65
-            $form = FrmForm::getOne($form_id);
66
-        }
67
-        $colspan = $this->get_column_count();
57
+		$s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
58
+		if ( ! empty($s) ) {
59
+			_e( 'No Entries Found', 'formidable' );
60
+			return;
61
+		}
62
+
63
+		$form_id = $form = $this->params['form'];
64
+		if ( $form_id ) {
65
+			$form = FrmForm::getOne($form_id);
66
+		}
67
+		$colspan = $this->get_column_count();
68 68
 
69 69
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php' );
70 70
 	}
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
 	}
75 75
 
76 76
 	/**
77
-	* Gets the name of the primary column in the Entries screen
78
-	*
79
-	* @since 2.0.14
80
-	*
81
-	* @return string $primary_column
82
-	*/
77
+	 * Gets the name of the primary column in the Entries screen
78
+	 *
79
+	 * @since 2.0.14
80
+	 *
81
+	 * @return string $primary_column
82
+	 */
83 83
 	protected function get_primary_column_name() {
84 84
 		$columns = get_column_headers( $this->screen );
85 85
 		$hidden = get_hidden_columns( $this->screen );
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 
104 104
 		$this->get_actions( $actions, $item, $view_link );
105 105
 
106
-        $action_links = $this->row_actions( $actions );
106
+		$action_links = $this->row_actions( $actions );
107 107
 
108 108
 		// Set up the checkbox ( because the user is editable, otherwise its empty )
109 109
 		$checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />";
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		$r = "<tr id='item-action-{$item->id}'$style>";
112 112
 
113 113
 		list( $columns, $hidden, , $primary ) = $this->get_column_info();
114
-        $action_col = false;
114
+		$action_col = false;
115 115
 
116 116
 		foreach ( $columns as $column_name => $column_display_name ) {
117 117
 			$class = $column_name . ' column-' . $column_name;
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
 			if ( in_array( $column_name, $hidden ) ) {
124 124
 				$class .= ' frm_hidden';
125 125
 			} else if ( ! $action_col && ! in_array( $column_name, array( 'cb', 'id', 'form_id', 'post_id' ) ) ) {
126
-			    $action_col = $column_name;
127
-            }
126
+				$action_col = $column_name;
127
+			}
128 128
 
129 129
 			$attributes = 'class="' . esc_attr( $class ) . '"';
130 130
 			unset($class);
@@ -140,30 +140,30 @@  discard block
 block discarded – undo
140 140
 				case 'ip':
141 141
 				case 'id':
142 142
 				case 'item_key':
143
-				    $val = $item->{$col_name};
144
-				    break;
143
+					$val = $item->{$col_name};
144
+					break;
145 145
 				case 'name':
146 146
 				case 'description':
147
-				    $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
148
-				    break;
147
+					$val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
148
+					break;
149 149
 				case 'created_at':
150 150
 				case 'updated_at':
151
-				    $date = FrmAppHelper::get_formatted_time($item->{$col_name});
151
+					$date = FrmAppHelper::get_formatted_time($item->{$col_name});
152 152
 					$val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>';
153 153
 					break;
154 154
 				case 'is_draft':
155
-				    $val = empty($item->is_draft) ? __( 'No') : __( 'Yes');
156
-			        break;
155
+					$val = empty($item->is_draft) ? __( 'No') : __( 'Yes');
156
+					break;
157 157
 				case 'form_id':
158
-				    $val = FrmFormsHelper::edit_form_link($item->form_id);
159
-    				break;
158
+					$val = FrmFormsHelper::edit_form_link($item->form_id);
159
+					break;
160 160
 				case 'post_id':
161
-				    $val = FrmAppHelper::post_edit_link($item->post_id);
162
-				    break;
161
+					$val = FrmAppHelper::post_edit_link($item->post_id);
162
+					break;
163 163
 				case 'user_id':
164
-				    $user = get_userdata($item->user_id);
165
-				    $val = $user->user_login;
166
-				    break;
164
+					$user = get_userdata($item->user_id);
165
+					$val = $user->user_login;
166
+					break;
167 167
 				default:
168 168
 					$val = apply_filters( 'frm_entries_' . $col_name . '_column', false, compact( 'item' ) );
169 169
 					if ( $val === false ) {
@@ -173,15 +173,15 @@  discard block
 block discarded – undo
173 173
 			}
174 174
 
175 175
 			if ( isset( $val ) ) {
176
-			    $r .= "<td $attributes>";
176
+				$r .= "<td $attributes>";
177 177
 				if ( $column_name == $action_col ) {
178 178
 					$edit_link = '?page=formidable-entries&frm_action=edit&id=' . $item->id;
179 179
 					$r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> ';
180
-			        $r .= $action_links;
180
+					$r .= $action_links;
181 181
 				} else {
182
-			        $r .= $val;
183
-			    }
184
-			    $r .= '</td>';
182
+					$r .= $val;
183
+				}
184
+				$r .= '</td>';
185 185
 			}
186 186
 			unset($val);
187 187
 		}
@@ -190,19 +190,19 @@  discard block
 block discarded – undo
190 190
 		return $r;
191 191
 	}
192 192
 
193
-    /**
194
-     * @param string $view_link
195
-     */
196
-    private function get_actions( &$actions, $item, $view_link ) {
193
+	/**
194
+	 * @param string $view_link
195
+	 */
196
+	private function get_actions( &$actions, $item, $view_link ) {
197 197
 		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
198 198
 
199
-        if ( current_user_can('frm_delete_entries') ) {
199
+		if ( current_user_can('frm_delete_entries') ) {
200 200
 			$delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
201 201
 			$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>';
202
-	    }
202
+		}
203 203
 
204
-        $actions = apply_filters('frm_row_actions', $actions, $item);
205
-    }
204
+		$actions = apply_filters('frm_row_actions', $actions, $item);
205
+	}
206 206
 
207 207
 	private function get_column_value( $item, &$val ) {
208 208
 		$col_name = $this->column_name;
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -25,15 +25,15 @@  discard block
 block discarded – undo
25 25
 
26 26
 	    $s_query = array( 'it.form_id' => $form_id );
27 27
 
28
-		$s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
28
+		$s = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
29 29
 
30 30
 	    if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
31 31
 	        $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
32
-	        $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid);
32
+	        $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid );
33 33
 	    }
34 34
 
35 35
         $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
36
-        if ( strpos($orderby, 'meta') !== false ) {
36
+        if ( strpos( $orderby, 'meta' ) !== false ) {
37 37
             $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
38 38
 			$orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : '';
39 39
         }
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 		$start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page );
46 46
 
47 47
 		$this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, false );
48
-        $total_items = FrmEntry::getRecordCount($s_query);
48
+        $total_items = FrmEntry::getRecordCount( $s_query );
49 49
 
50 50
 		$this->set_pagination_args( array(
51 51
 			'total_items' => $total_items,
@@ -55,14 +55,14 @@  discard block
 block discarded – undo
55 55
 
56 56
 	public function no_items() {
57 57
         $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
58
-	    if ( ! empty($s) ) {
58
+	    if ( ! empty( $s ) ) {
59 59
             _e( 'No Entries Found', 'formidable' );
60 60
             return;
61 61
         }
62 62
 
63 63
         $form_id = $form = $this->params['form'];
64 64
         if ( $form_id ) {
65
-            $form = FrmForm::getOne($form_id);
65
+            $form = FrmForm::getOne( $form_id );
66 66
         }
67 67
         $colspan = $this->get_column_count();
68 68
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 
111 111
 		$r = "<tr id='item-action-{$item->id}'$style>";
112 112
 
113
-		list( $columns, $hidden, , $primary ) = $this->get_column_info();
113
+		list( $columns, $hidden,, $primary ) = $this->get_column_info();
114 114
         $action_col = false;
115 115
 
116 116
 		foreach ( $columns as $column_name => $column_display_name ) {
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
             }
128 128
 
129 129
 			$attributes = 'class="' . esc_attr( $class ) . '"';
130
-			unset($class);
130
+			unset( $class );
131 131
 			$attributes .= ' data-colname="' . $column_display_name . '"';
132 132
 
133 133
 			$col_name = preg_replace( '/^(' . $this->params['form'] . '_)/', '', $column_name );
@@ -144,24 +144,24 @@  discard block
 block discarded – undo
144 144
 				    break;
145 145
 				case 'name':
146 146
 				case 'description':
147
-				    $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
147
+				    $val = FrmAppHelper::truncate( strip_tags( $item->{$col_name}), 100 );
148 148
 				    break;
149 149
 				case 'created_at':
150 150
 				case 'updated_at':
151
-				    $date = FrmAppHelper::get_formatted_time($item->{$col_name});
151
+				    $date = FrmAppHelper::get_formatted_time( $item->{$col_name});
152 152
 					$val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>';
153 153
 					break;
154 154
 				case 'is_draft':
155
-				    $val = empty($item->is_draft) ? __( 'No') : __( 'Yes');
155
+				    $val = empty( $item->is_draft ) ? __( 'No' ) : __( 'Yes' );
156 156
 			        break;
157 157
 				case 'form_id':
158
-				    $val = FrmFormsHelper::edit_form_link($item->form_id);
158
+				    $val = FrmFormsHelper::edit_form_link( $item->form_id );
159 159
     				break;
160 160
 				case 'post_id':
161
-				    $val = FrmAppHelper::post_edit_link($item->post_id);
161
+				    $val = FrmAppHelper::post_edit_link( $item->post_id );
162 162
 				    break;
163 163
 				case 'user_id':
164
-				    $user = get_userdata($item->user_id);
164
+				    $user = get_userdata( $item->user_id );
165 165
 				    $val = $user->user_login;
166 166
 				    break;
167 167
 				default:
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 			    }
184 184
 			    $r .= '</td>';
185 185
 			}
186
-			unset($val);
186
+			unset( $val );
187 187
 		}
188 188
 		$r .= '</tr>';
189 189
 
@@ -196,12 +196,12 @@  discard block
 block discarded – undo
196 196
     private function get_actions( &$actions, $item, $view_link ) {
197 197
 		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
198 198
 
199
-        if ( current_user_can('frm_delete_entries') ) {
199
+        if ( current_user_can( 'frm_delete_entries' ) ) {
200 200
 			$delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
201 201
 			$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>';
202 202
 	    }
203 203
 
204
-        $actions = apply_filters('frm_row_actions', $actions, $item);
204
+        $actions = apply_filters( 'frm_row_actions', $actions, $item );
205 205
     }
206 206
 
207 207
 	private function get_column_value( $item, &$val ) {
Please login to merge, or discard this patch.
classes/helpers/FrmStylesHelper.php 2 patches
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -1,67 +1,67 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class FrmStylesHelper {
3 3
 
4
-    public static function jquery_themes() {
5
-        $themes = array(
6
-            'ui-lightness'  => 'UI Lightness',
7
-            'ui-darkness'   => 'UI Darkness',
8
-            'smoothness'    => 'Smoothness',
9
-            'start'         => 'Start',
10
-            'redmond'       => 'Redmond',
11
-            'sunny'         => 'Sunny',
12
-            'overcast'      => 'Overcast',
13
-            'le-frog'       => 'Le Frog',
14
-            'flick'         => 'Flick',
4
+	public static function jquery_themes() {
5
+		$themes = array(
6
+			'ui-lightness'  => 'UI Lightness',
7
+			'ui-darkness'   => 'UI Darkness',
8
+			'smoothness'    => 'Smoothness',
9
+			'start'         => 'Start',
10
+			'redmond'       => 'Redmond',
11
+			'sunny'         => 'Sunny',
12
+			'overcast'      => 'Overcast',
13
+			'le-frog'       => 'Le Frog',
14
+			'flick'         => 'Flick',
15 15
 			'pepper-grinder' => 'Pepper Grinder',
16
-            'eggplant'      => 'Eggplant',
17
-            'dark-hive'     => 'Dark Hive',
18
-            'cupertino'     => 'Cupertino',
19
-            'south-street'  => 'South Street',
20
-            'blitzer'       => 'Blitzer',
21
-            'humanity'      => 'Humanity',
22
-            'hot-sneaks'    => 'Hot Sneaks',
23
-            'excite-bike'   => 'Excite Bike',
24
-            'vader'         => 'Vader',
25
-            'dot-luv'       => 'Dot Luv',
26
-            'mint-choc'     => 'Mint Choc',
27
-            'black-tie'     => 'Black Tie',
28
-            'trontastic'    => 'Trontastic',
29
-            'swanky-purse'  => 'Swanky Purse',
30
-        );
31
-
32
-        $themes = apply_filters('frm_jquery_themes', $themes);
33
-        return $themes;
34
-    }
16
+			'eggplant'      => 'Eggplant',
17
+			'dark-hive'     => 'Dark Hive',
18
+			'cupertino'     => 'Cupertino',
19
+			'south-street'  => 'South Street',
20
+			'blitzer'       => 'Blitzer',
21
+			'humanity'      => 'Humanity',
22
+			'hot-sneaks'    => 'Hot Sneaks',
23
+			'excite-bike'   => 'Excite Bike',
24
+			'vader'         => 'Vader',
25
+			'dot-luv'       => 'Dot Luv',
26
+			'mint-choc'     => 'Mint Choc',
27
+			'black-tie'     => 'Black Tie',
28
+			'trontastic'    => 'Trontastic',
29
+			'swanky-purse'  => 'Swanky Purse',
30
+		);
31
+
32
+		$themes = apply_filters('frm_jquery_themes', $themes);
33
+		return $themes;
34
+	}
35 35
 
36 36
 	public static function jquery_css_url( $theme_css ) {
37
-        if ( $theme_css == -1 ) {
38
-            return;
39
-        }
40
-
41
-        if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) {
42
-            $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css';
43
-        } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) {
44
-            $css_file = $theme_css;
45
-        } else {
46
-            $uploads = self::get_upload_base();
37
+		if ( $theme_css == -1 ) {
38
+			return;
39
+		}
40
+
41
+		if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) {
42
+			$css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css';
43
+		} else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) {
44
+			$css_file = $theme_css;
45
+		} else {
46
+			$uploads = self::get_upload_base();
47 47
 			$file_path = '/formidable/css/' . $theme_css . '/jquery-ui.css';
48
-            if ( file_exists($uploads['basedir'] . $file_path) ) {
49
-                $css_file = $uploads['baseurl'] . $file_path;
50
-            } else {
48
+			if ( file_exists($uploads['basedir'] . $file_path) ) {
49
+				$css_file = $uploads['baseurl'] . $file_path;
50
+			} else {
51 51
 				$css_file = FrmAppHelper::jquery_ui_base_url() . '/themes/' . $theme_css . '/jquery-ui.min.css';
52
-            }
53
-        }
52
+			}
53
+		}
54 54
 
55
-        return $css_file;
56
-    }
55
+		return $css_file;
56
+	}
57 57
 
58
-    public static function enqueue_jquery_css() {
58
+	public static function enqueue_jquery_css() {
59 59
 		$form = self::get_form_for_page();
60 60
 		$theme_css = FrmStylesController::get_style_val( 'theme_css', $form );
61
-        if ( $theme_css != -1 ) {
62
-            wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version());
63
-        }
64
-    }
61
+		if ( $theme_css != -1 ) {
62
+			wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version());
63
+		}
64
+	}
65 65
 
66 66
 	public static function get_form_for_page() {
67 67
 		global $frm_vars;
@@ -77,14 +77,14 @@  discard block
 block discarded – undo
77 77
 		return $form_id;
78 78
 	}
79 79
 
80
-    public static function get_upload_base() {
81
-        $uploads = wp_upload_dir();
82
-        if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) {
83
-            $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']);
84
-        }
80
+	public static function get_upload_base() {
81
+		$uploads = wp_upload_dir();
82
+		if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) {
83
+			$uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']);
84
+		}
85 85
 
86
-        return $uploads;
87
-    }
86
+		return $uploads;
87
+	}
88 88
 
89 89
 	public static function style_menu( $active = '' ) {
90 90
 ?>
@@ -94,22 +94,22 @@  discard block
 block discarded – undo
94 94
 			<a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a>
95 95
         </h2>
96 96
 <?php
97
-    }
97
+	}
98 98
 
99
-    public static function minus_icons() {
100
-        return array(
99
+	public static function minus_icons() {
100
+		return array(
101 101
 			0 => array( '-' => '62e', '+' => '62f' ),
102 102
 			1 => array( '-' => '600', '+' => '602' ),
103 103
 			2 => array( '-' => '604', '+' => '603' ),
104 104
 			3 => array( '-' => '633', '+' => '632' ),
105 105
 			4 => array( '-' => '613', '+' => '60f' ),
106
-        );
107
-    }
106
+		);
107
+	}
108 108
 
109
-    public static function arrow_icons() {
110
-        $minus_icons = self::minus_icons();
109
+	public static function arrow_icons() {
110
+		$minus_icons = self::minus_icons();
111 111
 
112
-        return array(
112
+		return array(
113 113
 			6 => array( '-' => '62d', '+' => '62a' ),
114 114
 			0 => array( '-' => '60d', '+' => '609' ),
115 115
 			1 => array( '-' => '60e', '+' => '60c' ),
@@ -117,44 +117,44 @@  discard block
 block discarded – undo
117 117
 			3 => array( '-' => '62b', '+' => '628' ),
118 118
 			4 => array( '-' => '62c', '+' => '629' ),
119 119
 			5 => array( '-' => '635', '+' => '634' ),
120
-            'p0' => $minus_icons[0],
121
-            'p1' => $minus_icons[1],
122
-            'p2' => $minus_icons[2],
123
-            'p3' => $minus_icons[3],
124
-            'p4' => $minus_icons[4],
125
-        );
126
-    }
127
-
128
-    /**
129
-     * @since 2.0
130
-     * @return The class for this icon
131
-     */
120
+			'p0' => $minus_icons[0],
121
+			'p1' => $minus_icons[1],
122
+			'p2' => $minus_icons[2],
123
+			'p3' => $minus_icons[3],
124
+			'p4' => $minus_icons[4],
125
+		);
126
+	}
127
+
128
+	/**
129
+	 * @since 2.0
130
+	 * @return The class for this icon
131
+	 */
132 132
 	public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) {
133
-        if ( 'arrow' == $type && is_numeric($key) ) {
134
-            //frm_arrowup6_icon
133
+		if ( 'arrow' == $type && is_numeric($key) ) {
134
+			//frm_arrowup6_icon
135 135
 			$arrow = array( '-' => 'down', '+' => 'up' );
136 136
 			$class = 'frm_arrow' . $arrow[ $icon ];
137
-        } else {
138
-            //frm_minus1_icon
139
-            $key = str_replace('p', '', $key);
137
+		} else {
138
+			//frm_minus1_icon
139
+			$key = str_replace('p', '', $key);
140 140
 			$plus = array( '-' => 'minus', '+' => 'plus' );
141 141
 			$class = 'frm_' . $plus[ $icon ];
142
-        }
142
+		}
143 143
 
144
-        if ( $key ) {
145
-            $class .= $key;
146
-        }
147
-        $class .= '_icon';
144
+		if ( $key ) {
145
+			$class .= $key;
146
+		}
147
+		$class .= '_icon';
148 148
 
149
-        return $class;
150
-    }
149
+		return $class;
150
+	}
151 151
 
152 152
 	public static function bs_icon_select( $style, $frm_style, $type = 'arrow' ) {
153 153
 		$function_name = $type . '_icons';
154 154
 		$icons = self::$function_name();
155 155
 		unset( $function_name );
156 156
 
157
-        $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon';
157
+		$name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon';
158 158
 ?>
159 159
     	<select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js">
160 160
             <?php foreach ( $icons as $key => $icon ) { ?>
@@ -187,22 +187,22 @@  discard block
 block discarded – undo
187 187
             </ul>
188 188
         </div>
189 189
 <?php
190
-    }
190
+	}
191 191
 
192 192
 	public static function hex2rgb( $hex ) {
193
-        $hex = str_replace('#', '', $hex);
193
+		$hex = str_replace('#', '', $hex);
194 194
 
195
-        if ( strlen($hex) == 3 ) {
195
+		if ( strlen($hex) == 3 ) {
196 196
 			$r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) );
197 197
 			$g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) );
198 198
 			$b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) );
199
-        } else {
199
+		} else {
200 200
 			$r = hexdec( substr( $hex, 0, 2 ) );
201 201
 			$g = hexdec( substr( $hex, 2, 2 ) );
202 202
 			$b = hexdec( substr( $hex, 4, 2 ) );
203
-        }
203
+		}
204 204
 		$rgb = array( $r, $g, $b );
205
-        return implode(',', $rgb); // returns the rgb values separated by commas
206
-        //return $rgb; // returns an array with the rgb values
207
-    }
205
+		return implode(',', $rgb); // returns the rgb values separated by commas
206
+		//return $rgb; // returns an array with the rgb values
207
+	}
208 208
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
             'swanky-purse'  => 'Swanky Purse',
30 30
         );
31 31
 
32
-        $themes = apply_filters('frm_jquery_themes', $themes);
32
+        $themes = apply_filters( 'frm_jquery_themes', $themes );
33 33
         return $themes;
34 34
     }
35 35
 
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
 
41 41
         if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) {
42 42
             $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css';
43
-        } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) {
43
+        } else if ( preg_match( '/^http.?:\/\/.*\..*$/', $theme_css ) ) {
44 44
             $css_file = $theme_css;
45 45
         } else {
46 46
             $uploads = self::get_upload_base();
47 47
 			$file_path = '/formidable/css/' . $theme_css . '/jquery-ui.css';
48
-            if ( file_exists($uploads['basedir'] . $file_path) ) {
48
+            if ( file_exists( $uploads['basedir'] . $file_path ) ) {
49 49
                 $css_file = $uploads['baseurl'] . $file_path;
50 50
             } else {
51 51
 				$css_file = FrmAppHelper::jquery_ui_base_url() . '/themes/' . $theme_css . '/jquery-ui.min.css';
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		$form = self::get_form_for_page();
60 60
 		$theme_css = FrmStylesController::get_style_val( 'theme_css', $form );
61 61
         if ( $theme_css != -1 ) {
62
-            wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version());
62
+            wp_enqueue_style( 'jquery-theme', self::jquery_css_url( $theme_css ), array(), FrmAppHelper::plugin_version() );
63 63
         }
64 64
     }
65 65
 
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 
80 80
     public static function get_upload_base() {
81 81
         $uploads = wp_upload_dir();
82
-        if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) {
83
-            $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']);
82
+        if ( is_ssl() && ! preg_match( '/^https:\/\/.*\..*$/', $uploads['baseurl'] ) ) {
83
+            $uploads['baseurl'] = str_replace( 'http://', 'https://', $uploads['baseurl'] );
84 84
         }
85 85
 
86 86
         return $uploads;
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         <h2 class="nav-tab-wrapper">
92 92
 			<a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles' ) ) ?>" class="nav-tab <?php echo ( '' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Edit Styles', 'formidable' ) ?></a>
93 93
 			<a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=manage' ) ) ?>" class="nav-tab <?php echo ( 'manage' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Manage Form Styles', 'formidable' ) ?></a>
94
-			<a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a>
94
+			<a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a>
95 95
         </h2>
96 96
 <?php
97 97
     }
@@ -130,15 +130,15 @@  discard block
 block discarded – undo
130 130
      * @return The class for this icon
131 131
      */
132 132
 	public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) {
133
-        if ( 'arrow' == $type && is_numeric($key) ) {
133
+        if ( 'arrow' == $type && is_numeric( $key ) ) {
134 134
             //frm_arrowup6_icon
135 135
 			$arrow = array( '-' => 'down', '+' => 'up' );
136
-			$class = 'frm_arrow' . $arrow[ $icon ];
136
+			$class = 'frm_arrow' . $arrow[$icon];
137 137
         } else {
138 138
             //frm_minus1_icon
139
-            $key = str_replace('p', '', $key);
139
+            $key = str_replace( 'p', '', $key );
140 140
 			$plus = array( '-' => 'minus', '+' => 'plus' );
141
-			$class = 'frm_' . $plus[ $icon ];
141
+			$class = 'frm_' . $plus[$icon];
142 142
         }
143 143
 
144 144
         if ( $key ) {
@@ -156,9 +156,9 @@  discard block
 block discarded – undo
156 156
 
157 157
         $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon';
158 158
 ?>
159
-    	<select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js">
159
+    	<select name="<?php echo esc_attr( $frm_style->get_field_name( $name ) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js">
160 160
             <?php foreach ( $icons as $key => $icon ) { ?>
161
-			<option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[ $name ], $key ) ?>>
161
+			<option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[$name], $key ) ?>>
162 162
 				<?php echo '&#xe' . $icon['+'] . '; &#xe' . $icon['-'] . ';'; ?>
163 163
             </option>
164 164
             <?php } ?>
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
 
167 167
         <div class="btn-group hide-if-no-js" id="frm_<?php echo esc_attr( $name ) ?>_select">
168 168
             <button class="multiselect dropdown-toggle btn btn-default" data-toggle="dropdown" type="button">
169
-				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '+', $type ) ) ?>"></i>
170
-				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '-', $type ) ) ?>"></i>
169
+				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '+', $type ) ) ?>"></i>
170
+				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '-', $type ) ) ?>"></i>
171 171
                 <b class="caret"></b>
172 172
             </button>
173 173
             <ul class="multiselect-container frm-dropdown-menu">
@@ -190,9 +190,9 @@  discard block
 block discarded – undo
190 190
     }
191 191
 
192 192
 	public static function hex2rgb( $hex ) {
193
-        $hex = str_replace('#', '', $hex);
193
+        $hex = str_replace( '#', '', $hex );
194 194
 
195
-        if ( strlen($hex) == 3 ) {
195
+        if ( strlen( $hex ) == 3 ) {
196 196
 			$r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) );
197 197
 			$g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) );
198 198
 			$b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) );
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 			$b = hexdec( substr( $hex, 4, 2 ) );
203 203
         }
204 204
 		$rgb = array( $r, $g, $b );
205
-        return implode(',', $rgb); // returns the rgb values separated by commas
205
+        return implode( ',', $rgb ); // returns the rgb values separated by commas
206 206
         //return $rgb; // returns an array with the rgb values
207 207
     }
208 208
 }
Please login to merge, or discard this patch.
css/_single_theme.css.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -3,23 +3,23 @@  discard block
 block discarded – undo
3 3
 if ( isset($_GET['frm_style_setting']) || isset($_GET['flat']) ) {
4 4
 	if ( isset( $_GET['frm_style_setting'] ) ) {
5 5
 		extract( $_GET['frm_style_setting']['post_content'] );
6
-    } else {
7
-        extract($_GET);
8
-    }
6
+	} else {
7
+		extract($_GET);
8
+	}
9 9
 
10
-    $important_style = isset($important_style) ? $important_style : 0;
11
-    $auto_width = isset($auto_width) ? $auto_width : 0;
12
-    $submit_style = isset($submit_style) ? $submit_style : 0;
10
+	$important_style = isset($important_style) ? $important_style : 0;
11
+	$auto_width = isset($auto_width) ? $auto_width : 0;
12
+	$submit_style = isset($submit_style) ? $submit_style : 0;
13 13
 
14 14
 	$style_name = FrmAppHelper::simple_get( 'style_name', 'sanitize_title' );
15 15
 	if ( ! empty( $style_name ) ) {
16 16
 		$style_class = $style_name . '.with_frm_style';
17
-    } else {
18
-        $style_class = 'with_frm_style';
19
-    }
17
+	} else {
18
+		$style_class = 'with_frm_style';
19
+	}
20 20
 } else {
21 21
 	$style_class = 'frm_style_' . $style->post_name . '.with_frm_style';
22
-    extract($style->post_content);
22
+	extract($style->post_content);
23 23
 }
24 24
 
25 25
 $important = empty($important_style) ? '' : ' !important';
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 }
41 41
 
42 42
 if ( ! isset($collapse_icon) ) {
43
-    $collapse_icon = 0;
43
+	$collapse_icon = 0;
44 44
 }
45 45
 
46 46
 if ( ! isset( $center_form ) ) {
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
     color:#<?php echo esc_html( $text_color . $important ) ?>;
338 338
 	background-color:<?php echo esc_html( ( empty( $bg_color ) ? 'transparent' : '#' . $bg_color ) . $important ); ?>;
339 339
 <?php if ( ! empty($important) ) {
340
-    echo esc_html( 'background-image:none' . $important . ';' );
340
+	echo esc_html( 'background-image:none' . $important . ';' );
341 341
 }
342 342
 ?>
343 343
     border-color:#<?php echo esc_html( $border_color . $important ) ?>;
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
     color:#<?php echo esc_html( $submit_active_color . $important ) ?>;
549 549
 }
550 550
 <?php
551
-    }
551
+	}
552 552
 }
553 553
 ?>
554 554
 
@@ -851,11 +851,11 @@  discard block
 block discarded – undo
851 851
 
852 852
 .<?php echo esc_html( $style_class ) ?> .chosen-container-single .chosen-single div{
853 853
 <?php
854
-    // calculate the top position based on field padding
855
-    $top_pad = explode(' ', $field_pad);
856
-    $top_pad = reset($top_pad); // the top padding is listed first
857
-    $pad_unit = preg_replace('/[0-9]+/', '', $top_pad); //px, em, rem...
858
-    $top_margin = (int) str_replace($pad_unit, '', $top_pad) / 2;
854
+	// calculate the top position based on field padding
855
+	$top_pad = explode(' ', $field_pad);
856
+	$top_pad = reset($top_pad); // the top padding is listed first
857
+	$pad_unit = preg_replace('/[0-9]+/', '', $top_pad); //px, em, rem...
858
+	$top_margin = (int) str_replace($pad_unit, '', $top_pad) / 2;
859 859
 ?>
860 860
     top:<?php echo esc_html( $top_margin . $pad_unit . $important ) ?>;
861 861
 }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( isset($_GET['frm_style_setting']) || isset($_GET['flat']) ) {
3
+if ( isset( $_GET['frm_style_setting'] ) || isset( $_GET['flat'] ) ) {
4 4
 	if ( isset( $_GET['frm_style_setting'] ) ) {
5 5
 		extract( $_GET['frm_style_setting']['post_content'] );
6 6
     } else {
7
-        extract($_GET);
7
+        extract( $_GET );
8 8
     }
9 9
 
10
-    $important_style = isset($important_style) ? $important_style : 0;
11
-    $auto_width = isset($auto_width) ? $auto_width : 0;
12
-    $submit_style = isset($submit_style) ? $submit_style : 0;
10
+    $important_style = isset( $important_style ) ? $important_style : 0;
11
+    $auto_width = isset( $auto_width ) ? $auto_width : 0;
12
+    $submit_style = isset( $submit_style ) ? $submit_style : 0;
13 13
 
14 14
 	$style_name = FrmAppHelper::simple_get( 'style_name', 'sanitize_title' );
15 15
 	if ( ! empty( $style_name ) ) {
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
19 19
     }
20 20
 } else {
21 21
 	$style_class = 'frm_style_' . $style->post_name . '.with_frm_style';
22
-    extract($style->post_content);
22
+    extract( $style->post_content );
23 23
 }
24 24
 
25
-$important = empty($important_style) ? '' : ' !important';
25
+$important = empty( $important_style ) ? '' : ' !important';
26 26
 $label_margin = (int) $width + 10;
27 27
 
28 28
 $minus_icons = FrmStylesHelper::minus_icons();
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	$change_margin = 650 . 'px';
40 40
 }
41 41
 
42
-if ( ! isset($collapse_icon) ) {
42
+if ( ! isset( $collapse_icon ) ) {
43 43
     $collapse_icon = 0;
44 44
 }
45 45
 
@@ -148,11 +148,11 @@  discard block
 block discarded – undo
148 148
 }
149 149
 
150 150
 .<?php echo esc_html( $style_class ) ?> .frm_icon_font.frm_minus_icon:before{
151
-	content:"\e<?php echo esc_html( isset( $minus_icons[ $repeat_icon ] ) ? $minus_icons[ $repeat_icon ]['-'] : $minus_icons[1]['-'] ) ?>";
151
+	content:"\e<?php echo esc_html( isset( $minus_icons[$repeat_icon] ) ? $minus_icons[$repeat_icon]['-'] : $minus_icons[1]['-'] ) ?>";
152 152
 }
153 153
 
154 154
 .<?php echo esc_html( $style_class ) ?> .frm_icon_font.frm_plus_icon:before{
155
-	content:"\e<?php echo esc_html( isset( $minus_icons[ $repeat_icon ] ) ? $minus_icons[ $repeat_icon ]['+'] : $minus_icons[1]['+'] ) ?>";
155
+	content:"\e<?php echo esc_html( isset( $minus_icons[$repeat_icon] ) ? $minus_icons[$repeat_icon]['+'] : $minus_icons[1]['+'] ) ?>";
156 156
 }
157 157
 
158 158
 .<?php echo esc_html( $style_class ) ?> .frm_icon_font.frm_minus_icon:before,
@@ -161,11 +161,11 @@  discard block
 block discarded – undo
161 161
 }
162 162
 
163 163
 .<?php echo esc_html( $style_class ) ?> .frm_trigger.active .frm_icon_font.frm_arrow_icon:before{
164
-	content:"\e<?php echo esc_html( isset( $arrow_icons[ $collapse_icon ] ) ? $arrow_icons[ $collapse_icon ]['-'] : $arrow_icons[1]['-'] ) ?>";
164
+	content:"\e<?php echo esc_html( isset( $arrow_icons[$collapse_icon] ) ? $arrow_icons[$collapse_icon]['-'] : $arrow_icons[1]['-'] ) ?>";
165 165
 }
166 166
 
167 167
 .<?php echo esc_html( $style_class ) ?> .frm_trigger .frm_icon_font.frm_arrow_icon:before{
168
-	content:"\e<?php echo esc_html( isset( $arrow_icons[ $collapse_icon ] ) ? $arrow_icons[ $collapse_icon ]['+'] : $arrow_icons[1]['+'] ) ?>";
168
+	content:"\e<?php echo esc_html( isset( $arrow_icons[$collapse_icon] ) ? $arrow_icons[$collapse_icon]['+'] : $arrow_icons[1]['+'] ) ?>";
169 169
 }
170 170
 
171 171
 .<?php echo esc_html( $style_class ) ?> .form-field{
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 .<?php echo esc_html( $style_class ) ?> .frm_error{
188 188
     margin:0;
189 189
     padding:0;
190
-    font-family:<?php echo FrmAppHelper::kses( stripslashes($font) . $important ) ?>;
190
+    font-family:<?php echo FrmAppHelper::kses( stripslashes( $font ) . $important ) ?>;
191 191
     font-size:<?php echo esc_html( $description_font_size . $important ) ?>;
192 192
     color:#<?php echo esc_html( $description_color . $important ) ?>;
193 193
     font-weight:<?php echo esc_html( $description_weight . $important ) ?>;
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 
294 294
 .<?php echo esc_html( $style_class ) ?> .frm_scale label{
295 295
     font-weight:<?php echo esc_html( $check_weight . $important ) ?>;
296
-    font-family:<?php echo FrmAppHelper::kses( stripslashes($font) . $important ) ?>;
296
+    font-family:<?php echo FrmAppHelper::kses( stripslashes( $font ) . $important ) ?>;
297 297
     font-size:<?php echo esc_html( $check_font_size . $important ) ?>;
298 298
     color:#<?php echo esc_html( $check_label_color . $important ) ?>;
299 299
 }
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 .<?php echo esc_html( $style_class ) ?> select,
314 314
 .<?php echo esc_html( $style_class ) ?> textarea,
315 315
 .<?php echo esc_html( $style_class ) ?> .chosen-container{
316
-	font-family:<?php echo FrmAppHelper::kses( stripslashes($font) . $important ) ?>;
316
+	font-family:<?php echo FrmAppHelper::kses( stripslashes( $font ) . $important ) ?>;
317 317
     font-size:<?php echo esc_html( $field_font_size ) ?>;
318 318
     margin-bottom:0<?php echo esc_html( $important ) ?>;
319 319
 }
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 .<?php echo esc_html( $style_class ) ?> .chosen-container-single .chosen-single{
337 337
     color:#<?php echo esc_html( $text_color . $important ) ?>;
338 338
 	background-color:<?php echo esc_html( ( empty( $bg_color ) ? 'transparent' : '#' . $bg_color ) . $important ); ?>;
339
-<?php if ( ! empty($important) ) {
339
+<?php if ( ! empty( $important ) ) {
340 340
     echo esc_html( 'background-image:none' . $important . ';' );
341 341
 }
342 342
 ?>
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
     line-height:normal<?php echo esc_html( $important ) ?>;
495 495
     text-align:center;
496 496
     background:#<?php echo esc_html( $submit_bg_color );
497
-	if ( ! empty($submit_bg_img) ) {
497
+	if ( ! empty( $submit_bg_img ) ) {
498 498
 		echo esc_html( ' url(' . $submit_bg_img . ')' );
499 499
 	}
500 500
 	echo esc_html( $important ); ?>;
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 
593 593
 .<?php echo esc_html( $style_class ) ?> .frm_radio label,
594 594
 .<?php echo esc_html( $style_class ) ?> .frm_checkbox label{
595
-    font-family:<?php echo FrmAppHelper::kses( stripslashes($font) . $important ) ?>;
595
+    font-family:<?php echo FrmAppHelper::kses( stripslashes( $font ) . $important ) ?>;
596 596
     font-size:<?php echo esc_html( $check_font_size . $important ) ?>;
597 597
     color:#<?php echo esc_html( $check_label_color . $important ) ?>;
598 598
     font-weight:<?php echo esc_html( $check_weight . $important ) ?>;
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
     -webkit-border-radius:<?php echo esc_html( $border_radius . $important ) ?>;
734 734
     border-radius:<?php echo esc_html( $border_radius . $important ) ?>;
735 735
     font-size:<?php echo esc_html( $submit_font_size . $important ) ?>;
736
-    font-family:<?php echo FrmAppHelper::kses( stripslashes($font) . $important ) ?>;
736
+    font-family:<?php echo FrmAppHelper::kses( stripslashes( $font ) . $important ) ?>;
737 737
     font-weight:<?php echo esc_html( $submit_weight . $important ) ?>;
738 738
     color:#<?php echo esc_html( $submit_text_color . $important ) ?>;
739 739
     background:#<?php echo esc_html( $submit_bg_color . $important ) ?>;
@@ -852,10 +852,10 @@  discard block
 block discarded – undo
852 852
 .<?php echo esc_html( $style_class ) ?> .chosen-container-single .chosen-single div{
853 853
 <?php
854 854
     // calculate the top position based on field padding
855
-    $top_pad = explode(' ', $field_pad);
856
-    $top_pad = reset($top_pad); // the top padding is listed first
857
-    $pad_unit = preg_replace('/[0-9]+/', '', $top_pad); //px, em, rem...
858
-    $top_margin = (int) str_replace($pad_unit, '', $top_pad) / 2;
855
+    $top_pad = explode( ' ', $field_pad );
856
+    $top_pad = reset( $top_pad ); // the top padding is listed first
857
+    $pad_unit = preg_replace( '/[0-9]+/', '', $top_pad ); //px, em, rem...
858
+    $top_margin = (int) str_replace( $pad_unit, '', $top_pad ) / 2;
859 859
 ?>
860 860
     top:<?php echo esc_html( $top_margin . $pad_unit . $important ) ?>;
861 861
 }
Please login to merge, or discard this patch.
css/custom_theme.css.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! isset($saving) ) {
3
-    header( 'Content-type: text/css' );
3
+	header( 'Content-type: text/css' );
4 4
 
5
-    if ( isset($css) && $css ) {
6
-        echo $css;
7
-        die();
8
-    }
5
+	if ( isset($css) && $css ) {
6
+		echo $css;
7
+		die();
8
+	}
9 9
 }
10 10
 
11 11
 if ( ! isset($frm_style) ) {
12
-    $frm_style = new FrmStyle();
12
+	$frm_style = new FrmStyle();
13 13
 }
14 14
 
15 15
 $styles = $frm_style->get_all();
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 <?php
188 188
 foreach ( $styles as $style ) {
189 189
 	include( dirname( __FILE__ ) . '/_single_theme.css.php' );
190
-    unset($style);
190
+	unset($style);
191 191
 }
192 192
 ?>
193 193
 
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,19 +1,19 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! isset($saving) ) {
2
+if ( ! isset( $saving ) ) {
3 3
     header( 'Content-type: text/css' );
4 4
 
5
-    if ( isset($css) && $css ) {
5
+    if ( isset( $css ) && $css ) {
6 6
         echo $css;
7 7
         die();
8 8
     }
9 9
 }
10 10
 
11
-if ( ! isset($frm_style) ) {
11
+if ( ! isset( $frm_style ) ) {
12 12
     $frm_style = new FrmStyle();
13 13
 }
14 14
 
15 15
 $styles = $frm_style->get_all();
16
-$default_style = $frm_style->get_default_style($styles);
16
+$default_style = $frm_style->get_default_style( $styles );
17 17
 $defaults = $default_style->post_content;
18 18
 ?>
19 19
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 <?php
188 188
 foreach ( $styles as $style ) {
189 189
 	include( dirname( __FILE__ ) . '/_single_theme.css.php' );
190
-    unset($style);
190
+    unset( $style );
191 191
 }
192 192
 ?>
193 193
 
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
     overflow:hidden!important;
620 620
 }
621 621
 
622
-<?php include( dirname(__FILE__) . '/frm_grids.css' ); ?>
622
+<?php include( dirname( __FILE__ ) . '/frm_grids.css' ); ?>
623 623
 
624 624
 /* Left and right label styling for non-Formidable styling - very basic, not responsive */
625 625
 .frm_form_field.frm_left_container label.frm_primary_label{
@@ -975,7 +975,7 @@  discard block
 block discarded – undo
975 975
     -moz-border-radius:<?php echo $defaults['border_radius'] ?>;
976 976
     -webkit-border-radius:<?php echo $defaults['border_radius'] ?>;
977 977
     border-radius:<?php echo $defaults['border_radius'] ?>;
978
-    width:<?php echo ($defaults['field_width'] == '' ? 'auto' : $defaults['field_width']) ?>;
978
+    width:<?php echo ( $defaults['field_width'] == '' ? 'auto' : $defaults['field_width'] ) ?>;
979 979
     max-width:100%;
980 980
     font-size:<?php echo $defaults['field_font_size'] ?>;
981 981
     padding:<?php echo $defaults['field_pad'] ?>;
Please login to merge, or discard this patch.
classes/views/frm-fields/input.php 2 patches
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -10,41 +10,41 @@  discard block
 block discarded – undo
10 10
 <?php
11 11
 
12 12
 } else if ( $field['type'] == 'radio' ) {
13
-    $read_only = false;
13
+	$read_only = false;
14 14
 	if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
15
-        $read_only = true; ?>
15
+		$read_only = true; ?>
16 16
 <input type="hidden" value="<?php echo esc_attr( $field['value'] ) ?>" name="<?php echo esc_attr( $field_name ) ?>" />
17 17
 <?php
18
-    }
18
+	}
19 19
 
20
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
20
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
21 21
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
22
-    } else if ( is_array($field['options']) ) {
23
-        foreach ( $field['options'] as $opt_key => $opt ) {
22
+	} else if ( is_array($field['options']) ) {
23
+		foreach ( $field['options'] as $opt_key => $opt ) {
24 24
 			if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
25
-                continue;
26
-            }
25
+				continue;
26
+			}
27 27
 
28
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
29
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?>
28
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
29
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?>
30 30
 			<div class="<?php echo esc_attr( apply_filters( 'frm_radio_class', 'frm_radio', $field, $field_val ) ) ?>"><?php
31 31
 
32 32
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
33 33
 				?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
34
-            }
35
-            $checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' ';
34
+			}
35
+			$checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' ';
36 36
 
37
-            $other_opt = false;
38
-            $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
39
-            ?>
37
+			$other_opt = false;
38
+			$other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
39
+			?>
40 40
             <input type="radio" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php
41
-            echo $checked;
42
-            do_action('frm_field_input_html', $field);
41
+			echo $checked;
42
+			do_action('frm_field_input_html', $field);
43 43
 ?>/><?php
44 44
 
45 45
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
46 46
 				echo ' ' . $opt . '</label>';
47
-            }
47
+			}
48 48
 
49 49
 			FrmFieldsHelper::include_other_input( array(
50 50
 				'other_opt' => $other_opt, 'read_only' => $read_only,
@@ -53,14 +53,14 @@  discard block
 block discarded – undo
53 53
 				'html_id' => $html_id, 'opt_key' => $opt_key,
54 54
 			) );
55 55
 
56
-            unset( $other_opt, $other_args );
56
+			unset( $other_opt, $other_args );
57 57
 ?></div>
58 58
 <?php
59
-        }
60
-    }
59
+		}
60
+	}
61 61
 } else if ( $field['type'] == 'select' ) {
62
-    $read_only = false;
63
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
62
+	$read_only = false;
63
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
64 64
 		echo FrmFieldsHelper::dropdown_categories( array( 'name' => $field_name, 'field' => $field ) );
65 65
 	} else {
66 66
 		if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 			?>
94 94
 		<option value="<?php echo esc_attr($field_val) ?>" <?php echo $selected ? ' selected="selected"' : ''; ?><?php echo ( FrmFieldsHelper::is_other_opt( $opt_key ) ) ? ' class="frm_other_trigger"' : '';?>><?php echo ($opt == '') ? ' ' : $opt; ?></option>
95 95
     <?php
96
-    	} ?>
96
+		} ?>
97 97
 </select>
98 98
 <?php
99 99
 		FrmFieldsHelper::include_other_input( array(
@@ -102,52 +102,52 @@  discard block
 block discarded – undo
102 102
 			'value' => $other_args['value'], 'field' => $field,
103 103
 			'html_id' => $html_id, 'opt_key' => false,
104 104
 		) );
105
-    }
105
+	}
106 106
 } else if ( $field['type'] == 'checkbox' ) {
107
-    $checked_values = $field['value'];
108
-    $read_only = false;
107
+	$checked_values = $field['value'];
108
+	$read_only = false;
109 109
 
110 110
 	if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
111
-        $read_only = true;
112
-        if ( $checked_values ) {
113
-            foreach ( (array) $checked_values as $checked_value ) { ?>
111
+		$read_only = true;
112
+		if ( $checked_values ) {
113
+			foreach ( (array) $checked_values as $checked_value ) { ?>
114 114
 <input type="hidden" value="<?php echo esc_attr( $checked_value ) ?>" name="<?php echo esc_attr( $field_name ) ?>[]" />
115 115
 <?php
116
-            }
117
-        } else { ?>
116
+			}
117
+		} else { ?>
118 118
 <input type="hidden" value="" name="<?php echo esc_attr( $field_name ) ?>[]" />
119 119
 <?php
120
-        }
121
-    }
120
+		}
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
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
125
-    } else if ( $field['options'] ) {
126
-        foreach ( $field['options'] as $opt_key => $opt ) {
127
-            if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
128
-                continue;
129
-            }
130
-
131
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
132
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
133
-            $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
134
-
135
-            // Check if other opt, and get values for other field if needed
136
-            $other_opt = false;
125
+	} else if ( $field['options'] ) {
126
+		foreach ( $field['options'] as $opt_key => $opt ) {
127
+			if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
128
+				continue;
129
+			}
130
+
131
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
132
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
133
+			$checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
134
+
135
+			// Check if other opt, and get values for other field if needed
136
+			$other_opt = false;
137 137
 			$other_args = FrmFieldsHelper::prepare_other_input( compact( 'field', 'field_name', 'opt_key' ), $other_opt, $checked );
138 138
 
139
-            ?>
139
+			?>
140 140
 			<div class="<?php echo esc_attr( apply_filters( 'frm_checkbox_class', 'frm_checkbox', $field, $field_val ) ) ?>" id="frm_checkbox_<?php echo esc_attr( $field['id'] ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
141 141
 
142
-            if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
143
-                ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
144
-            }
142
+			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
143
+				?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
144
+			}
145 145
 
146
-            ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php
146
+			?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php
147 147
 
148
-            if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
148
+			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
149 149
 				echo ' ' . $opt . '</label>';
150
-            }
150
+			}
151 151
 
152 152
 			FrmFieldsHelper::include_other_input( array(
153 153
 				'other_opt' => $other_opt, 'read_only' => $read_only,
@@ -156,17 +156,17 @@  discard block
 block discarded – undo
156 156
 				'html_id' => $html_id, 'opt_key' => $opt_key,
157 157
 			) );
158 158
 
159
-            unset( $other_opt, $other_args, $checked );
159
+			unset( $other_opt, $other_args, $checked );
160 160
 
161
-            ?></div>
161
+			?></div>
162 162
 <?php
163
-        }
164
-    }
163
+		}
164
+	}
165 165
 } else if ( $field['type'] == 'captcha' && ! FrmAppHelper::is_admin() ) {
166
-    $frm_settings = FrmAppHelper::get_settings();
167
-    if ( ! empty($frm_settings->pubkey) ) {
168
-        FrmFieldsHelper::display_recaptcha($field);
169
-    }
166
+	$frm_settings = FrmAppHelper::get_settings();
167
+	if ( ! empty($frm_settings->pubkey) ) {
168
+		FrmFieldsHelper::display_recaptcha($field);
169
+	}
170 170
 } else {
171 171
 	do_action( 'frm_form_fields', $field, $field_name, compact( 'errors', 'html_id' ) );
172 172
 	do_action( 'frm_form_field_' . $field['type'], $field, $field_name, compact( 'errors', 'html_id' ) );
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php if ( in_array( $field['type'], array( 'email', 'url', 'text' ) ) ) { ?>
2
-<input type="<?php echo ( $frm_settings->use_html || $field['type'] == 'password' ) ? $field['type'] : 'text'; ?>" id="<?php echo esc_attr( $html_id ) ?>" name="<?php echo esc_attr( $field_name ) ?>" value="<?php echo esc_attr( $field['value'] ) ?>" <?php do_action('frm_field_input_html', $field) ?>/>
2
+<input type="<?php echo ( $frm_settings->use_html || $field['type'] == 'password' ) ? $field['type'] : 'text'; ?>" id="<?php echo esc_attr( $html_id ) ?>" name="<?php echo esc_attr( $field_name ) ?>" value="<?php echo esc_attr( $field['value'] ) ?>" <?php do_action( 'frm_field_input_html', $field ) ?>/>
3 3
 <?php } else if ( $field['type'] == 'textarea' ) { ?>
4 4
 <textarea name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php
5 5
 if ( $field['max'] ) {
6 6
 	echo 'rows="' . esc_attr( $field['max'] ) . '" ';
7 7
 }
8
-do_action('frm_field_input_html', $field);
9
-?>><?php echo FrmAppHelper::esc_textarea($field['value']) ?></textarea>
8
+do_action( 'frm_field_input_html', $field );
9
+?>><?php echo FrmAppHelper::esc_textarea( $field['value'] ) ?></textarea>
10 10
 <?php
11 11
 
12 12
 } else if ( $field['type'] == 'radio' ) {
@@ -17,29 +17,29 @@  discard block
 block discarded – undo
17 17
 <?php
18 18
     }
19 19
 
20
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
20
+    if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) {
21 21
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
22
-    } else if ( is_array($field['options']) ) {
22
+    } else if ( is_array( $field['options'] ) ) {
23 23
         foreach ( $field['options'] as $opt_key => $opt ) {
24 24
 			if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
25 25
                 continue;
26 26
             }
27 27
 
28
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
29
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?>
28
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
29
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field ); ?>
30 30
 			<div class="<?php echo esc_attr( apply_filters( 'frm_radio_class', 'frm_radio', $field, $field_val ) ) ?>"><?php
31 31
 
32 32
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
33 33
 				?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
34 34
             }
35
-            $checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' ';
35
+            $checked = FrmAppHelper::check_selected( $field['value'], $field_val ) ? 'checked="checked" ' : ' ';
36 36
 
37 37
             $other_opt = false;
38 38
             $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
39 39
             ?>
40 40
             <input type="radio" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php
41 41
             echo $checked;
42
-            do_action('frm_field_input_html', $field);
42
+            do_action( 'frm_field_input_html', $field );
43 43
 ?>/><?php
44 44
 
45 45
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     }
61 61
 } else if ( $field['type'] == 'select' ) {
62 62
     $read_only = false;
63
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
63
+    if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) {
64 64
 		echo FrmFieldsHelper::dropdown_categories( array( 'name' => $field_name, 'field' => $field ) );
65 65
 	} else {
66 66
 		if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
@@ -71,12 +71,12 @@  discard block
 block discarded – undo
71 71
 					<input type="hidden" value="<?php echo esc_attr( $selected_value ) ?>" name="<?php echo esc_attr( $field_name ) ?>[]" /> <?php
72 72
 				}
73 73
 			} else { ?>
74
-				<input type="hidden" value="<?php echo esc_attr($field['value']) ?>" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" /> <?php
74
+				<input type="hidden" value="<?php echo esc_attr( $field['value'] ) ?>" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" /> <?php
75 75
 			} ?>
76
-				<select disabled="disabled" <?php do_action('frm_field_input_html', $field) ?>> <?php
76
+				<select disabled="disabled" <?php do_action( 'frm_field_input_html', $field ) ?>> <?php
77 77
 
78 78
 		} else { ?>
79
-<select name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php do_action('frm_field_input_html', $field) ?>>
79
+<select name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php do_action( 'frm_field_input_html', $field ) ?>>
80 80
 <?php   }
81 81
 
82 82
 		$other_opt = $other_checked = false;
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 				}
92 92
 			}
93 93
 			?>
94
-		<option value="<?php echo esc_attr($field_val) ?>" <?php echo $selected ? ' selected="selected"' : ''; ?><?php echo ( FrmFieldsHelper::is_other_opt( $opt_key ) ) ? ' class="frm_other_trigger"' : '';?>><?php echo ($opt == '') ? ' ' : $opt; ?></option>
94
+		<option value="<?php echo esc_attr( $field_val ) ?>" <?php echo $selected ? ' selected="selected"' : ''; ?><?php echo ( FrmFieldsHelper::is_other_opt( $opt_key ) ) ? ' class="frm_other_trigger"' : ''; ?>><?php echo ( $opt == '' ) ? ' ' : $opt; ?></option>
95 95
     <?php
96 96
     	} ?>
97 97
 </select>
@@ -120,17 +120,17 @@  discard block
 block discarded – undo
120 120
         }
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
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
125 125
     } else if ( $field['options'] ) {
126 126
         foreach ( $field['options'] as $opt_key => $opt ) {
127
-            if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
127
+            if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
128 128
                 continue;
129 129
             }
130 130
 
131
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
132
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
133
-            $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
131
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
132
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field );
133
+            $checked = FrmAppHelper::check_selected( $checked_values, $field_val ) ? ' checked="checked"' : '';
134 134
 
135 135
             // Check if other opt, and get values for other field if needed
136 136
             $other_opt = false;
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
                 ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
144 144
             }
145 145
 
146
-            ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php
146
+            ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action( 'frm_field_input_html', $field ) ?> /><?php
147 147
 
148 148
             if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
149 149
 				echo ' ' . $opt . '</label>';
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
     }
165 165
 } else if ( $field['type'] == 'captcha' && ! FrmAppHelper::is_admin() ) {
166 166
     $frm_settings = FrmAppHelper::get_settings();
167
-    if ( ! empty($frm_settings->pubkey) ) {
168
-        FrmFieldsHelper::display_recaptcha($field);
167
+    if ( ! empty( $frm_settings->pubkey ) ) {
168
+        FrmFieldsHelper::display_recaptcha( $field );
169 169
     }
170 170
 } else {
171 171
 	do_action( 'frm_form_fields', $field, $field_name, compact( 'errors', 'html_id' ) );
Please login to merge, or discard this patch.
classes/controllers/FrmFieldsController.php 2 patches
Spacing   +89 added lines, -89 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'];
@@ -34,17 +34,17 @@  discard block
 block discarded – undo
34 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 39
             ob_start();
40 40
 			include( $path . '/classes/views/frm-forms/add_field.php' );
41
-            $field_html[ $field_id ] = ob_get_contents();
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
     }
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 * Create a new field with ajax
54 54
 	 */
55 55
     public static function create() {
56
-		FrmAppHelper::permission_check('frm_edit_forms');
56
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
57 57
         check_ajax_referer( 'frm_ajax', 'nonce' );
58 58
 
59 59
 		$field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' );
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 		$field = self::include_new_field( $field_type, $form_id, $section_id );
64 64
 
65 65
         // this hook will allow for multiple fields to be added at once
66
-        do_action('frm_after_field_created', $field, $form_id);
66
+        do_action( 'frm_after_field_created', $field, $form_id );
67 67
 
68 68
         wp_die();
69 69
     }
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	public static function include_new_field( $field_type, $form_id, $section_id = 0 ) {
80 80
         $values = array();
81 81
         if ( FrmAppHelper::pro_is_installed() ) {
82
-            $values['post_type'] = FrmProFormsHelper::post_type($form_id);
82
+            $values['post_type'] = FrmProFormsHelper::post_type( $form_id );
83 83
         }
84 84
 
85 85
 		$field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id );
@@ -92,27 +92,27 @@  discard block
 block discarded – undo
92 92
             return false;
93 93
         }
94 94
 
95
-        $field = self::include_single_field($field_id, $values, $form_id);
95
+        $field = self::include_single_field( $field_id, $values, $form_id );
96 96
 
97 97
         return $field;
98 98
     }
99 99
 
100 100
 	public static function edit_name( $field = 'name', $id = '' ) {
101
-		FrmAppHelper::permission_check('frm_edit_forms');
101
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
102 102
         check_ajax_referer( 'frm_ajax', 'nonce' );
103 103
 
104
-        if ( empty($field) ) {
104
+        if ( empty( $field ) ) {
105 105
             $field = 'name';
106 106
         }
107 107
 
108
-        if ( empty($id) ) {
108
+        if ( empty( $id ) ) {
109 109
 			$id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
110 110
 			$id = str_replace( 'field_label_', '', $id );
111 111
         }
112 112
 
113 113
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' );
114 114
 		$value = trim( $value );
115
-        if ( trim(strip_tags($value)) == '' ) {
115
+        if ( trim( strip_tags( $value ) ) == '' ) {
116 116
             // set blank value if there is no content
117 117
             $value = '';
118 118
         }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     }
127 127
 
128 128
     public static function update_ajax_option() {
129
-		FrmAppHelper::permission_check('frm_edit_forms');
129
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
130 130
         check_ajax_referer( 'frm_ajax', 'nonce' );
131 131
 
132 132
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 		if ( isset( $_POST['separate_value'] ) ) {
140 140
 			$new_val = FrmField::is_option_true( $field, 'separate_value' ) ? 0 : 1;
141 141
 			$field->field_options['separate_value'] = $new_val;
142
-			unset($new_val);
142
+			unset( $new_val );
143 143
 		}
144 144
 
145 145
         FrmField::update( $field_id, array(
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
     }
151 151
 
152 152
     public static function duplicate() {
153
-		FrmAppHelper::permission_check('frm_edit_forms');
153
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
154 154
         check_ajax_referer( 'frm_ajax', 'nonce' );
155 155
 
156 156
         global $wpdb;
@@ -173,11 +173,11 @@  discard block
 block discarded – undo
173 173
 
174 174
         $values['field_order'] = $field_count + 1;
175 175
 
176
-        if ( ! $field_id = FrmField::create($values) ) {
176
+        if ( ! $field_id = FrmField::create( $values ) ) {
177 177
             wp_die();
178 178
         }
179 179
 
180
-        self::include_single_field($field_id, $values);
180
+        self::include_single_field( $field_id, $values );
181 181
 
182 182
         wp_die();
183 183
     }
@@ -186,9 +186,9 @@  discard block
 block discarded – undo
186 186
      * Load a single field in the form builder along with all needed variables
187 187
      */
188 188
     public static function include_single_field( $field_id, $values, $form_id = 0 ) {
189
-        $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
189
+        $field = FrmFieldsHelper::setup_edit_vars( FrmField::getOne( $field_id ) );
190 190
 		$field_name = 'item_meta[' . $field_id . ']';
191
-        $html_id = FrmFieldsHelper::get_html_id($field);
191
+        $html_id = FrmFieldsHelper::get_html_id( $field );
192 192
         $id = $form_id ? $form_id : $field['form_id'];
193 193
         if ( $field['type'] == 'html' ) {
194 194
             $field['stop_filter'] = true;
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
     }
201 201
 
202 202
     public static function destroy() {
203
-		FrmAppHelper::permission_check('frm_edit_forms');
203
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
204 204
         check_ajax_referer( 'frm_ajax', 'nonce' );
205 205
 
206 206
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
@@ -212,14 +212,14 @@  discard block
 block discarded – undo
212 212
 
213 213
     //Add Single Option or Other Option
214 214
     public static function add_option() {
215
-		FrmAppHelper::permission_check('frm_edit_forms');
215
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
216 216
         check_ajax_referer( 'frm_ajax', 'nonce' );
217 217
 
218 218
 		$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
219 219
 		$opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
220 220
 
221 221
         //Get the field
222
-        $field = FrmField::getOne($id);
222
+        $field = FrmField::getOne( $id );
223 223
 
224 224
 		if ( ! empty( $field->options ) ) {
225 225
 			$keys = array_keys( $field->options );
@@ -242,13 +242,13 @@  discard block
 block discarded – undo
242 242
 			$first_opt = reset( $field->options );
243 243
 			$next_opt = count( $field->options );
244 244
             if ( $first_opt != '' ) {
245
-                $next_opt++;
245
+                $next_opt ++;
246 246
             }
247 247
 			$opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt;
248
-            unset($next_opt);
248
+            unset( $next_opt );
249 249
         }
250 250
         $field_val = $opt;
251
-		$field->options[ $opt_key ] = $opt;
251
+		$field->options[$opt_key] = $opt;
252 252
 
253 253
         //Update options in DB
254 254
 		FrmField::update( $id, array( 'options' => $field->options ) );
@@ -257,13 +257,13 @@  discard block
 block discarded – undo
257 257
         $field = array(
258 258
             'type'  => $field_data->type,
259 259
             'id'    => $id,
260
-            'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
260
+            'separate_value' => isset( $field_data->field_options['separate_value'] ) ? $field_data->field_options['separate_value'] : 0,
261 261
             'form_id' => $field_data->form_id,
262 262
             'field_key' => $field_data->field_key,
263 263
         );
264 264
 
265 265
 		$field_name = 'item_meta[' . $id . ']';
266
-        $html_id = FrmFieldsHelper::get_html_id($field);
266
+        $html_id = FrmFieldsHelper::get_html_id( $field );
267 267
         $checked = '';
268 268
 
269 269
         if ( 'other' == $opt_type ) {
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
     }
276 276
 
277 277
     public static function edit_option() {
278
-		FrmAppHelper::permission_check('frm_edit_forms');
278
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
279 279
         check_ajax_referer( 'frm_ajax', 'nonce' );
280 280
 
281 281
 		$element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
@@ -289,28 +289,28 @@  discard block
 block discarded – undo
289 289
             $new_label = $update_value;
290 290
         }
291 291
 
292
-        $field = FrmField::getOne($id);
292
+        $field = FrmField::getOne( $id );
293 293
         $separate_values = FrmField::is_option_true( $field, 'separate_value' );
294 294
 
295
-        $this_opt_id = end($ids);
296
-		$this_opt = (array) $field->options[ $this_opt_id ];
297
-		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false );
295
+        $this_opt_id = end( $ids );
296
+		$this_opt = (array) $field->options[$this_opt_id];
297
+		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other' ) !== false );
298 298
 
299
-        $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
300
-        $value = isset($this_opt['value']) ? $this_opt['value'] : '';
299
+        $label = isset( $this_opt['label'] ) ? $this_opt['label'] : reset( $this_opt );
300
+        $value = isset( $this_opt['value'] ) ? $this_opt['value'] : '';
301 301
 
302 302
         if ( ! isset( $new_label ) ) {
303 303
             $new_label = $label;
304 304
         }
305 305
 
306
-        if ( isset($new_value) || isset($value) ) {
307
-            $update_value = isset($new_value) ? $new_value : $value;
306
+        if ( isset( $new_value ) || isset( $value ) ) {
307
+            $update_value = isset( $new_value ) ? $new_value : $value;
308 308
         }
309 309
 
310 310
 		if ( $update_value != $new_label && $other_opt === false && $separate_values ) {
311
-			$field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label );
311
+			$field->options[$this_opt_id] = array( 'value' => $update_value, 'label' => $new_label );
312 312
         } else {
313
-			$field->options[ $this_opt_id ] = $orig_update_value;
313
+			$field->options[$this_opt_id] = $orig_update_value;
314 314
         }
315 315
 
316 316
 		FrmField::update( $field->id, array( 'options' => $field->options ) );
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
     }
320 320
 
321 321
     public static function delete_option() {
322
-		FrmAppHelper::permission_check('frm_edit_forms');
322
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
323 323
         check_ajax_referer( 'frm_ajax', 'nonce' );
324 324
 
325 325
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 		$opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' );
329 329
 
330 330
 		$options = $field->options;
331
-        unset( $options[ $opt_key ] );
331
+        unset( $options[$opt_key] );
332 332
         $response = array( 'other' => true );
333 333
 
334 334
         //If the deleted option is an "other" option
@@ -394,9 +394,9 @@  discard block
 block discarded – undo
394 394
 
395 395
         $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
396 396
         $prepop = array();
397
-        FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
397
+        FrmFieldsHelper::get_bulk_prefilled_opts( $prepop );
398 398
 
399
-        $field = FrmField::getOne($field_id);
399
+        $field = FrmField::getOne( $field_id );
400 400
 
401 401
         wp_enqueue_script( 'utils' );
402 402
 		wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' );
@@ -407,33 +407,33 @@  discard block
 block discarded – undo
407 407
     }
408 408
 
409 409
     public static function import_options() {
410
-		FrmAppHelper::permission_check('frm_edit_forms');
410
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
411 411
         check_ajax_referer( 'frm_ajax', 'nonce' );
412 412
 
413
-        if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
413
+        if ( ! is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
414 414
             return;
415 415
         }
416 416
 
417 417
 		$field_id = absint( $_POST['field_id'] );
418
-        $field = FrmField::getOne($field_id);
418
+        $field = FrmField::getOne( $field_id );
419 419
 
420 420
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
421 421
             return;
422 422
         }
423 423
 
424
-        $field = FrmFieldsHelper::setup_edit_vars($field);
425
-        $opts = stripslashes_deep($_POST['opts']);
426
-        $opts = explode("\n", rtrim($opts, "\n"));
424
+        $field = FrmFieldsHelper::setup_edit_vars( $field );
425
+        $opts = stripslashes_deep( $_POST['opts'] );
426
+        $opts = explode( "\n", rtrim( $opts, "\n" ) );
427 427
         if ( $field['separate_value'] ) {
428 428
             foreach ( $opts as $opt_key => $opt ) {
429
-                if ( strpos($opt, '|') !== false ) {
430
-                    $vals = explode('|', $opt);
429
+                if ( strpos( $opt, '|' ) !== false ) {
430
+                    $vals = explode( '|', $opt );
431 431
                     if ( $vals[0] != $vals[1] ) {
432
-                        $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
432
+                        $opts[$opt_key] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
433 433
                     }
434
-                    unset($vals);
434
+                    unset( $vals );
435 435
                 }
436
-                unset($opt_key, $opt);
436
+                unset( $opt_key, $opt );
437 437
             }
438 438
         }
439 439
 
@@ -442,12 +442,12 @@  discard block
 block discarded – undo
442 442
             $other_array = array();
443 443
             foreach ( $field['options'] as $opt_key => $opt ) {
444 444
                 if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
445
-                    $other_array[ $opt_key ] = $opt;
445
+                    $other_array[$opt_key] = $opt;
446 446
                 }
447
-                unset($opt_key, $opt);
447
+                unset( $opt_key, $opt );
448 448
             }
449
-            if ( ! empty($other_array) ) {
450
-                $opts = array_merge( $opts, $other_array);
449
+            if ( ! empty( $other_array ) ) {
450
+                $opts = array_merge( $opts, $other_array );
451 451
             }
452 452
         }
453 453
 
@@ -462,14 +462,14 @@  discard block
 block discarded – undo
462 462
         if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
463 463
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' );
464 464
         } else {
465
-            FrmFieldsHelper::show_single_option($field);
465
+            FrmFieldsHelper::show_single_option( $field );
466 466
         }
467 467
 
468 468
         wp_die();
469 469
     }
470 470
 
471 471
     public static function update_order() {
472
-		FrmAppHelper::permission_check('frm_edit_forms');
472
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
473 473
         check_ajax_referer( 'frm_ajax', 'nonce' );
474 474
 
475 475
 		$fields = FrmAppHelper::get_post_param( 'frm_field_id' );
@@ -486,13 +486,13 @@  discard block
 block discarded – undo
486 486
             'rte'       => 'textarea',
487 487
             'website'   => 'url',
488 488
         );
489
-        if ( isset( $type_switch[ $type ] ) ) {
490
-            $type = $type_switch[ $type ];
489
+        if ( isset( $type_switch[$type] ) ) {
490
+            $type = $type_switch[$type];
491 491
         }
492 492
 
493 493
 		$frm_field_selection = FrmField::field_selection();
494
-        $types = array_keys($frm_field_selection);
495
-        if ( ! in_array($type, $types) && $type != 'captcha' ) {
494
+        $types = array_keys( $frm_field_selection );
495
+        if ( ! in_array( $type, $types ) && $type != 'captcha' ) {
496 496
             $type = 'text';
497 497
         }
498 498
 
@@ -531,19 +531,19 @@  discard block
 block discarded – undo
531 531
 
532 532
     public static function input_html( $field, $echo = true ) {
533 533
         $class = array(); //$field['type'];
534
-        self::add_input_classes($field, $class);
534
+        self::add_input_classes( $field, $class );
535 535
 
536 536
         $add_html = array();
537
-        self::add_html_size($field, $add_html);
538
-        self::add_html_length($field, $add_html);
539
-        self::add_html_placeholder($field, $add_html, $class);
537
+        self::add_html_size( $field, $add_html );
538
+        self::add_html_length( $field, $add_html );
539
+        self::add_html_placeholder( $field, $add_html, $class );
540 540
 		self::add_validation_messages( $field, $add_html );
541 541
 
542
-        $class = apply_filters('frm_field_classes', implode(' ', $class), $field);
542
+        $class = apply_filters( 'frm_field_classes', implode( ' ', $class ), $field );
543 543
 
544 544
 		FrmFormsHelper::add_html_attr( $class, 'class', $add_html );
545 545
 
546
-        self::add_shortcodes_to_html($field, $add_html);
546
+        self::add_shortcodes_to_html( $field, $add_html );
547 547
 
548 548
 		$add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
549 549
 		$add_html = ' ' . implode( ' ', $add_html ) . '  ';
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
     }
557 557
 
558 558
 	private static function add_input_classes( $field, array &$class ) {
559
-        if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
559
+        if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) {
560 560
             $class[] = $field['input_class'];
561 561
         }
562 562
 
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
             $class[] = 'dyn_default_value';
570 570
         }
571 571
 
572
-        if ( isset($field['size']) && $field['size'] > 0 ) {
572
+        if ( isset( $field['size'] ) && $field['size'] > 0 ) {
573 573
             $class[] = 'auto_width';
574 574
         }
575 575
     }
@@ -579,19 +579,19 @@  discard block
 block discarded – undo
579 579
             return;
580 580
         }
581 581
 
582
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
582
+        if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
583 583
             return;
584 584
         }
585 585
 
586
-        if ( is_numeric($field['size']) ) {
586
+        if ( is_numeric( $field['size'] ) ) {
587 587
             $field['size'] .= 'px';
588 588
         }
589 589
 
590
-        $important = apply_filters('frm_use_important_width', 1, $field);
590
+        $important = apply_filters( 'frm_use_important_width', 1, $field );
591 591
         // Note: This inline styling must stay since we cannot realistically set a class for every possible field size
592 592
 		$add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"';
593 593
 
594
-        self::add_html_cols($field, $add_html);
594
+        self::add_html_cols( $field, $add_html );
595 595
     }
596 596
 
597 597
 	private static function add_html_cols( $field, array &$add_html ) {
@@ -608,13 +608,13 @@  discard block
 block discarded – undo
608 608
         );
609 609
 
610 610
         // include "col" for valid html
611
-        $unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
611
+        $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) );
612 612
 
613
-        if ( ! isset( $calc[ $unit ] ) ) {
613
+        if ( ! isset( $calc[$unit] ) ) {
614 614
             return;
615 615
         }
616 616
 
617
-        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
617
+        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[$unit];
618 618
 
619 619
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
620 620
     }
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
             return;
626 626
         }
627 627
 
628
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
628
+        if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
629 629
             // don't load on form builder page
630 630
             return;
631 631
         }
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
 		if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) {
658 658
             // use HMTL5 placeholder with js fallback
659 659
 			$add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"';
660
-            wp_enqueue_script('jquery-placeholder');
660
+            wp_enqueue_script( 'jquery-placeholder' );
661 661
         } else if ( ! $frm_settings->use_html ) {
662 662
 			$val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( '&#039;', "'", esc_attr( $field['default_value'] ) ) ) );
663 663
 			$add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"';
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 			$format = FrmEntryValidate::phone_format( $field );
685 685
 			$format = substr( $format, 2, -2 );
686 686
 			$key = 'pattern';
687
-			$add_html[ $key ] = $key . '="' . esc_attr( $format ) . '"';
687
+			$add_html[$key] = $key . '="' . esc_attr( $format ) . '"';
688 688
 		}
689 689
 	}
690 690
 
@@ -698,15 +698,15 @@  discard block
 block discarded – undo
698 698
                 continue;
699 699
             }
700 700
 
701
-            if ( is_numeric($k) && strpos($v, '=') ) {
701
+            if ( is_numeric( $k ) && strpos( $v, '=' ) ) {
702 702
                 $add_html[] = $v;
703
-            } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
704
-				$add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] );
703
+            } else if ( ! empty( $k ) && isset( $add_html[$k] ) ) {
704
+				$add_html[$k] = str_replace( $k . '="', $k . '="' . $v, $add_html[$k] );
705 705
             } else {
706
-				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
706
+				$add_html[$k] = $k . '="' . esc_attr( $v ) . '"';
707 707
             }
708 708
 
709
-            unset($k, $v);
709
+            unset( $k, $v );
710 710
         }
711 711
     }
712 712
 
@@ -722,8 +722,8 @@  discard block
 block discarded – undo
722 722
     }
723 723
 
724 724
 	public static function check_label( $opt ) {
725
-        if ( is_array($opt) ) {
726
-            $opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
725
+        if ( is_array( $opt ) ) {
726
+            $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
727 727
         }
728 728
 
729 729
         return $opt;
Please login to merge, or discard this patch.
Indentation   +435 added lines, -435 removed lines patch added patch discarded remove patch
@@ -2,59 +2,59 @@  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' );
@@ -62,72 +62,72 @@  discard block
 block discarded – undo
62 62
 
63 63
 		$field = self::include_new_field( $field_type, $form_id, $section_id );
64 64
 
65
-        // this hook will allow for multiple fields to be added at once
66
-        do_action('frm_after_field_created', $field, $form_id);
65
+		// this hook will allow for multiple fields to be added at once
66
+		do_action('frm_after_field_created', $field, $form_id);
67 67
 
68
-        wp_die();
69
-    }
68
+		wp_die();
69
+	}
70 70
 
71
-    /**
72
-     * Set up and create a new field
73
-     *
74
-     * @param string $field_type
75
-     * @param integer $form_id
76
-     * @param int $section_id
77
-     * @return array|bool
78
-     */
71
+	/**
72
+	 * Set up and create a new field
73
+	 *
74
+	 * @param string $field_type
75
+	 * @param integer $form_id
76
+	 * @param int $section_id
77
+	 * @return array|bool
78
+	 */
79 79
 	public static function include_new_field( $field_type, $form_id, $section_id = 0 ) {
80
-        $values = array();
81
-        if ( FrmAppHelper::pro_is_installed() ) {
82
-            $values['post_type'] = FrmProFormsHelper::post_type($form_id);
83
-        }
80
+		$values = array();
81
+		if ( FrmAppHelper::pro_is_installed() ) {
82
+			$values['post_type'] = FrmProFormsHelper::post_type($form_id);
83
+		}
84 84
 
85 85
 		$field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id );
86 86
 		$field_values['field_options']['in_section'] = $section_id;
87
-        $field_values = apply_filters( 'frm_before_field_created', $field_values );
87
+		$field_values = apply_filters( 'frm_before_field_created', $field_values );
88 88
 
89
-        $field_id = FrmField::create( $field_values );
89
+		$field_id = FrmField::create( $field_values );
90 90
 
91
-        if ( ! $field_id ) {
92
-            return false;
93
-        }
91
+		if ( ! $field_id ) {
92
+			return false;
93
+		}
94 94
 
95
-        $field = self::include_single_field($field_id, $values, $form_id);
95
+		$field = self::include_single_field($field_id, $values, $form_id);
96 96
 
97
-        return $field;
98
-    }
97
+		return $field;
98
+	}
99 99
 
100 100
 	public static function edit_name( $field = 'name', $id = '' ) {
101 101
 		FrmAppHelper::permission_check('frm_edit_forms');
102
-        check_ajax_referer( 'frm_ajax', 'nonce' );
102
+		check_ajax_referer( 'frm_ajax', 'nonce' );
103 103
 
104
-        if ( empty($field) ) {
105
-            $field = 'name';
106
-        }
104
+		if ( empty($field) ) {
105
+			$field = 'name';
106
+		}
107 107
 
108
-        if ( empty($id) ) {
108
+		if ( empty($id) ) {
109 109
 			$id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
110 110
 			$id = str_replace( 'field_label_', '', $id );
111
-        }
111
+		}
112 112
 
113 113
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' );
114 114
 		$value = trim( $value );
115
-        if ( trim(strip_tags($value)) == '' ) {
116
-            // set blank value if there is no content
117
-            $value = '';
118
-        }
115
+		if ( trim(strip_tags($value)) == '' ) {
116
+			// set blank value if there is no content
117
+			$value = '';
118
+		}
119 119
 
120 120
 		FrmField::update( $id, array( $field => $value ) );
121 121
 
122 122
 		do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) );
123 123
 
124 124
 		echo stripslashes( wp_kses_post( $value ) );
125
-        wp_die();
126
-    }
125
+		wp_die();
126
+	}
127 127
 
128
-    public static function update_ajax_option() {
128
+	public static function update_ajax_option() {
129 129
 		FrmAppHelper::permission_check('frm_edit_forms');
130
-        check_ajax_referer( 'frm_ajax', 'nonce' );
130
+		check_ajax_referer( 'frm_ajax', 'nonce' );
131 131
 
132 132
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
133 133
 		if ( ! $field_id ) {
@@ -142,141 +142,141 @@  discard block
 block discarded – undo
142 142
 			unset($new_val);
143 143
 		}
144 144
 
145
-        FrmField::update( $field_id, array(
146
-            'field_options' => $field->field_options,
145
+		FrmField::update( $field_id, array(
146
+			'field_options' => $field->field_options,
147 147
 			'form_id'		=> $field->form_id,
148
-        ) );
149
-        wp_die();
150
-    }
148
+		) );
149
+		wp_die();
150
+	}
151 151
 
152
-    public static function duplicate() {
152
+	public static function duplicate() {
153 153
 		FrmAppHelper::permission_check('frm_edit_forms');
154
-        check_ajax_referer( 'frm_ajax', 'nonce' );
154
+		check_ajax_referer( 'frm_ajax', 'nonce' );
155 155
 
156
-        global $wpdb;
156
+		global $wpdb;
157 157
 
158 158
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
159 159
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
160 160
 
161 161
 		$copy_field = FrmField::getOne( $field_id );
162
-        if ( ! $copy_field ) {
163
-            wp_die();
164
-        }
162
+		if ( ! $copy_field ) {
163
+			wp_die();
164
+		}
165 165
 
166 166
 		do_action( 'frm_duplicate_field', $copy_field, $form_id );
167 167
 		do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id );
168 168
 
169
-        $values = array( 'id' => $form_id );
170
-        FrmFieldsHelper::fill_field( $values, $copy_field, $form_id );
169
+		$values = array( 'id' => $form_id );
170
+		FrmFieldsHelper::fill_field( $values, $copy_field, $form_id );
171 171
 
172 172
 		$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 ) );
173 173
 
174
-        $values['field_order'] = $field_count + 1;
174
+		$values['field_order'] = $field_count + 1;
175 175
 
176
-        if ( ! $field_id = FrmField::create($values) ) {
177
-            wp_die();
178
-        }
176
+		if ( ! $field_id = FrmField::create($values) ) {
177
+			wp_die();
178
+		}
179 179
 
180
-        self::include_single_field($field_id, $values);
180
+		self::include_single_field($field_id, $values);
181 181
 
182
-        wp_die();
183
-    }
182
+		wp_die();
183
+	}
184 184
 
185
-    /**
186
-     * Load a single field in the form builder along with all needed variables
187
-     */
188
-    public static function include_single_field( $field_id, $values, $form_id = 0 ) {
189
-        $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
185
+	/**
186
+	 * Load a single field in the form builder along with all needed variables
187
+	 */
188
+	public static function include_single_field( $field_id, $values, $form_id = 0 ) {
189
+		$field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
190 190
 		$field_name = 'item_meta[' . $field_id . ']';
191
-        $html_id = FrmFieldsHelper::get_html_id($field);
192
-        $id = $form_id ? $form_id : $field['form_id'];
193
-        if ( $field['type'] == 'html' ) {
194
-            $field['stop_filter'] = true;
195
-        }
191
+		$html_id = FrmFieldsHelper::get_html_id($field);
192
+		$id = $form_id ? $form_id : $field['form_id'];
193
+		if ( $field['type'] == 'html' ) {
194
+			$field['stop_filter'] = true;
195
+		}
196 196
 
197 197
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' );
198 198
 
199
-        return $field;
200
-    }
199
+		return $field;
200
+	}
201 201
 
202
-    public static function destroy() {
202
+	public static function destroy() {
203 203
 		FrmAppHelper::permission_check('frm_edit_forms');
204
-        check_ajax_referer( 'frm_ajax', 'nonce' );
204
+		check_ajax_referer( 'frm_ajax', 'nonce' );
205 205
 
206 206
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
207 207
 		FrmField::destroy( $field_id );
208
-        wp_die();
209
-    }
208
+		wp_die();
209
+	}
210 210
 
211
-    /* Field Options */
211
+	/* Field Options */
212 212
 
213
-    //Add Single Option or Other Option
214
-    public static function add_option() {
213
+	//Add Single Option or Other Option
214
+	public static function add_option() {
215 215
 		FrmAppHelper::permission_check('frm_edit_forms');
216
-        check_ajax_referer( 'frm_ajax', 'nonce' );
216
+		check_ajax_referer( 'frm_ajax', 'nonce' );
217 217
 
218 218
 		$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
219 219
 		$opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
220 220
 
221
-        //Get the field
222
-        $field = FrmField::getOne($id);
221
+		//Get the field
222
+		$field = FrmField::getOne($id);
223 223
 
224 224
 		if ( ! empty( $field->options ) ) {
225 225
 			$keys = array_keys( $field->options );
226
-            $last = str_replace( 'other_', '', end( $keys ) );
227
-        } else {
228
-            $last = 0;
229
-        }
230
-        $opt_key = $last + 1;
226
+			$last = str_replace( 'other_', '', end( $keys ) );
227
+		} else {
228
+			$last = 0;
229
+		}
230
+		$opt_key = $last + 1;
231 231
 
232
-        if ( 'other' == $opt_type ) {
232
+		if ( 'other' == $opt_type ) {
233 233
 			$opt = esc_html__( 'Other', 'formidable' );
234
-            $other_val = '';
235
-            $opt_key = 'other_' . $opt_key;
236
-
237
-            //Update value of "other" in DB
238
-            $field_options = maybe_unserialize( $field->field_options );
239
-            $field_options['other'] = 1;
240
-            FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) );
241
-        } else {
234
+			$other_val = '';
235
+			$opt_key = 'other_' . $opt_key;
236
+
237
+			//Update value of "other" in DB
238
+			$field_options = maybe_unserialize( $field->field_options );
239
+			$field_options['other'] = 1;
240
+			FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) );
241
+		} else {
242 242
 			$first_opt = reset( $field->options );
243 243
 			$next_opt = count( $field->options );
244
-            if ( $first_opt != '' ) {
245
-                $next_opt++;
246
-            }
244
+			if ( $first_opt != '' ) {
245
+				$next_opt++;
246
+			}
247 247
 			$opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt;
248
-            unset($next_opt);
249
-        }
250
-        $field_val = $opt;
248
+			unset($next_opt);
249
+		}
250
+		$field_val = $opt;
251 251
 		$field->options[ $opt_key ] = $opt;
252 252
 
253
-        //Update options in DB
253
+		//Update options in DB
254 254
 		FrmField::update( $id, array( 'options' => $field->options ) );
255 255
 
256
-        $field_data = $field;
257
-        $field = array(
258
-            'type'  => $field_data->type,
259
-            'id'    => $id,
260
-            'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
261
-            'form_id' => $field_data->form_id,
262
-            'field_key' => $field_data->field_key,
263
-        );
256
+		$field_data = $field;
257
+		$field = array(
258
+			'type'  => $field_data->type,
259
+			'id'    => $id,
260
+			'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
261
+			'form_id' => $field_data->form_id,
262
+			'field_key' => $field_data->field_key,
263
+		);
264 264
 
265 265
 		$field_name = 'item_meta[' . $id . ']';
266
-        $html_id = FrmFieldsHelper::get_html_id($field);
267
-        $checked = '';
266
+		$html_id = FrmFieldsHelper::get_html_id($field);
267
+		$checked = '';
268 268
 
269
-        if ( 'other' == $opt_type ) {
269
+		if ( 'other' == $opt_type ) {
270 270
 			require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' );
271
-        } else {
271
+		} else {
272 272
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
273
-        }
274
-        wp_die();
275
-    }
273
+		}
274
+		wp_die();
275
+	}
276 276
 
277
-    public static function edit_option() {
277
+	public static function edit_option() {
278 278
 		FrmAppHelper::permission_check('frm_edit_forms');
279
-        check_ajax_referer( 'frm_ajax', 'nonce' );
279
+		check_ajax_referer( 'frm_ajax', 'nonce' );
280 280
 
281 281
 		$element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
282 282
 		$ids = explode( '-', $element_id );
@@ -284,43 +284,43 @@  discard block
 block discarded – undo
284 284
 
285 285
 		$orig_update_value = $update_value = trim( FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ) );
286 286
 		if ( strpos( $element_id, 'key_' ) ) {
287
-            $new_value = $update_value;
288
-        } else {
289
-            $new_label = $update_value;
290
-        }
287
+			$new_value = $update_value;
288
+		} else {
289
+			$new_label = $update_value;
290
+		}
291 291
 
292
-        $field = FrmField::getOne($id);
293
-        $separate_values = FrmField::is_option_true( $field, 'separate_value' );
292
+		$field = FrmField::getOne($id);
293
+		$separate_values = FrmField::is_option_true( $field, 'separate_value' );
294 294
 
295
-        $this_opt_id = end($ids);
295
+		$this_opt_id = end($ids);
296 296
 		$this_opt = (array) $field->options[ $this_opt_id ];
297 297
 		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false );
298 298
 
299
-        $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
300
-        $value = isset($this_opt['value']) ? $this_opt['value'] : '';
299
+		$label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
300
+		$value = isset($this_opt['value']) ? $this_opt['value'] : '';
301 301
 
302
-        if ( ! isset( $new_label ) ) {
303
-            $new_label = $label;
304
-        }
302
+		if ( ! isset( $new_label ) ) {
303
+			$new_label = $label;
304
+		}
305 305
 
306
-        if ( isset($new_value) || isset($value) ) {
307
-            $update_value = isset($new_value) ? $new_value : $value;
308
-        }
306
+		if ( isset($new_value) || isset($value) ) {
307
+			$update_value = isset($new_value) ? $new_value : $value;
308
+		}
309 309
 
310 310
 		if ( $update_value != $new_label && $other_opt === false && $separate_values ) {
311 311
 			$field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label );
312
-        } else {
312
+		} else {
313 313
 			$field->options[ $this_opt_id ] = $orig_update_value;
314
-        }
314
+		}
315 315
 
316 316
 		FrmField::update( $field->id, array( 'options' => $field->options ) );
317 317
 		echo ( $orig_update_value == '' ) ? esc_html__( '(Blank)', 'formidable' ) : stripslashes( $orig_update_value );
318
-        wp_die();
319
-    }
318
+		wp_die();
319
+	}
320 320
 
321
-    public static function delete_option() {
321
+	public static function delete_option() {
322 322
 		FrmAppHelper::permission_check('frm_edit_forms');
323
-        check_ajax_referer( 'frm_ajax', 'nonce' );
323
+		check_ajax_referer( 'frm_ajax', 'nonce' );
324 324
 
325 325
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
326 326
 		$field = FrmField::getOne( $field_id );
@@ -328,310 +328,310 @@  discard block
 block discarded – undo
328 328
 		$opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' );
329 329
 
330 330
 		$options = $field->options;
331
-        unset( $options[ $opt_key ] );
332
-        $response = array( 'other' => true );
331
+		unset( $options[ $opt_key ] );
332
+		$response = array( 'other' => true );
333 333
 
334
-        //If the deleted option is an "other" option
334
+		//If the deleted option is an "other" option
335 335
 		if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
336
-            //Assume all other options are gone, unless proven otherwise
337
-            $other = false;
336
+			//Assume all other options are gone, unless proven otherwise
337
+			$other = false;
338 338
 
339
-            //Check if all other options are really gone
340
-            foreach ( $options as $o_key => $o_val ) {
341
-                //If there is still an other option in the field, set other to true
339
+			//Check if all other options are really gone
340
+			foreach ( $options as $o_key => $o_val ) {
341
+				//If there is still an other option in the field, set other to true
342 342
 				if ( FrmFieldsHelper::is_other_opt( $o_key ) ) {
343
-                    $other = true;
344
-                    break;
345
-                }
346
-                unset( $o_key, $o_val );
347
-            }
348
-
349
-            //If all other options are gone
350
-            if ( false === $other ) {
351
-                $field_options = maybe_unserialize( $field->field_options );
352
-                $field_options['other'] = 0;
343
+					$other = true;
344
+					break;
345
+				}
346
+				unset( $o_key, $o_val );
347
+			}
348
+
349
+			//If all other options are gone
350
+			if ( false === $other ) {
351
+				$field_options = maybe_unserialize( $field->field_options );
352
+				$field_options['other'] = 0;
353 353
 				FrmField::update( $field_id, array( 'field_options' => maybe_serialize( $field_options ) ) );
354
-                $response = array( 'other' => false );
355
-            }
356
-        }
357
-        echo json_encode( $response );
354
+				$response = array( 'other' => false );
355
+			}
356
+		}
357
+		echo json_encode( $response );
358 358
 
359 359
 		FrmField::update( $field_id, array( 'options' => maybe_serialize( $options ) ) );
360 360
 
361
-        wp_die();
362
-    }
361
+		wp_die();
362
+	}
363 363
 
364
-    public static function import_choices() {
365
-        FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
364
+	public static function import_choices() {
365
+		FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
366 366
 
367 367
 		$field_id = absint( $_REQUEST['field_id'] );
368 368
 
369
-        global $current_screen, $hook_suffix;
369
+		global $current_screen, $hook_suffix;
370 370
 
371
-        // Catch plugins that include admin-header.php before admin.php completes.
372
-        if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
373
-            $hook_suffix = '';
374
-        	set_current_screen();
375
-        }
371
+		// Catch plugins that include admin-header.php before admin.php completes.
372
+		if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
373
+			$hook_suffix = '';
374
+			set_current_screen();
375
+		}
376 376
 
377
-        if ( function_exists( 'register_admin_color_schemes' ) ) {
378
-            register_admin_color_schemes();
379
-        }
377
+		if ( function_exists( 'register_admin_color_schemes' ) ) {
378
+			register_admin_color_schemes();
379
+		}
380 380
 
381
-        $hook_suffix = $admin_body_class = '';
381
+		$hook_suffix = $admin_body_class = '';
382 382
 
383
-        if ( get_user_setting( 'mfold' ) == 'f' ) {
384
-        	$admin_body_class .= ' folded';
385
-        }
383
+		if ( get_user_setting( 'mfold' ) == 'f' ) {
384
+			$admin_body_class .= ' folded';
385
+		}
386 386
 
387
-        if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
388
-        	$admin_body_class .= ' admin-bar';
389
-        }
387
+		if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
388
+			$admin_body_class .= ' admin-bar';
389
+		}
390 390
 
391
-        if ( is_rtl() ) {
392
-        	$admin_body_class .= ' rtl';
393
-        }
391
+		if ( is_rtl() ) {
392
+			$admin_body_class .= ' rtl';
393
+		}
394 394
 
395
-        $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
396
-        $prepop = array();
397
-        FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
395
+		$admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
396
+		$prepop = array();
397
+		FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
398 398
 
399
-        $field = FrmField::getOne($field_id);
399
+		$field = FrmField::getOne($field_id);
400 400
 
401
-        wp_enqueue_script( 'utils' );
401
+		wp_enqueue_script( 'utils' );
402 402
 		wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' );
403
-        FrmAppHelper::load_admin_wide_js();
403
+		FrmAppHelper::load_admin_wide_js();
404 404
 
405 405
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' );
406
-        wp_die();
407
-    }
406
+		wp_die();
407
+	}
408 408
 
409
-    public static function import_options() {
409
+	public static function import_options() {
410 410
 		FrmAppHelper::permission_check('frm_edit_forms');
411
-        check_ajax_referer( 'frm_ajax', 'nonce' );
411
+		check_ajax_referer( 'frm_ajax', 'nonce' );
412 412
 
413
-        if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
414
-            return;
415
-        }
413
+		if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
414
+			return;
415
+		}
416 416
 
417 417
 		$field_id = absint( $_POST['field_id'] );
418
-        $field = FrmField::getOne($field_id);
418
+		$field = FrmField::getOne($field_id);
419 419
 
420 420
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
421
-            return;
422
-        }
423
-
424
-        $field = FrmFieldsHelper::setup_edit_vars($field);
425
-        $opts = stripslashes_deep($_POST['opts']);
426
-        $opts = explode("\n", rtrim($opts, "\n"));
427
-        if ( $field['separate_value'] ) {
428
-            foreach ( $opts as $opt_key => $opt ) {
429
-                if ( strpos($opt, '|') !== false ) {
430
-                    $vals = explode('|', $opt);
431
-                    if ( $vals[0] != $vals[1] ) {
432
-                        $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
433
-                    }
434
-                    unset($vals);
435
-                }
436
-                unset($opt_key, $opt);
437
-            }
438
-        }
439
-
440
-        //Keep other options after bulk update
441
-        if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
442
-            $other_array = array();
443
-            foreach ( $field['options'] as $opt_key => $opt ) {
444
-                if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
445
-                    $other_array[ $opt_key ] = $opt;
446
-                }
447
-                unset($opt_key, $opt);
448
-            }
449
-            if ( ! empty($other_array) ) {
450
-                $opts = array_merge( $opts, $other_array);
451
-            }
452
-        }
453
-
454
-        FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) );
455
-
456
-        $field['options'] = $opts;
457
-        $field_name = $field['name'];
458
-
459
-        // Get html_id which will be used in single-option.php
460
-        $html_id = FrmFieldsHelper::get_html_id( $field );
461
-
462
-        if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
421
+			return;
422
+		}
423
+
424
+		$field = FrmFieldsHelper::setup_edit_vars($field);
425
+		$opts = stripslashes_deep($_POST['opts']);
426
+		$opts = explode("\n", rtrim($opts, "\n"));
427
+		if ( $field['separate_value'] ) {
428
+			foreach ( $opts as $opt_key => $opt ) {
429
+				if ( strpos($opt, '|') !== false ) {
430
+					$vals = explode('|', $opt);
431
+					if ( $vals[0] != $vals[1] ) {
432
+						$opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
433
+					}
434
+					unset($vals);
435
+				}
436
+				unset($opt_key, $opt);
437
+			}
438
+		}
439
+
440
+		//Keep other options after bulk update
441
+		if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
442
+			$other_array = array();
443
+			foreach ( $field['options'] as $opt_key => $opt ) {
444
+				if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
445
+					$other_array[ $opt_key ] = $opt;
446
+				}
447
+				unset($opt_key, $opt);
448
+			}
449
+			if ( ! empty($other_array) ) {
450
+				$opts = array_merge( $opts, $other_array);
451
+			}
452
+		}
453
+
454
+		FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) );
455
+
456
+		$field['options'] = $opts;
457
+		$field_name = $field['name'];
458
+
459
+		// Get html_id which will be used in single-option.php
460
+		$html_id = FrmFieldsHelper::get_html_id( $field );
461
+
462
+		if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
463 463
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' );
464
-        } else {
465
-            FrmFieldsHelper::show_single_option($field);
466
-        }
464
+		} else {
465
+			FrmFieldsHelper::show_single_option($field);
466
+		}
467 467
 
468
-        wp_die();
469
-    }
468
+		wp_die();
469
+	}
470 470
 
471
-    public static function update_order() {
471
+	public static function update_order() {
472 472
 		FrmAppHelper::permission_check('frm_edit_forms');
473
-        check_ajax_referer( 'frm_ajax', 'nonce' );
473
+		check_ajax_referer( 'frm_ajax', 'nonce' );
474 474
 
475 475
 		$fields = FrmAppHelper::get_post_param( 'frm_field_id' );
476 476
 		foreach ( (array) $fields as $position => $item ) {
477 477
 			FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) );
478 478
 		}
479
-        wp_die();
480
-    }
479
+		wp_die();
480
+	}
481 481
 
482 482
 	public static function change_type( $type ) {
483
-        $type_switch = array(
484
-            'scale'     => 'radio',
485
-            '10radio'   => 'radio',
486
-            'rte'       => 'textarea',
487
-            'website'   => 'url',
488
-        );
489
-        if ( isset( $type_switch[ $type ] ) ) {
490
-            $type = $type_switch[ $type ];
491
-        }
483
+		$type_switch = array(
484
+			'scale'     => 'radio',
485
+			'10radio'   => 'radio',
486
+			'rte'       => 'textarea',
487
+			'website'   => 'url',
488
+		);
489
+		if ( isset( $type_switch[ $type ] ) ) {
490
+			$type = $type_switch[ $type ];
491
+		}
492 492
 
493 493
 		$frm_field_selection = FrmField::field_selection();
494
-        $types = array_keys($frm_field_selection);
495
-        if ( ! in_array($type, $types) && $type != 'captcha' ) {
496
-            $type = 'text';
497
-        }
494
+		$types = array_keys($frm_field_selection);
495
+		if ( ! in_array($type, $types) && $type != 'captcha' ) {
496
+			$type = 'text';
497
+		}
498 498
 
499
-        return $type;
500
-    }
499
+		return $type;
500
+	}
501 501
 
502 502
 	public static function display_field_options( $display ) {
503 503
 		switch ( $display['type'] ) {
504
-            case 'captcha':
505
-                $display['required'] = false;
506
-                $display['invalid'] = true;
507
-                $display['default_blank'] = false;
504
+			case 'captcha':
505
+				$display['required'] = false;
506
+				$display['invalid'] = true;
507
+				$display['default_blank'] = false;
508 508
 				$display['captcha_size'] = true;
509
-            break;
510
-            case 'radio':
511
-                $display['default_blank'] = false;
512
-            break;
513
-            case 'text':
514
-            case 'textarea':
515
-                $display['size'] = true;
516
-                $display['clear_on_focus'] = true;
517
-            break;
518
-            case 'select':
519
-                $display['size'] = true;
520
-            break;
521
-            case 'url':
522
-            case 'website':
523
-            case 'email':
524
-                $display['size'] = true;
525
-                $display['clear_on_focus'] = true;
526
-                $display['invalid'] = true;
527
-        }
528
-
529
-        return $display;
530
-    }
531
-
532
-    public static function input_html( $field, $echo = true ) {
533
-        $class = array(); //$field['type'];
534
-        self::add_input_classes($field, $class);
535
-
536
-        $add_html = array();
537
-        self::add_html_size($field, $add_html);
538
-        self::add_html_length($field, $add_html);
539
-        self::add_html_placeholder($field, $add_html, $class);
509
+			break;
510
+			case 'radio':
511
+				$display['default_blank'] = false;
512
+			break;
513
+			case 'text':
514
+			case 'textarea':
515
+				$display['size'] = true;
516
+				$display['clear_on_focus'] = true;
517
+			break;
518
+			case 'select':
519
+				$display['size'] = true;
520
+			break;
521
+			case 'url':
522
+			case 'website':
523
+			case 'email':
524
+				$display['size'] = true;
525
+				$display['clear_on_focus'] = true;
526
+				$display['invalid'] = true;
527
+		}
528
+
529
+		return $display;
530
+	}
531
+
532
+	public static function input_html( $field, $echo = true ) {
533
+		$class = array(); //$field['type'];
534
+		self::add_input_classes($field, $class);
535
+
536
+		$add_html = array();
537
+		self::add_html_size($field, $add_html);
538
+		self::add_html_length($field, $add_html);
539
+		self::add_html_placeholder($field, $add_html, $class);
540 540
 		self::add_validation_messages( $field, $add_html );
541 541
 
542
-        $class = apply_filters('frm_field_classes', implode(' ', $class), $field);
542
+		$class = apply_filters('frm_field_classes', implode(' ', $class), $field);
543 543
 
544 544
 		FrmFormsHelper::add_html_attr( $class, 'class', $add_html );
545 545
 
546
-        self::add_shortcodes_to_html($field, $add_html);
546
+		self::add_shortcodes_to_html($field, $add_html);
547 547
 
548 548
 		$add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
549 549
 		$add_html = ' ' . implode( ' ', $add_html ) . '  ';
550 550
 
551
-        if ( $echo ) {
552
-            echo $add_html;
553
-        }
551
+		if ( $echo ) {
552
+			echo $add_html;
553
+		}
554 554
 
555
-        return $add_html;
556
-    }
555
+		return $add_html;
556
+	}
557 557
 
558 558
 	private static function add_input_classes( $field, array &$class ) {
559
-        if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
560
-            $class[] = $field['input_class'];
561
-        }
559
+		if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
560
+			$class[] = $field['input_class'];
561
+		}
562 562
 
563
-        if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
564
-            return;
565
-        }
563
+		if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
564
+			return;
565
+		}
566 566
 
567
-        global $frm_vars;
567
+		global $frm_vars;
568 568
 		if ( is_admin() && ! FrmAppHelper::is_preview_page() && ! in_array( $field['type'], array( 'scale', 'radio', 'checkbox', 'data' ) ) ) {
569
-            $class[] = 'dyn_default_value';
570
-        }
569
+			$class[] = 'dyn_default_value';
570
+		}
571 571
 
572
-        if ( isset($field['size']) && $field['size'] > 0 ) {
573
-            $class[] = 'auto_width';
574
-        }
575
-    }
572
+		if ( isset($field['size']) && $field['size'] > 0 ) {
573
+			$class[] = 'auto_width';
574
+		}
575
+	}
576 576
 
577 577
 	private static function add_html_size( $field, array &$add_html ) {
578 578
 		if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden' ) ) ) {
579
-            return;
580
-        }
579
+			return;
580
+		}
581 581
 
582
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
583
-            return;
584
-        }
582
+		if ( FrmAppHelper::is_admin_page('formidable' ) ) {
583
+			return;
584
+		}
585 585
 
586
-        if ( is_numeric($field['size']) ) {
587
-            $field['size'] .= 'px';
588
-        }
586
+		if ( is_numeric($field['size']) ) {
587
+			$field['size'] .= 'px';
588
+		}
589 589
 
590
-        $important = apply_filters('frm_use_important_width', 1, $field);
591
-        // Note: This inline styling must stay since we cannot realistically set a class for every possible field size
590
+		$important = apply_filters('frm_use_important_width', 1, $field);
591
+		// Note: This inline styling must stay since we cannot realistically set a class for every possible field size
592 592
 		$add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"';
593 593
 
594
-        self::add_html_cols($field, $add_html);
595
-    }
594
+		self::add_html_cols($field, $add_html);
595
+	}
596 596
 
597 597
 	private static function add_html_cols( $field, array &$add_html ) {
598 598
 		if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) {
599
-            return;
600
-        }
599
+			return;
600
+		}
601 601
 
602
-        // convert to cols for textareas
603
-        $calc = array(
604
-            ''      => 9,
605
-            'px'    => 9,
606
-            'rem'   => 0.444,
607
-            'em'    => 0.544,
608
-        );
602
+		// convert to cols for textareas
603
+		$calc = array(
604
+			''      => 9,
605
+			'px'    => 9,
606
+			'rem'   => 0.444,
607
+			'em'    => 0.544,
608
+		);
609 609
 
610
-        // include "col" for valid html
611
-        $unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
610
+		// include "col" for valid html
611
+		$unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
612 612
 
613
-        if ( ! isset( $calc[ $unit ] ) ) {
614
-            return;
615
-        }
613
+		if ( ! isset( $calc[ $unit ] ) ) {
614
+			return;
615
+		}
616 616
 
617
-        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
617
+		$size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
618 618
 
619 619
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
620
-    }
620
+	}
621 621
 
622 622
 	private static function add_html_length( $field, array &$add_html ) {
623
-        // check for max setting and if this field accepts maxlength
623
+		// check for max setting and if this field accepts maxlength
624 624
 		if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden' ) ) ) {
625
-            return;
626
-        }
625
+			return;
626
+		}
627 627
 
628
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
629
-            // don't load on form builder page
630
-            return;
631
-        }
628
+		if ( FrmAppHelper::is_admin_page('formidable' ) ) {
629
+			// don't load on form builder page
630
+			return;
631
+		}
632 632
 
633 633
 		$add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"';
634
-    }
634
+	}
635 635
 
636 636
 	private static function add_html_placeholder( $field, array &$add_html, array &$class ) {
637 637
 		if ( empty( $field['default_value'] ) || FrmAppHelper::is_admin_page( 'formidable' ) ) {
@@ -639,35 +639,35 @@  discard block
 block discarded – undo
639 639
 		}
640 640
 
641 641
 		$default_value_array = is_array( $field['default_value'] );
642
-        if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
642
+		if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
643 643
 			if ( $default_value_array ) {
644 644
 				$field['default_value'] = json_encode( $field['default_value'] );
645 645
 			}
646 646
 			$add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"';
647
-            return;
648
-        }
647
+			return;
648
+		}
649 649
 
650 650
 		if ( $default_value_array ) {
651 651
 			// don't include a json placeholder
652 652
 			return;
653 653
 		}
654 654
 
655
-        $frm_settings = FrmAppHelper::get_settings();
655
+		$frm_settings = FrmAppHelper::get_settings();
656 656
 
657 657
 		if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) {
658
-            // use HMTL5 placeholder with js fallback
658
+			// use HMTL5 placeholder with js fallback
659 659
 			$add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"';
660
-            wp_enqueue_script('jquery-placeholder');
661
-        } else if ( ! $frm_settings->use_html ) {
660
+			wp_enqueue_script('jquery-placeholder');
661
+		} else if ( ! $frm_settings->use_html ) {
662 662
 			$val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( '&#039;', "'", esc_attr( $field['default_value'] ) ) ) );
663 663
 			$add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"';
664
-            $class[] = 'frm_toggle_default';
664
+			$class[] = 'frm_toggle_default';
665 665
 
666
-            if ( $field['value'] == $field['default_value'] ) {
667
-                $class[] = 'frm_default';
668
-            }
669
-        }
670
-    }
666
+			if ( $field['value'] == $field['default_value'] ) {
667
+				$class[] = 'frm_default';
668
+			}
669
+		}
670
+	}
671 671
 
672 672
 	private static function add_validation_messages( $field, array &$add_html ) {
673 673
 		if ( FrmField::is_required( $field ) ) {
@@ -688,44 +688,44 @@  discard block
 block discarded – undo
688 688
 		}
689 689
 	}
690 690
 
691
-    private static function add_shortcodes_to_html( $field, array &$add_html ) {
692
-        if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
693
-            return;
694
-        }
691
+	private static function add_shortcodes_to_html( $field, array &$add_html ) {
692
+		if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
693
+			return;
694
+		}
695 695
 
696
-        foreach ( $field['shortcodes'] as $k => $v ) {
697
-            if ( 'opt' === $k ) {
698
-                continue;
699
-            }
696
+		foreach ( $field['shortcodes'] as $k => $v ) {
697
+			if ( 'opt' === $k ) {
698
+				continue;
699
+			}
700 700
 
701
-            if ( is_numeric($k) && strpos($v, '=') ) {
702
-                $add_html[] = $v;
703
-            } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
701
+			if ( is_numeric($k) && strpos($v, '=') ) {
702
+				$add_html[] = $v;
703
+			} else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
704 704
 				$add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] );
705
-            } else {
705
+			} else {
706 706
 				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
707
-            }
708
-
709
-            unset($k, $v);
710
-        }
711
-    }
712
-
713
-    public static function check_value( $opt, $opt_key, $field ) {
714
-        if ( is_array( $opt ) ) {
715
-            if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
716
-                $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
717
-            } else {
718
-                $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
719
-            }
720
-        }
721
-        return $opt;
722
-    }
707
+			}
708
+
709
+			unset($k, $v);
710
+		}
711
+	}
712
+
713
+	public static function check_value( $opt, $opt_key, $field ) {
714
+		if ( is_array( $opt ) ) {
715
+			if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
716
+				$opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
717
+			} else {
718
+				$opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
719
+			}
720
+		}
721
+		return $opt;
722
+	}
723 723
 
724 724
 	public static function check_label( $opt ) {
725
-        if ( is_array($opt) ) {
726
-            $opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
727
-        }
725
+		if ( is_array($opt) ) {
726
+			$opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
727
+		}
728 728
 
729
-        return $opt;
730
-    }
729
+		return $opt;
730
+	}
731 731
 }
Please login to merge, or discard this patch.