Completed
Branch 3.0 (991649)
by Stephanie
02:44
created
classes/helpers/FrmFieldsHelper.php 3 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -117,6 +117,7 @@  discard block
 block discarded – undo
117 117
 
118 118
 	/**
119 119
 	 * @since 3.0
120
+	 * @return string
120 121
 	 */
121 122
 	public static function get_default_field( $type ) {
122 123
 		$field_type = FrmFieldFactory::get_field_type( $type );
@@ -138,6 +139,7 @@  discard block
 block discarded – undo
138 139
 
139 140
     /**
140 141
      * @since 2.0
142
+     * @param string $error
141 143
      */
142 144
 	public static function get_error_msg( $field, $error ) {
143 145
 		$frm_settings = FrmAppHelper::get_settings();
@@ -696,6 +698,9 @@  discard block
 block discarded – undo
696 698
         return $field_types;
697 699
     }
698 700
 
701
+    /**
702
+     * @param string[] $inputs
703
+     */
699 704
     private static function field_types_for_input( $inputs, $fields, &$field_types ) {
700 705
         foreach ( $inputs as $input ) {
701 706
             $field_types[ $input ] = $fields[ $input ];
Please login to merge, or discard this patch.
Indentation   +475 added lines, -475 removed lines patch added patch discarded remove patch
@@ -7,9 +7,9 @@  discard block
 block discarded – undo
7 7
 
8 8
 	public static function setup_new_vars( $type = '', $form_id = '' ) {
9 9
 
10
-        if ( strpos($type, '|') ) {
11
-            list($type, $setting) = explode('|', $type);
12
-        }
10
+		if ( strpos($type, '|') ) {
11
+			list($type, $setting) = explode('|', $type);
12
+		}
13 13
 
14 14
 		$values = self::get_default_field( $type );
15 15
 
@@ -29,17 +29,17 @@  discard block
 block discarded – undo
29 29
 			}
30 30
 		}
31 31
 
32
-        return $values;
33
-    }
32
+		return $values;
33
+	}
34 34
 
35 35
 	public static function get_html_id( $field, $plus = '' ) {
36 36
 		return apply_filters( 'frm_field_html_id', 'field_' . $field['field_key'] . $plus, $field );
37
-    }
37
+	}
38 38
 
39
-    public static function setup_edit_vars( $field, $doing_ajax = false ) {
39
+	public static function setup_edit_vars( $field, $doing_ajax = false ) {
40 40
 		$values = self::field_object_to_array( $field, $doing_ajax );
41 41
 		return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) );
42
-    }
42
+	}
43 43
 
44 44
 	public static function field_object_to_array( $field, $doing_ajax = false ) {
45 45
 		$values = (array) $field;
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		}
85 85
 	}
86 86
 
87
-    public static function get_default_field_opts( $type, $field, $limit = false ) {
87
+	public static function get_default_field_opts( $type, $field, $limit = false ) {
88 88
 		if ( $limit ) {
89 89
 			_deprecated_function( __FUNCTION__, '3.0', 'FrmFieldHelper::get_default_field_options' );
90 90
 			$field_options = self::get_default_field_options( $type );
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 		}
95 95
 
96 96
 		return $field_options;
97
-    }
97
+	}
98 98
 
99 99
 	/**
100 100
 	 * @since 3.0
@@ -123,22 +123,22 @@  discard block
 block discarded – undo
123 123
 		return $field_type->get_new_field_defaults();
124 124
 	}
125 125
 
126
-    public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
127
-        global $wpdb;
126
+	public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
127
+		global $wpdb;
128 128
 
129 129
 		$values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' );
130
-        $values['form_id'] = $form_id;
131
-        $values['options'] = maybe_serialize($field->options);
132
-        $values['default_value'] = maybe_serialize($field->default_value);
133
-
134
-        foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
135
-            $values[ $col ] = $field->{$col};
136
-        }
137
-    }
138
-
139
-    /**
140
-     * @since 2.0
141
-     */
130
+		$values['form_id'] = $form_id;
131
+		$values['options'] = maybe_serialize($field->options);
132
+		$values['default_value'] = maybe_serialize($field->default_value);
133
+
134
+		foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
135
+			$values[ $col ] = $field->{$col};
136
+		}
137
+	}
138
+
139
+	/**
140
+	 * @since 2.0
141
+	 */
142 142
 	public static function get_error_msg( $field, $error ) {
143 143
 		$frm_settings = FrmAppHelper::get_settings();
144 144
 		$default_settings = $frm_settings->default_options();
@@ -243,8 +243,8 @@  discard block
 block discarded – undo
243 243
 
244 244
 	public static function get_shortcode_tag( $shortcodes, $short_key, $args ) {
245 245
 		_deprecated_function( __FUNCTION__, '3.0', 'FrmShortcodesHelper::get_shortcode_tag' );
246
-        return FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key, $args );
247
-    }
246
+		return FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key, $args );
247
+	}
248 248
 
249 249
 	public static function get_checkbox_id( $field, $opt_key ) {
250 250
 		$id = $field['id'];
@@ -256,37 +256,37 @@  discard block
 block discarded – undo
256 256
 
257 257
 	public static function display_recaptcha( $field ) {
258 258
 		_deprecated_function( __FUNCTION__, '3.0', 'FrmFieldCaptcha::field_input' );
259
-    }
259
+	}
260 260
 
261 261
 	public static function show_single_option( $field ) {
262 262
 		if ( ! is_array( $field['options'] ) ) {
263 263
 			return;
264 264
 		}
265 265
 
266
-        $field_name = $field['name'];
267
-        $html_id = self::get_html_id($field);
266
+		$field_name = $field['name'];
267
+		$html_id = self::get_html_id($field);
268 268
 
269 269
 		foreach ( $field['options'] as $opt_key => $opt ) {
270
-		    $field_val = self::get_value_from_array( $opt, $opt_key, $field );
271
-		    $opt = self::get_label_from_array( $opt, $opt_key, $field );
270
+			$field_val = self::get_value_from_array( $opt, $opt_key, $field );
271
+			$opt = self::get_label_from_array( $opt, $opt_key, $field );
272 272
 
273 273
 			// Get string for Other text field, if needed
274 274
 			$other_val = self::get_other_val( compact( 'opt_key', 'field' ) );
275 275
 
276 276
 			$checked = ( $other_val || isset( $field['value'] ) && ( ( ! is_array( $field['value'] ) && $field['value'] == $field_val ) || ( is_array($field['value'] ) && in_array( $field_val, $field['value'] ) ) ) ) ? ' checked="checked"':'';
277 277
 
278
-		    // If this is an "Other" option, get the HTML for it
278
+			// If this is an "Other" option, get the HTML for it
279 279
 			if ( self::is_other_opt( $opt_key ) ) {
280 280
 				if ( FrmAppHelper::pro_is_installed() ) {
281 281
 					require( FrmProAppHelper::plugin_path() . '/classes/views/frmpro-fields/other-option.php' );
282 282
 				}
283
-		    } else {
283
+			} else {
284 284
 				require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
285
-		    }
285
+			}
286 286
 
287 287
 			unset( $checked, $other_val );
288 288
 		}
289
-    }
289
+	}
290 290
 
291 291
 	public static function get_value_from_array( $opt, $opt_key, $field ) {
292 292
 		$opt = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
@@ -299,47 +299,47 @@  discard block
 block discarded – undo
299 299
 	}
300 300
 
301 301
 	public static function get_term_link( $tax_id ) {
302
-        $tax = get_taxonomy($tax_id);
303
-        if ( ! $tax ) {
304
-            return;
305
-        }
302
+		$tax = get_taxonomy($tax_id);
303
+		if ( ! $tax ) {
304
+			return;
305
+		}
306 306
 
307
-        $link = sprintf(
308
-            __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
307
+		$link = sprintf(
308
+			__( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
309 309
 			'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
310
-        );
311
-        unset($tax);
310
+		);
311
+		unset($tax);
312 312
 
313
-        return $link;
314
-    }
313
+		return $link;
314
+	}
315 315
 
316 316
 	public static function value_meets_condition( $observed_value, $cond, $hide_opt ) {
317 317
 		$hide_opt = self::get_value_for_comparision( $hide_opt );
318 318
 		$observed_value = self::get_value_for_comparision( $observed_value );
319 319
 
320
-        if ( is_array($observed_value) ) {
321
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
322
-        }
323
-
324
-        $m = false;
325
-        if ( $cond == '==' ) {
326
-            $m = $observed_value == $hide_opt;
327
-        } else if ( $cond == '!=' ) {
328
-            $m = $observed_value != $hide_opt;
329
-        } else if ( $cond == '>' ) {
330
-            $m = $observed_value > $hide_opt;
331
-        } else if ( $cond == '<' ) {
332
-            $m = $observed_value < $hide_opt;
333
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
334
-            $m = stripos($observed_value, $hide_opt);
335
-            if ( $cond == 'not LIKE' ) {
336
-                $m = ( $m === false ) ? true : false;
337
-            } else {
338
-                $m = ( $m === false ) ? false : true;
339
-            }
340
-        }
341
-        return $m;
342
-    }
320
+		if ( is_array($observed_value) ) {
321
+			return self::array_value_condition($observed_value, $cond, $hide_opt);
322
+		}
323
+
324
+		$m = false;
325
+		if ( $cond == '==' ) {
326
+			$m = $observed_value == $hide_opt;
327
+		} else if ( $cond == '!=' ) {
328
+			$m = $observed_value != $hide_opt;
329
+		} else if ( $cond == '>' ) {
330
+			$m = $observed_value > $hide_opt;
331
+		} else if ( $cond == '<' ) {
332
+			$m = $observed_value < $hide_opt;
333
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
334
+			$m = stripos($observed_value, $hide_opt);
335
+			if ( $cond == 'not LIKE' ) {
336
+				$m = ( $m === false ) ? true : false;
337
+			} else {
338
+				$m = ( $m === false ) ? false : true;
339
+			}
340
+		}
341
+		return $m;
342
+	}
343 343
 
344 344
 	/**
345 345
 	 * Trim and sanitize the values
@@ -355,174 +355,174 @@  discard block
 block discarded – undo
355 355
 	}
356 356
 
357 357
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
358
-        $m = false;
359
-        if ( $cond == '==' ) {
360
-            if ( is_array($hide_opt) ) {
361
-                $m = array_intersect($hide_opt, $observed_value);
362
-                $m = empty($m) ? false : true;
363
-            } else {
364
-                $m = in_array($hide_opt, $observed_value);
365
-            }
366
-        } else if ( $cond == '!=' ) {
367
-            $m = ! in_array($hide_opt, $observed_value);
368
-        } else if ( $cond == '>' ) {
369
-            $min = min($observed_value);
370
-            $m = $min > $hide_opt;
371
-        } else if ( $cond == '<' ) {
372
-            $max = max($observed_value);
373
-            $m = $max < $hide_opt;
374
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
375
-            foreach ( $observed_value as $ob ) {
376
-                $m = strpos($ob, $hide_opt);
377
-                if ( $m !== false ) {
378
-                    $m = true;
379
-                    break;
380
-                }
381
-            }
382
-
383
-            if ( $cond == 'not LIKE' ) {
384
-                $m = ( $m === false ) ? true : false;
385
-            }
386
-        }
387
-
388
-        return $m;
389
-    }
390
-
391
-    /**
392
-     * Replace a few basic shortcodes and field ids
393
-     * @since 2.0
394
-     * @return string
395
-     */
358
+		$m = false;
359
+		if ( $cond == '==' ) {
360
+			if ( is_array($hide_opt) ) {
361
+				$m = array_intersect($hide_opt, $observed_value);
362
+				$m = empty($m) ? false : true;
363
+			} else {
364
+				$m = in_array($hide_opt, $observed_value);
365
+			}
366
+		} else if ( $cond == '!=' ) {
367
+			$m = ! in_array($hide_opt, $observed_value);
368
+		} else if ( $cond == '>' ) {
369
+			$min = min($observed_value);
370
+			$m = $min > $hide_opt;
371
+		} else if ( $cond == '<' ) {
372
+			$max = max($observed_value);
373
+			$m = $max < $hide_opt;
374
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
375
+			foreach ( $observed_value as $ob ) {
376
+				$m = strpos($ob, $hide_opt);
377
+				if ( $m !== false ) {
378
+					$m = true;
379
+					break;
380
+				}
381
+			}
382
+
383
+			if ( $cond == 'not LIKE' ) {
384
+				$m = ( $m === false ) ? true : false;
385
+			}
386
+		}
387
+
388
+		return $m;
389
+	}
390
+
391
+	/**
392
+	 * Replace a few basic shortcodes and field ids
393
+	 * @since 2.0
394
+	 * @return string
395
+	 */
396 396
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
397
-        if ( strpos($value, '[sitename]') !== false ) {
398
-            $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
399
-            $value = str_replace('[sitename]', $new_value, $value);
400
-        }
397
+		if ( strpos($value, '[sitename]') !== false ) {
398
+			$new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
399
+			$value = str_replace('[sitename]', $new_value, $value);
400
+		}
401 401
 
402
-        $value = apply_filters('frm_content', $value, $form, $entry);
403
-        $value = do_shortcode($value);
402
+		$value = apply_filters('frm_content', $value, $form, $entry);
403
+		$value = do_shortcode($value);
404 404
 
405
-        return $value;
406
-    }
405
+		return $value;
406
+	}
407 407
 
408 408
 	public static function get_shortcodes( $content, $form_id ) {
409
-        if ( FrmAppHelper::pro_is_installed() ) {
410
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
411
-        }
409
+		if ( FrmAppHelper::pro_is_installed() ) {
410
+			return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
411
+		}
412 412
 
413
-        $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
413
+		$fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
414 414
 
415
-        $tagregexp = self::allowed_shortcodes($fields);
415
+		$tagregexp = self::allowed_shortcodes($fields);
416 416
 
417
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
417
+		preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
418 418
 
419
-        return $matches;
420
-    }
419
+		return $matches;
420
+	}
421 421
 
422 422
 	public static function allowed_shortcodes( $fields = array() ) {
423
-        $tagregexp = array(
424
-            'editlink', 'id', 'key', 'ip',
425
-            'siteurl', 'sitename', 'admin_email',
426
-            'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by',
423
+		$tagregexp = array(
424
+			'editlink', 'id', 'key', 'ip',
425
+			'siteurl', 'sitename', 'admin_email',
426
+			'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by',
427 427
 			'parent[-|_]id',
428
-        );
428
+		);
429 429
 
430
-        foreach ( $fields as $field ) {
431
-            $tagregexp[] = $field->id;
432
-            $tagregexp[] = $field->field_key;
433
-        }
430
+		foreach ( $fields as $field ) {
431
+			$tagregexp[] = $field->id;
432
+			$tagregexp[] = $field->field_key;
433
+		}
434 434
 
435
-        $tagregexp = implode('|', $tagregexp);
436
-        return $tagregexp;
437
-    }
435
+		$tagregexp = implode('|', $tagregexp);
436
+		return $tagregexp;
437
+	}
438 438
 
439 439
 	public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
440
-        $shortcode_values = array(
441
-           'id'     => $entry->id,
442
-           'key'    => $entry->item_key,
443
-           'ip'     => $entry->ip,
444
-        );
440
+		$shortcode_values = array(
441
+		   'id'     => $entry->id,
442
+		   'key'    => $entry->item_key,
443
+		   'ip'     => $entry->ip,
444
+		);
445 445
 
446
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
446
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
447 447
 			if ( empty( $tag ) ) {
448 448
 				continue;
449 449
 			}
450 450
 
451
-            $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] );
451
+			$atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] );
452 452
 
453
-            if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
453
+			if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
454 454
 				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] );
455
-                $tags = explode(' ', $tag);
456
-                if ( is_array($tags) ) {
457
-                    $tag = $tags[0];
458
-                }
459
-            } else {
460
-                $tag = $shortcodes[2][ $short_key ];
461
-            }
462
-
463
-            switch ( $tag ) {
464
-                case 'id':
465
-                case 'key':
466
-                case 'ip':
467
-                    $replace_with = $shortcode_values[ $tag ];
468
-                break;
469
-
470
-                case 'user_agent':
471
-                case 'user-agent':
472
-                    $entry->description = maybe_unserialize($entry->description);
455
+				$tags = explode(' ', $tag);
456
+				if ( is_array($tags) ) {
457
+					$tag = $tags[0];
458
+				}
459
+			} else {
460
+				$tag = $shortcodes[2][ $short_key ];
461
+			}
462
+
463
+			switch ( $tag ) {
464
+				case 'id':
465
+				case 'key':
466
+				case 'ip':
467
+					$replace_with = $shortcode_values[ $tag ];
468
+				break;
469
+
470
+				case 'user_agent':
471
+				case 'user-agent':
472
+					$entry->description = maybe_unserialize($entry->description);
473 473
 					$replace_with = FrmEntriesHelper::get_browser( $entry->description['browser'] );
474
-                break;
475
-
476
-                case 'created_at':
477
-                case 'created-at':
478
-                case 'updated_at':
479
-                case 'updated-at':
480
-                    if ( isset($atts['format']) ) {
481
-                        $time_format = ' ';
482
-                    } else {
483
-                        $atts['format'] = get_option('date_format');
484
-                        $time_format = '';
485
-                    }
486
-
487
-                    $this_tag = str_replace('-', '_', $tag);
488
-                    $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
489
-                    unset($this_tag);
490
-                break;
491
-
492
-                case 'created_by':
493
-                case 'created-by':
494
-                case 'updated_by':
495
-                case 'updated-by':
496
-                    $this_tag = str_replace('-', '_', $tag);
474
+				break;
475
+
476
+				case 'created_at':
477
+				case 'created-at':
478
+				case 'updated_at':
479
+				case 'updated-at':
480
+					if ( isset($atts['format']) ) {
481
+						$time_format = ' ';
482
+					} else {
483
+						$atts['format'] = get_option('date_format');
484
+						$time_format = '';
485
+					}
486
+
487
+					$this_tag = str_replace('-', '_', $tag);
488
+					$replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
489
+					unset($this_tag);
490
+				break;
491
+
492
+				case 'created_by':
493
+				case 'created-by':
494
+				case 'updated_by':
495
+				case 'updated-by':
496
+					$this_tag = str_replace('-', '_', $tag);
497 497
 					$replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts );
498
-                    unset($this_tag);
499
-                break;
500
-
501
-                case 'admin_email':
502
-                case 'siteurl':
503
-                case 'frmurl':
504
-                case 'sitename':
505
-                case 'get':
506
-                    $replace_with = self::dynamic_default_values( $tag, $atts );
507
-                break;
508
-
509
-                default:
510
-                    $field = FrmField::getOne( $tag );
511
-                    if ( ! $field ) {
512
-                        break;
513
-                    }
514
-
515
-                    $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
516
-
517
-                    $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
518
-
519
-                    $atts['entry_id'] = $entry->id;
520
-                    $atts['entry_key'] = $entry->item_key;
521
-
522
-                    if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
523
-                        $replace_with = $field->name;
524
-                    } else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
525
-                        $replace_with = $field->description;
498
+					unset($this_tag);
499
+				break;
500
+
501
+				case 'admin_email':
502
+				case 'siteurl':
503
+				case 'frmurl':
504
+				case 'sitename':
505
+				case 'get':
506
+					$replace_with = self::dynamic_default_values( $tag, $atts );
507
+				break;
508
+
509
+				default:
510
+					$field = FrmField::getOne( $tag );
511
+					if ( ! $field ) {
512
+						break;
513
+					}
514
+
515
+					$sep = isset($atts['sep']) ? $atts['sep'] : ', ';
516
+
517
+					$replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
518
+
519
+					$atts['entry_id'] = $entry->id;
520
+					$atts['entry_key'] = $entry->item_key;
521
+
522
+					if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
523
+						$replace_with = $field->name;
524
+					} else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
525
+						$replace_with = $field->description;
526 526
 					} else {
527 527
 						$string_value = $replace_with;
528 528
 						if ( is_array( $replace_with ) ) {
@@ -536,82 +536,82 @@  discard block
 block discarded – undo
536 536
 						}
537 537
 					}
538 538
 
539
-                    unset($field);
540
-                break;
541
-            }
539
+					unset($field);
540
+				break;
541
+			}
542 542
 
543
-            if ( isset($replace_with) ) {
544
-                $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
545
-            }
543
+			if ( isset($replace_with) ) {
544
+				$content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
545
+			}
546 546
 
547
-            unset($atts, $conditional, $replace_with);
547
+			unset($atts, $conditional, $replace_with);
548 548
 		}
549 549
 
550 550
 		return $content;
551
-    }
552
-
553
-    /**
554
-     * Get the value to replace a few standard shortcodes
555
-     *
556
-     * @since 2.0
557
-     * @return string
558
-     */
559
-    public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
560
-        $new_value = '';
561
-        switch ( $tag ) {
562
-            case 'admin_email':
563
-                $new_value = get_option('admin_email');
564
-                break;
565
-            case 'siteurl':
566
-                $new_value = FrmAppHelper::site_url();
567
-                break;
568
-            case 'frmurl':
569
-                $new_value = FrmAppHelper::plugin_url();
570
-                break;
571
-            case 'sitename':
572
-                $new_value = FrmAppHelper::site_name();
573
-                break;
574
-            case 'get':
575
-                $new_value = self::process_get_shortcode( $atts, $return_array );
576
-                break;
577
-        }
578
-
579
-        return $new_value;
580
-    }
581
-
582
-    /**
583
-     * Process the [get] shortcode
584
-     *
585
-     * @since 2.0
586
-     * @return string|array
587
-     */
588
-    public static function process_get_shortcode( $atts, $return_array = false ) {
589
-        if ( ! isset($atts['param']) ) {
590
-            return '';
591
-        }
592
-
593
-        if ( strpos($atts['param'], '&#91;') ) {
594
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
595
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
596
-        }
597
-
598
-        $new_value = FrmAppHelper::get_param($atts['param'], '');
599
-        $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
600
-
601
-        if ( $new_value == '' ) {
602
-            if ( ! isset($atts['prev_val']) ) {
603
-                $atts['prev_val'] = '';
604
-            }
605
-
606
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
607
-        }
608
-
609
-        if ( is_array($new_value) && ! $return_array ) {
610
-            $new_value = implode(', ', $new_value);
611
-        }
612
-
613
-        return $new_value;
614
-    }
551
+	}
552
+
553
+	/**
554
+	 * Get the value to replace a few standard shortcodes
555
+	 *
556
+	 * @since 2.0
557
+	 * @return string
558
+	 */
559
+	public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
560
+		$new_value = '';
561
+		switch ( $tag ) {
562
+			case 'admin_email':
563
+				$new_value = get_option('admin_email');
564
+				break;
565
+			case 'siteurl':
566
+				$new_value = FrmAppHelper::site_url();
567
+				break;
568
+			case 'frmurl':
569
+				$new_value = FrmAppHelper::plugin_url();
570
+				break;
571
+			case 'sitename':
572
+				$new_value = FrmAppHelper::site_name();
573
+				break;
574
+			case 'get':
575
+				$new_value = self::process_get_shortcode( $atts, $return_array );
576
+				break;
577
+		}
578
+
579
+		return $new_value;
580
+	}
581
+
582
+	/**
583
+	 * Process the [get] shortcode
584
+	 *
585
+	 * @since 2.0
586
+	 * @return string|array
587
+	 */
588
+	public static function process_get_shortcode( $atts, $return_array = false ) {
589
+		if ( ! isset($atts['param']) ) {
590
+			return '';
591
+		}
592
+
593
+		if ( strpos($atts['param'], '&#91;') ) {
594
+			$atts['param'] = str_replace('&#91;', '[', $atts['param']);
595
+			$atts['param'] = str_replace('&#93;', ']', $atts['param']);
596
+		}
597
+
598
+		$new_value = FrmAppHelper::get_param($atts['param'], '');
599
+		$new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
600
+
601
+		if ( $new_value == '' ) {
602
+			if ( ! isset($atts['prev_val']) ) {
603
+				$atts['prev_val'] = '';
604
+			}
605
+
606
+			$new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
607
+		}
608
+
609
+		if ( is_array($new_value) && ! $return_array ) {
610
+			$new_value = implode(', ', $new_value);
611
+		}
612
+
613
+		return $new_value;
614
+	}
615 615
 
616 616
 	public static function get_display_value( $value, $field, $atts = array() ) {
617 617
 
@@ -671,37 +671,37 @@  discard block
 block discarded – undo
671 671
 	}
672 672
 
673 673
 	public static function get_field_types( $type ) {
674
-        $single_input = array(
675
-            'text', 'textarea', 'rte', 'number', 'email', 'url',
676
-            'image', 'file', 'date', 'phone', 'hidden', 'time',
677
-            'user_id', 'tag', 'password',
678
-        );
674
+		$single_input = array(
675
+			'text', 'textarea', 'rte', 'number', 'email', 'url',
676
+			'image', 'file', 'date', 'phone', 'hidden', 'time',
677
+			'user_id', 'tag', 'password',
678
+		);
679 679
 		$multiple_input = array( 'radio', 'checkbox', 'select', 'scale', 'lookup' );
680 680
 		$other_type = array( 'html', 'break' );
681 681
 
682 682
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
683 683
 
684
-        $field_types = array();
685
-        if ( in_array($type, $single_input) ) {
686
-            self::field_types_for_input( $single_input, $field_selection, $field_types );
687
-        } else if ( in_array($type, $multiple_input) ) {
688
-            self::field_types_for_input( $multiple_input, $field_selection, $field_types );
689
-        } else if ( in_array($type, $other_type) ) {
690
-            self::field_types_for_input( $other_type, $field_selection, $field_types );
684
+		$field_types = array();
685
+		if ( in_array($type, $single_input) ) {
686
+			self::field_types_for_input( $single_input, $field_selection, $field_types );
687
+		} else if ( in_array($type, $multiple_input) ) {
688
+			self::field_types_for_input( $multiple_input, $field_selection, $field_types );
689
+		} else if ( in_array($type, $other_type) ) {
690
+			self::field_types_for_input( $other_type, $field_selection, $field_types );
691 691
 		} else if ( isset( $field_selection[ $type ] ) ) {
692
-            $field_types[ $type ] = $field_selection[ $type ];
693
-        }
692
+			$field_types[ $type ] = $field_selection[ $type ];
693
+		}
694 694
 
695 695
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
696
-        return $field_types;
697
-    }
696
+		return $field_types;
697
+	}
698 698
 
699
-    private static function field_types_for_input( $inputs, $fields, &$field_types ) {
700
-        foreach ( $inputs as $input ) {
701
-            $field_types[ $input ] = $fields[ $input ];
702
-            unset($input);
703
-        }
704
-    }
699
+	private static function field_types_for_input( $inputs, $fields, &$field_types ) {
700
+		foreach ( $inputs as $input ) {
701
+			$field_types[ $input ] = $fields[ $input ];
702
+			unset($input);
703
+		}
704
+	}
705 705
 
706 706
 	/**
707 707
 	 * Check if current field option is an "other" option
@@ -715,14 +715,14 @@  discard block
 block discarded – undo
715 715
 		return $opt_key && strpos( $opt_key, 'other_' ) === 0;
716 716
 	}
717 717
 
718
-    /**
719
-    * Get value that belongs in "Other" text box
720
-    *
721
-    * @since 2.0.6
722
-    *
723
-    * @param array $args
724
-    */
725
-    public static function get_other_val( $args ) {
718
+	/**
719
+	 * Get value that belongs in "Other" text box
720
+	 *
721
+	 * @since 2.0.6
722
+	 *
723
+	 * @param array $args
724
+	 */
725
+	public static function get_other_val( $args ) {
726 726
 		$defaults = array(
727 727
 			'opt_key' => 0, 'field' => array(),
728 728
 			'parent' => false, 'pointer' => false,
@@ -798,20 +798,20 @@  discard block
 block discarded – undo
798 798
 		}
799 799
 
800 800
 		return $other_val;
801
-    }
802
-
803
-    /**
804
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
805
-    * Intended for front-end use
806
-    *
807
-    * @since 2.0.6
808
-    *
809
-    * @param array $args should include field, opt_key and field name
810
-    * @param boolean $other_opt
811
-    * @param string $checked
812
-    * @return string $other_val
813
-    */
814
-    public static function prepare_other_input( $args, &$other_opt, &$checked ) {
801
+	}
802
+
803
+	/**
804
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
805
+	 * Intended for front-end use
806
+	 *
807
+	 * @since 2.0.6
808
+	 *
809
+	 * @param array $args should include field, opt_key and field name
810
+	 * @param boolean $other_opt
811
+	 * @param string $checked
812
+	 * @return string $other_val
813
+	 */
814
+	public static function prepare_other_input( $args, &$other_opt, &$checked ) {
815 815
 		//Check if this is an "Other" option
816 816
 		if ( ! self::is_other_opt( $args['opt_key'] ) ) {
817 817
 			return;
@@ -827,8 +827,8 @@  discard block
 block discarded – undo
827 827
 			$checked = 'checked="checked" ';
828 828
 		}
829 829
 
830
-        return $other_args;
831
-    }
830
+		return $other_args;
831
+	}
832 832
 
833 833
 	/**
834 834
 	 * @param array $args
@@ -878,8 +878,8 @@  discard block
 block discarded – undo
878 878
 	 * @since 2.0.6
879 879
 	 */
880 880
 	public static function include_other_input( $args ) {
881
-        if ( ! $args['other_opt'] ) {
882
-        	return;
881
+		if ( ! $args['other_opt'] ) {
882
+			return;
883 883
 		}
884 884
 
885 885
 		$classes = array( 'frm_other_input' );
@@ -900,15 +900,15 @@  discard block
 block discarded – undo
900 900
 	}
901 901
 
902 902
 	/**
903
-	* Get the HTML id for an "Other" text field
904
-	* Note: This does not affect fields in repeating sections
905
-	*
906
-	* @since 2.0.08
907
-	* @param string $type - field type
908
-	* @param string $html_id
909
-	* @param string|boolean $opt_key
910
-	* @return string $other_id
911
-	*/
903
+	 * Get the HTML id for an "Other" text field
904
+	 * Note: This does not affect fields in repeating sections
905
+	 *
906
+	 * @since 2.0.08
907
+	 * @param string $type - field type
908
+	 * @param string $html_id
909
+	 * @param string|boolean $opt_key
910
+	 * @return string $other_id
911
+	 */
912 912
 	public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) {
913 913
 		$other_id = $html_id;
914 914
 
@@ -966,10 +966,10 @@  discard block
 block discarded – undo
966 966
 	}
967 967
 
968 968
 	public static function switch_field_ids( $val ) {
969
-        global $frm_duplicate_ids;
970
-        $replace = array();
971
-        $replace_with = array();
972
-        foreach ( (array) $frm_duplicate_ids as $old => $new ) {
969
+		global $frm_duplicate_ids;
970
+		$replace = array();
971
+		$replace_with = array();
972
+		foreach ( (array) $frm_duplicate_ids as $old => $new ) {
973 973
 			$replace[] = '[if ' . $old . ']';
974 974
 			$replace_with[] = '[if ' . $new . ']';
975 975
 			$replace[] = '[if ' . $old . ' ';
@@ -984,153 +984,153 @@  discard block
 block discarded – undo
984 984
 			$replace_with[] = '[' . $new . ']';
985 985
 			$replace[] = '[' . $old . ' ';
986 986
 			$replace_with[] = '[' . $new . ' ';
987
-            unset($old, $new);
988
-        }
987
+			unset($old, $new);
988
+		}
989 989
 		if ( is_array( $val ) ) {
990 990
 			foreach ( $val as $k => $v ) {
991
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
992
-                unset($k, $v);
993
-            }
994
-        } else {
995
-            $val = str_replace($replace, $replace_with, $val);
996
-        }
997
-
998
-        return $val;
999
-    }
1000
-
1001
-    public static function get_us_states() {
1002
-        return apply_filters( 'frm_us_states', array(
1003
-            'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona',
1004
-            'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware',
1005
-            'DC' => 'District of Columbia',
1006
-            'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1007
-            'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1008
-            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1009
-            'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1010
-            'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1011
-            'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
1012
-            'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma',
1013
-            'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina',
1014
-            'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah',
1015
-            'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia',
1016
-            'WI' => 'Wisconsin', 'WY' => 'Wyoming',
1017
-        ) );
1018
-    }
1019
-
1020
-    public static function get_countries() {
1021
-        return apply_filters( 'frm_countries', array(
1022
-            __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ),
1023
-            __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ),
1024
-            __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ),
1025
-            __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ),
1026
-            __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ),
1027
-            __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ),
1028
-            __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ),
1029
-            __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ),
1030
-            __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ),
1031
-            __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ),
1032
-            __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ),
1033
-            __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ),
1034
-            __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ),
1035
-            __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ),
1036
-            __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ),
1037
-            __( 'Costa Rica', 'formidable' ), __( 'C&ocirc;te d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ),
1038
-            __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ),
1039
-            __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ),
1040
-            __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ),
1041
-            __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ),
1042
-            __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ),
1043
-            __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ),
1044
-            __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ),
1045
-            __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ),
1046
-            __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ),
1047
-            __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ),
1048
-            __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ),
1049
-            __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ),
1050
-            __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ),
1051
-            __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ),
1052
-            __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ),
1053
-            __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ),
1054
-            __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ),
1055
-            __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ),
1056
-            __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ),
1057
-            __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ),
1058
-            __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ),
1059
-            __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ),
1060
-            __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ),
1061
-            __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ),
1062
-            __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ),
1063
-            __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ),
1064
-            __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ),
1065
-            __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ),
1066
-            __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ),
1067
-            __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ),
1068
-            __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ),
1069
-            __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ),
1070
-            __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ),
1071
-            __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ),
1072
-            __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ),
1073
-            __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ),
1074
-            __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ),
1075
-            __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ),
1076
-            __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ),
1077
-            __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ),
1078
-            __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ),
1079
-            __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ),
1080
-            __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ),
1081
-            __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ),
1082
-            __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ),
1083
-            __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ),
1084
-            __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ),
1085
-            __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ),
1086
-            __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ),
1087
-            __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ),
1088
-            __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ),
1089
-            __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ),
1090
-            __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ),
1091
-            __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ),
1092
-            __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ),
1093
-            __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ),
1094
-            __( 'Zimbabwe', 'formidable' ),
1095
-        ) );
1096
-    }
991
+				$val[ $k ] = str_replace( $replace, $replace_with, $v );
992
+				unset($k, $v);
993
+			}
994
+		} else {
995
+			$val = str_replace($replace, $replace_with, $val);
996
+		}
997
+
998
+		return $val;
999
+	}
1000
+
1001
+	public static function get_us_states() {
1002
+		return apply_filters( 'frm_us_states', array(
1003
+			'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona',
1004
+			'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware',
1005
+			'DC' => 'District of Columbia',
1006
+			'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1007
+			'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1008
+			'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1009
+			'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1010
+			'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1011
+			'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
1012
+			'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma',
1013
+			'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina',
1014
+			'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah',
1015
+			'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia',
1016
+			'WI' => 'Wisconsin', 'WY' => 'Wyoming',
1017
+		) );
1018
+	}
1019
+
1020
+	public static function get_countries() {
1021
+		return apply_filters( 'frm_countries', array(
1022
+			__( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ),
1023
+			__( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ),
1024
+			__( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ),
1025
+			__( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ),
1026
+			__( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ),
1027
+			__( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ),
1028
+			__( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ),
1029
+			__( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ),
1030
+			__( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ),
1031
+			__( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ),
1032
+			__( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ),
1033
+			__( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ),
1034
+			__( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ),
1035
+			__( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ),
1036
+			__( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ),
1037
+			__( 'Costa Rica', 'formidable' ), __( 'C&ocirc;te d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ),
1038
+			__( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ),
1039
+			__( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ),
1040
+			__( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ),
1041
+			__( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ),
1042
+			__( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ),
1043
+			__( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ),
1044
+			__( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ),
1045
+			__( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ),
1046
+			__( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ),
1047
+			__( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ),
1048
+			__( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ),
1049
+			__( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ),
1050
+			__( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ),
1051
+			__( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ),
1052
+			__( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ),
1053
+			__( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ),
1054
+			__( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ),
1055
+			__( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ),
1056
+			__( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ),
1057
+			__( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ),
1058
+			__( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ),
1059
+			__( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ),
1060
+			__( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ),
1061
+			__( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ),
1062
+			__( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ),
1063
+			__( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ),
1064
+			__( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ),
1065
+			__( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ),
1066
+			__( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ),
1067
+			__( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ),
1068
+			__( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ),
1069
+			__( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ),
1070
+			__( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ),
1071
+			__( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ),
1072
+			__( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ),
1073
+			__( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ),
1074
+			__( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ),
1075
+			__( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ),
1076
+			__( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ),
1077
+			__( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ),
1078
+			__( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ),
1079
+			__( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ),
1080
+			__( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ),
1081
+			__( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ),
1082
+			__( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ),
1083
+			__( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ),
1084
+			__( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ),
1085
+			__( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ),
1086
+			__( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ),
1087
+			__( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ),
1088
+			__( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ),
1089
+			__( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ),
1090
+			__( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ),
1091
+			__( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ),
1092
+			__( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ),
1093
+			__( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ),
1094
+			__( 'Zimbabwe', 'formidable' ),
1095
+		) );
1096
+	}
1097 1097
 
1098 1098
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1099 1099
 		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1100 1100
 
1101
-        $states = FrmFieldsHelper::get_us_states();
1102
-        $state_abv = array_keys($states);
1103
-        sort($state_abv);
1101
+		$states = FrmFieldsHelper::get_us_states();
1102
+		$state_abv = array_keys($states);
1103
+		sort($state_abv);
1104 1104
 		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1105 1105
 
1106
-        $states = array_values($states);
1107
-        sort($states);
1106
+		$states = array_values($states);
1107
+		sort($states);
1108 1108
 		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1109
-        unset($state_abv, $states);
1109
+		unset($state_abv, $states);
1110 1110
 
1111 1111
 		$prepop[ __( 'Age', 'formidable' ) ] = array(
1112
-            __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1113
-            __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1114
-            __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1115
-        );
1112
+			__( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1113
+			__( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1114
+			__( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1115
+		);
1116 1116
 
1117 1117
 		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1118
-            __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1119
-            __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1120
-        );
1118
+			__( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1119
+			__( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1120
+		);
1121 1121
 
1122 1122
 		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1123
-            __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1124
-            __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1125
-        );
1123
+			__( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1124
+			__( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1125
+		);
1126 1126
 
1127 1127
 		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1128
-            __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1129
-            __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1130
-        );
1128
+			__( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1129
+			__( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1130
+		);
1131 1131
 
1132 1132
 		$prepop = apply_filters( 'frm_bulk_field_choices', $prepop );
1133
-    }
1133
+	}
1134 1134
 
1135 1135
 	/**
1136 1136
 	 * Display a field value selector
@@ -1140,10 +1140,10 @@  discard block
 block discarded – undo
1140 1140
 	 * @param int $selector_field_id
1141 1141
 	 * @param array $selector_args
1142 1142
 	 */
1143
-    public static function display_field_value_selector( $selector_field_id, $selector_args ) {
1144
-	    $field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args );
1145
-	    $field_value_selector->display();
1146
-    }
1143
+	public static function display_field_value_selector( $selector_field_id, $selector_args ) {
1144
+		$field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args );
1145
+		$field_value_selector->display();
1146
+	}
1147 1147
 
1148 1148
 	/**
1149 1149
 	 * Convert a field object to a flat array
Please login to merge, or discard this patch.
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
 
8 8
 	public static function setup_new_vars( $type = '', $form_id = '' ) {
9 9
 
10
-        if ( strpos($type, '|') ) {
11
-            list($type, $setting) = explode('|', $type);
10
+        if ( strpos( $type, '|' ) ) {
11
+            list( $type, $setting ) = explode( '|', $type );
12 12
         }
13 13
 
14 14
 		$values = self::get_default_field( $type );
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 			if ( in_array( $type, array( 'data', 'lookup' ) ) ) {
26 26
 				$values['field_options']['data_type'] = $setting;
27 27
 			} else {
28
-				$values['field_options'][ $setting ] = 1;
28
+				$values['field_options'][$setting] = 1;
29 29
 			}
30 30
 		}
31 31
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 		if ( ! $doing_ajax ) {
49 49
 			$field_values = array( 'name', 'description', 'field_key', 'type', 'default_value', 'field_order', 'required' );
50 50
 			foreach ( $field_values as $var ) {
51
-				$values[ $var ] = FrmAppHelper::get_param( $var, $values[ $var ], 'get', 'htmlspecialchars' );
51
+				$values[$var] = FrmAppHelper::get_param( $var, $values[$var], 'get', 'htmlspecialchars' );
52 52
 				unset( $var );
53 53
 			}
54 54
 
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 		$defaults = self::get_default_field_options_from_field( $field );
79 79
 
80 80
 		foreach ( $defaults as $opt => $default ) {
81
-			$current_opt = isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default;
82
-			$values[ $opt ] = ( $_POST && isset( $_POST['field_options'][ $opt . '_' . $field->id ] ) ) ? stripslashes_deep( maybe_unserialize( $_POST['field_options'][ $opt . '_' . $field->id ] ) ) : $current_opt;
81
+			$current_opt = isset( $field->field_options[$opt] ) ? $field->field_options[$opt] : $default;
82
+			$values[$opt] = ( $_POST && isset( $_POST['field_options'][$opt . '_' . $field->id] ) ) ? stripslashes_deep( maybe_unserialize( $_POST['field_options'][$opt . '_' . $field->id] ) ) : $current_opt;
83 83
 			unset( $opt, $default );
84 84
 		}
85 85
 	}
@@ -128,11 +128,11 @@  discard block
 block discarded – undo
128 128
 
129 129
 		$values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' );
130 130
         $values['form_id'] = $form_id;
131
-        $values['options'] = maybe_serialize($field->options);
132
-        $values['default_value'] = maybe_serialize($field->default_value);
131
+        $values['options'] = maybe_serialize( $field->options );
132
+        $values['default_value'] = maybe_serialize( $field->default_value );
133 133
 
134 134
         foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
135
-            $values[ $col ] = $field->{$col};
135
+            $values[$col] = $field->{$col};
136 136
         }
137 137
     }
138 138
 
@@ -146,14 +146,14 @@  discard block
 block discarded – undo
146 146
 
147 147
 		$conf_msg = __( 'The entered values do not match', 'formidable' );
148 148
 		$defaults = array(
149
-			'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __('%s must be unique', 'formidable' ), $field_name ) ),
150
-			'invalid'   => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __('%s is invalid', 'formidable' ), $field_name ) ),
149
+			'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __( '%s must be unique', 'formidable' ), $field_name ) ),
150
+			'invalid'   => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __( '%s is invalid', 'formidable' ), $field_name ) ),
151 151
 			'blank'     => array( 'full' => $frm_settings->blank_msg, 'part' => $frm_settings->blank_msg ),
152 152
 			'conf_msg'  => array( 'full' => $conf_msg, 'part' => $conf_msg ),
153 153
 		);
154 154
 
155 155
 		$msg = FrmField::get_option( $field, $error );
156
-		$msg = empty( $msg ) ? $defaults[ $error ]['part'] : $msg;
156
+		$msg = empty( $msg ) ? $defaults[$error]['part'] : $msg;
157 157
 		$msg = do_shortcode( $msg );
158 158
 		return $msg;
159 159
 	}
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 			$default_html = apply_filters( 'frm_other_custom_html', '', $type );
173 173
 		}
174 174
 
175
-		return apply_filters('frm_custom_html', $default_html, $type);
175
+		return apply_filters( 'frm_custom_html', $default_html, $type );
176 176
 	}
177 177
 
178 178
 	public static function show_fields( $fields, $errors, $form, $form_action ) {
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 		}
265 265
 
266 266
         $field_name = $field['name'];
267
-        $html_id = self::get_html_id($field);
267
+        $html_id = self::get_html_id( $field );
268 268
 
269 269
 		foreach ( $field['options'] as $opt_key => $opt ) {
270 270
 		    $field_val = self::get_value_from_array( $opt, $opt_key, $field );
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 			// Get string for Other text field, if needed
274 274
 			$other_val = self::get_other_val( compact( 'opt_key', 'field' ) );
275 275
 
276
-			$checked = ( $other_val || isset( $field['value'] ) && ( ( ! is_array( $field['value'] ) && $field['value'] == $field_val ) || ( is_array($field['value'] ) && in_array( $field_val, $field['value'] ) ) ) ) ? ' checked="checked"':'';
276
+			$checked = ( $other_val || isset( $field['value'] ) && ( ( ! is_array( $field['value'] ) && $field['value'] == $field_val ) || ( is_array( $field['value'] ) && in_array( $field_val, $field['value'] ) ) ) ) ? ' checked="checked"' : '';
277 277
 
278 278
 		    // If this is an "Other" option, get the HTML for it
279 279
 			if ( self::is_other_opt( $opt_key ) ) {
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	}
300 300
 
301 301
 	public static function get_term_link( $tax_id ) {
302
-        $tax = get_taxonomy($tax_id);
302
+        $tax = get_taxonomy( $tax_id );
303 303
         if ( ! $tax ) {
304 304
             return;
305 305
         }
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
             __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
309 309
 			'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
310 310
         );
311
-        unset($tax);
311
+        unset( $tax );
312 312
 
313 313
         return $link;
314 314
     }
@@ -317,8 +317,8 @@  discard block
 block discarded – undo
317 317
 		$hide_opt = self::get_value_for_comparision( $hide_opt );
318 318
 		$observed_value = self::get_value_for_comparision( $observed_value );
319 319
 
320
-        if ( is_array($observed_value) ) {
321
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
320
+        if ( is_array( $observed_value ) ) {
321
+            return self::array_value_condition( $observed_value, $cond, $hide_opt );
322 322
         }
323 323
 
324 324
         $m = false;
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
         } else if ( $cond == '<' ) {
332 332
             $m = $observed_value < $hide_opt;
333 333
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
334
-            $m = stripos($observed_value, $hide_opt);
334
+            $m = stripos( $observed_value, $hide_opt );
335 335
             if ( $cond == 'not LIKE' ) {
336 336
                 $m = ( $m === false ) ? true : false;
337 337
             } else {
@@ -357,23 +357,23 @@  discard block
 block discarded – undo
357 357
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
358 358
         $m = false;
359 359
         if ( $cond == '==' ) {
360
-            if ( is_array($hide_opt) ) {
361
-                $m = array_intersect($hide_opt, $observed_value);
362
-                $m = empty($m) ? false : true;
360
+            if ( is_array( $hide_opt ) ) {
361
+                $m = array_intersect( $hide_opt, $observed_value );
362
+                $m = empty( $m ) ? false : true;
363 363
             } else {
364
-                $m = in_array($hide_opt, $observed_value);
364
+                $m = in_array( $hide_opt, $observed_value );
365 365
             }
366 366
         } else if ( $cond == '!=' ) {
367
-            $m = ! in_array($hide_opt, $observed_value);
367
+            $m = ! in_array( $hide_opt, $observed_value );
368 368
         } else if ( $cond == '>' ) {
369
-            $min = min($observed_value);
369
+            $min = min( $observed_value );
370 370
             $m = $min > $hide_opt;
371 371
         } else if ( $cond == '<' ) {
372
-            $max = max($observed_value);
372
+            $max = max( $observed_value );
373 373
             $m = $max < $hide_opt;
374 374
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
375 375
             foreach ( $observed_value as $ob ) {
376
-                $m = strpos($ob, $hide_opt);
376
+                $m = strpos( $ob, $hide_opt );
377 377
                 if ( $m !== false ) {
378 378
                     $m = true;
379 379
                     break;
@@ -394,27 +394,27 @@  discard block
 block discarded – undo
394 394
      * @return string
395 395
      */
396 396
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
397
-        if ( strpos($value, '[sitename]') !== false ) {
397
+        if ( strpos( $value, '[sitename]' ) !== false ) {
398 398
             $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
399
-            $value = str_replace('[sitename]', $new_value, $value);
399
+            $value = str_replace( '[sitename]', $new_value, $value );
400 400
         }
401 401
 
402
-        $value = apply_filters('frm_content', $value, $form, $entry);
403
-        $value = do_shortcode($value);
402
+        $value = apply_filters( 'frm_content', $value, $form, $entry );
403
+        $value = do_shortcode( $value );
404 404
 
405 405
         return $value;
406 406
     }
407 407
 
408 408
 	public static function get_shortcodes( $content, $form_id ) {
409 409
         if ( FrmAppHelper::pro_is_installed() ) {
410
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
410
+            return FrmProDisplaysHelper::get_shortcodes( $content, $form_id );
411 411
         }
412 412
 
413 413
         $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
414 414
 
415
-        $tagregexp = self::allowed_shortcodes($fields);
415
+        $tagregexp = self::allowed_shortcodes( $fields );
416 416
 
417
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
417
+        preg_match_all( "/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER );
418 418
 
419 419
         return $matches;
420 420
     }
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
             $tagregexp[] = $field->field_key;
433 433
         }
434 434
 
435
-        $tagregexp = implode('|', $tagregexp);
435
+        $tagregexp = implode( '|', $tagregexp );
436 436
         return $tagregexp;
437 437
     }
438 438
 
@@ -448,28 +448,28 @@  discard block
 block discarded – undo
448 448
 				continue;
449 449
 			}
450 450
 
451
-            $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] );
451
+            $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][$short_key] );
452 452
 
453
-            if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
454
-				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] );
455
-                $tags = explode(' ', $tag);
456
-                if ( is_array($tags) ) {
453
+            if ( ! empty( $shortcodes[3][$short_key] ) ) {
454
+				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][$short_key] );
455
+                $tags = explode( ' ', $tag );
456
+                if ( is_array( $tags ) ) {
457 457
                     $tag = $tags[0];
458 458
                 }
459 459
             } else {
460
-                $tag = $shortcodes[2][ $short_key ];
460
+                $tag = $shortcodes[2][$short_key];
461 461
             }
462 462
 
463 463
             switch ( $tag ) {
464 464
                 case 'id':
465 465
                 case 'key':
466 466
                 case 'ip':
467
-                    $replace_with = $shortcode_values[ $tag ];
467
+                    $replace_with = $shortcode_values[$tag];
468 468
                 break;
469 469
 
470 470
                 case 'user_agent':
471 471
                 case 'user-agent':
472
-                    $entry->description = maybe_unserialize($entry->description);
472
+                    $entry->description = maybe_unserialize( $entry->description );
473 473
 					$replace_with = FrmEntriesHelper::get_browser( $entry->description['browser'] );
474 474
                 break;
475 475
 
@@ -477,25 +477,25 @@  discard block
 block discarded – undo
477 477
                 case 'created-at':
478 478
                 case 'updated_at':
479 479
                 case 'updated-at':
480
-                    if ( isset($atts['format']) ) {
480
+                    if ( isset( $atts['format'] ) ) {
481 481
                         $time_format = ' ';
482 482
                     } else {
483
-                        $atts['format'] = get_option('date_format');
483
+                        $atts['format'] = get_option( 'date_format' );
484 484
                         $time_format = '';
485 485
                     }
486 486
 
487
-                    $this_tag = str_replace('-', '_', $tag);
488
-                    $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
489
-                    unset($this_tag);
487
+                    $this_tag = str_replace( '-', '_', $tag );
488
+                    $replace_with = FrmAppHelper::get_formatted_time( $entry->{$this_tag}, $atts['format'], $time_format );
489
+                    unset( $this_tag );
490 490
                 break;
491 491
 
492 492
                 case 'created_by':
493 493
                 case 'created-by':
494 494
                 case 'updated_by':
495 495
                 case 'updated-by':
496
-                    $this_tag = str_replace('-', '_', $tag);
496
+                    $this_tag = str_replace( '-', '_', $tag );
497 497
 					$replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts );
498
-                    unset($this_tag);
498
+                    unset( $this_tag );
499 499
                 break;
500 500
 
501 501
                 case 'admin_email':
@@ -512,16 +512,16 @@  discard block
 block discarded – undo
512 512
                         break;
513 513
                     }
514 514
 
515
-                    $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
515
+                    $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
516 516
 
517 517
                     $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
518 518
 
519 519
                     $atts['entry_id'] = $entry->id;
520 520
                     $atts['entry_key'] = $entry->item_key;
521 521
 
522
-                    if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
522
+                    if ( isset( $atts['show'] ) && $atts['show'] == 'field_label' ) {
523 523
                         $replace_with = $field->name;
524
-                    } else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
524
+                    } else if ( isset( $atts['show'] ) && $atts['show'] == 'description' ) {
525 525
                         $replace_with = $field->description;
526 526
 					} else {
527 527
 						$string_value = $replace_with;
@@ -536,15 +536,15 @@  discard block
 block discarded – undo
536 536
 						}
537 537
 					}
538 538
 
539
-                    unset($field);
539
+                    unset( $field );
540 540
                 break;
541 541
             }
542 542
 
543
-            if ( isset($replace_with) ) {
544
-                $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
543
+            if ( isset( $replace_with ) ) {
544
+                $content = str_replace( $shortcodes[0][$short_key], $replace_with, $content );
545 545
             }
546 546
 
547
-            unset($atts, $conditional, $replace_with);
547
+            unset( $atts, $conditional, $replace_with );
548 548
 		}
549 549
 
550 550
 		return $content;
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
         $new_value = '';
561 561
         switch ( $tag ) {
562 562
             case 'admin_email':
563
-                $new_value = get_option('admin_email');
563
+                $new_value = get_option( 'admin_email' );
564 564
                 break;
565 565
             case 'siteurl':
566 566
                 $new_value = FrmAppHelper::site_url();
@@ -586,28 +586,28 @@  discard block
 block discarded – undo
586 586
      * @return string|array
587 587
      */
588 588
     public static function process_get_shortcode( $atts, $return_array = false ) {
589
-        if ( ! isset($atts['param']) ) {
589
+        if ( ! isset( $atts['param'] ) ) {
590 590
             return '';
591 591
         }
592 592
 
593
-        if ( strpos($atts['param'], '&#91;') ) {
594
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
595
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
593
+        if ( strpos( $atts['param'], '&#91;' ) ) {
594
+            $atts['param'] = str_replace( '&#91;', '[', $atts['param'] );
595
+            $atts['param'] = str_replace( '&#93;', ']', $atts['param'] );
596 596
         }
597 597
 
598
-        $new_value = FrmAppHelper::get_param($atts['param'], '');
598
+        $new_value = FrmAppHelper::get_param( $atts['param'], '' );
599 599
         $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
600 600
 
601 601
         if ( $new_value == '' ) {
602
-            if ( ! isset($atts['prev_val']) ) {
602
+            if ( ! isset( $atts['prev_val'] ) ) {
603 603
                 $atts['prev_val'] = '';
604 604
             }
605 605
 
606
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
606
+            $new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val'];
607 607
         }
608 608
 
609
-        if ( is_array($new_value) && ! $return_array ) {
610
-            $new_value = implode(', ', $new_value);
609
+        if ( is_array( $new_value ) && ! $return_array ) {
610
+            $new_value = implode( ', ', $new_value );
611 611
         }
612 612
 
613 613
         return $new_value;
@@ -644,9 +644,9 @@  discard block
 block discarded – undo
644 644
 			'blank' => false, 'link' => false, 'size' => 96
645 645
 		);
646 646
 
647
-		$args = wp_parse_args($args, $defaults);
647
+		$args = wp_parse_args( $args, $defaults );
648 648
 
649
-		$user = get_userdata($user_id);
649
+		$user = get_userdata( $user_id );
650 650
 		$info = '';
651 651
 
652 652
 		if ( $user ) {
@@ -655,16 +655,16 @@  discard block
 block discarded – undo
655 655
 			} elseif ( $user_info == 'author_link' ) {
656 656
 				$info = get_author_posts_url( $user_id );
657 657
 			} else {
658
-				$info = isset($user->$user_info) ? $user->$user_info : '';
658
+				$info = isset( $user->$user_info ) ? $user->$user_info : '';
659 659
 			}
660 660
 
661
-			if ( empty($info) && ! $args['blank'] ) {
661
+			if ( empty( $info ) && ! $args['blank'] ) {
662 662
 				$info = $user->user_login;
663 663
 			}
664 664
 		}
665 665
 
666 666
 		if ( $args['link'] ) {
667
-			$info = '<a href="' .  esc_url( admin_url('user-edit.php?user_id=' . $user_id ) ) . '">' . $info . '</a>';
667
+			$info = '<a href="' . esc_url( admin_url( 'user-edit.php?user_id=' . $user_id ) ) . '">' . $info . '</a>';
668 668
 		}
669 669
 
670 670
 		return $info;
@@ -682,14 +682,14 @@  discard block
 block discarded – undo
682 682
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
683 683
 
684 684
         $field_types = array();
685
-        if ( in_array($type, $single_input) ) {
685
+        if ( in_array( $type, $single_input ) ) {
686 686
             self::field_types_for_input( $single_input, $field_selection, $field_types );
687
-        } else if ( in_array($type, $multiple_input) ) {
687
+        } else if ( in_array( $type, $multiple_input ) ) {
688 688
             self::field_types_for_input( $multiple_input, $field_selection, $field_types );
689
-        } else if ( in_array($type, $other_type) ) {
689
+        } else if ( in_array( $type, $other_type ) ) {
690 690
             self::field_types_for_input( $other_type, $field_selection, $field_types );
691
-		} else if ( isset( $field_selection[ $type ] ) ) {
692
-            $field_types[ $type ] = $field_selection[ $type ];
691
+		} else if ( isset( $field_selection[$type] ) ) {
692
+            $field_types[$type] = $field_selection[$type];
693 693
         }
694 694
 
695 695
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
@@ -698,8 +698,8 @@  discard block
 block discarded – undo
698 698
 
699 699
     private static function field_types_for_input( $inputs, $fields, &$field_types ) {
700 700
         foreach ( $inputs as $input ) {
701
-            $field_types[ $input ] = $fields[ $input ];
702
-            unset($input);
701
+            $field_types[$input] = $fields[$input];
702
+            unset( $input );
703 703
         }
704 704
     }
705 705
 
@@ -744,21 +744,21 @@  discard block
 block discarded – undo
744 744
 		// Check posted vals before checking saved values
745 745
 
746 746
 		// For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero
747
-		if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) {
747
+		if ( $parent && isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ) {
748 748
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
749
-				$other_val = isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) : '';
749
+				$other_val = isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) : '';
750 750
 			} else {
751
-				$other_val = sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] );
751
+				$other_val = sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] );
752 752
 			}
753 753
 			return $other_val;
754 754
 
755
-		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) {
755
+		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][$field['id']] ) ) {
756 756
 			// For normal fields
757 757
 
758 758
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
759
-				$other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) : '';
759
+				$other_val = isset( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta']['other'][$field['id']][$opt_key] ) : '';
760 760
 			} else {
761
-				$other_val = sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ] );
761
+				$other_val = sanitize_text_field( $_POST['item_meta']['other'][$field['id']] );
762 762
 			}
763 763
 			return $other_val;
764 764
 		}
@@ -767,8 +767,8 @@  discard block
 block discarded – undo
767 767
 		if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) {
768 768
 			// Check if there is an "other" val in saved value and make sure the
769 769
 			// "other" val is not equal to the Other checkbox option
770
-			if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) {
771
-				$other_val = $field['value'][ $opt_key ];
770
+			if ( isset( $field['value'][$opt_key] ) && $field['options'][$opt_key] != $field['value'][$opt_key] ) {
771
+				$other_val = $field['value'][$opt_key];
772 772
 			}
773 773
 		} else {
774 774
 			/**
@@ -780,8 +780,8 @@  discard block
 block discarded – undo
780 780
 				// Multi-select dropdowns - key is not preserved
781 781
 				if ( is_array( $field['value'] ) ) {
782 782
 					$o_key = array_search( $temp_val, $field['value'] );
783
-					if ( isset( $field['value'][ $o_key ] ) ) {
784
-						unset( $field['value'][ $o_key ], $o_key );
783
+					if ( isset( $field['value'][$o_key] ) ) {
784
+						unset( $field['value'][$o_key], $o_key );
785 785
 					}
786 786
 				} else if ( $temp_val == $field['value'] ) {
787 787
 					// For radio and regular dropdowns
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
 	private static function set_other_name( $args, &$other_args ) {
839 839
 		//Set up name for other field
840 840
 		$other_args['name'] = str_replace( '[]', '', $args['field_name'] );
841
-		$other_args['name'] = preg_replace('/\[' . $args['field']['id'] . '\]$/', '', $other_args['name']);
841
+		$other_args['name'] = preg_replace( '/\[' . $args['field']['id'] . '\]$/', '', $other_args['name'] );
842 842
 		$other_args['name'] = $other_args['name'] . '[other]' . '[' . $args['field']['id'] . ']';
843 843
 
844 844
 		//Converts item_meta[field_id] => item_meta[other][field_id] and
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
 		// Count should only be greater than 3 if inside of a repeating section
866 866
 		if ( count( $temp_array ) > 3 ) {
867 867
 			$parent = str_replace( ']', '', $temp_array[1] );
868
-			$pointer = str_replace( ']', '', $temp_array[2]);
868
+			$pointer = str_replace( ']', '', $temp_array[2] );
869 869
 		}
870 870
 
871 871
 		// Get text for "other" text field
@@ -984,15 +984,15 @@  discard block
 block discarded – undo
984 984
 			$replace_with[] = '[' . $new . ']';
985 985
 			$replace[] = '[' . $old . ' ';
986 986
 			$replace_with[] = '[' . $new . ' ';
987
-            unset($old, $new);
987
+            unset( $old, $new );
988 988
         }
989 989
 		if ( is_array( $val ) ) {
990 990
 			foreach ( $val as $k => $v ) {
991
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
992
-                unset($k, $v);
991
+                $val[$k] = str_replace( $replace, $replace_with, $v );
992
+                unset( $k, $v );
993 993
             }
994 994
         } else {
995
-            $val = str_replace($replace, $replace_with, $val);
995
+            $val = str_replace( $replace, $replace_with, $val );
996 996
         }
997 997
 
998 998
         return $val;
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
             'DC' => 'District of Columbia',
1006 1006
             'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1007 1007
             'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1008
-            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1008
+            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine', 'MD' => 'Maryland',
1009 1009
             'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1010 1010
             'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1011 1011
             'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
@@ -1096,35 +1096,35 @@  discard block
 block discarded – undo
1096 1096
     }
1097 1097
 
1098 1098
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1099
-		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1099
+		$prepop[__( 'Countries', 'formidable' )] = FrmFieldsHelper::get_countries();
1100 1100
 
1101 1101
         $states = FrmFieldsHelper::get_us_states();
1102
-        $state_abv = array_keys($states);
1103
-        sort($state_abv);
1104
-		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1102
+        $state_abv = array_keys( $states );
1103
+        sort( $state_abv );
1104
+		$prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv;
1105 1105
 
1106
-        $states = array_values($states);
1107
-        sort($states);
1108
-		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1109
-        unset($state_abv, $states);
1106
+        $states = array_values( $states );
1107
+        sort( $states );
1108
+		$prepop[__( 'U.S. States', 'formidable' )] = $states;
1109
+        unset( $state_abv, $states );
1110 1110
 
1111
-		$prepop[ __( 'Age', 'formidable' ) ] = array(
1111
+		$prepop[__( 'Age', 'formidable' )] = array(
1112 1112
             __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1113 1113
             __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1114 1114
             __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1115 1115
         );
1116 1116
 
1117
-		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1117
+		$prepop[__( 'Satisfaction', 'formidable' )] = array(
1118 1118
             __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1119 1119
             __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1120 1120
         );
1121 1121
 
1122
-		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1122
+		$prepop[__( 'Importance', 'formidable' )] = array(
1123 1123
             __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1124 1124
             __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1125 1125
         );
1126 1126
 
1127
-		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1127
+		$prepop[__( 'Agreement', 'formidable' )] = array(
1128 1128
             __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1129 1129
             __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1130 1130
         );
Please login to merge, or discard this patch.
classes/models/fields/FrmFieldType.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -259,6 +259,9 @@
 block discarded – undo
259 259
 		return $this->alter_builder_classes( $classes );
260 260
 	}
261 261
 
262
+	/**
263
+	 * @param string $classes
264
+	 */
262 265
 	protected function alter_builder_classes( $classes ) {
263 266
 		return $classes;
264 267
 	}
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	protected function set_type( $type ) {
77 77
 		if ( empty( $this->type ) ) {
78
-			$this->type = $this->get_field_column('type');
78
+			$this->type = $this->get_field_column( 'type' );
79 79
 			if ( empty( $this->type ) && ! empty( $type ) ) {
80 80
 				$this->type = $type;
81 81
 			}
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
 		$field_val = '';
92 92
 		if ( is_object( $this->field ) ) {
93 93
 			$field_val = $this->field->{$column};
94
-		} elseif ( is_array( $this->field ) && isset( $this->field[ $column ] ) ) {
95
-			$field_val = $this->field[ $column ];
94
+		} elseif ( is_array( $this->field ) && isset( $this->field[$column] ) ) {
95
+			$field_val = $this->field[$column];
96 96
 		}
97 97
 		return $field_val;
98 98
 	}
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 		if ( is_object( $this->field ) ) {
106 106
 			$this->field->{$column} = $value;
107 107
 		} elseif ( is_array( $this->field ) ) {
108
-			$this->field[ $column ] = $value;
108
+			$this->field[$column] = $value;
109 109
 		}
110 110
 	}
111 111
 
@@ -197,16 +197,16 @@  discard block
 block discarded – undo
197 197
 	}
198 198
 
199 199
 	protected function builder_text_field() {
200
-		return '<input type="text" name="' . esc_attr( $this->html_name() ) . '" id="' . esc_attr( $this->html_id() ) . '" value="' . esc_attr( $this->get_field_column('default_value') ) . '" class="dyn_default_value" />';
200
+		return '<input type="text" name="' . esc_attr( $this->html_name() ) . '" id="' . esc_attr( $this->html_id() ) . '" value="' . esc_attr( $this->get_field_column( 'default_value' ) ) . '" class="dyn_default_value" />';
201 201
 	}
202 202
 
203 203
 	protected function html_name( $name = '' ) {
204 204
 		$prefix = empty( $name ) ? 'item_meta' : $name;
205
-		return $prefix . '[' . $this->get_field_column('id') . ']';
205
+		return $prefix . '[' . $this->get_field_column( 'id' ) . ']';
206 206
 	}
207 207
 
208 208
 	protected function html_id( $plus = '' ) {
209
-		return apply_filters( 'frm_field_get_html_id', 'field_' . $this->get_field_column('field_key') . $plus, $this->field );
209
+		return apply_filters( 'frm_field_get_html_id', 'field_' . $this->get_field_column( 'field_key' ) . $plus, $this->field );
210 210
     }
211 211
 
212 212
 	public function display_field_settings() {
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 	}
297 297
 
298 298
 	protected function default_invalid_msg() {
299
-		$field_name = $this->get_field_column('name');
299
+		$field_name = $this->get_field_column( 'name' );
300 300
 		if ( $field_name == '' ) {
301 301
 			$invalid = __( 'This field is invalid', 'formidable' );
302 302
 		} else {
@@ -312,8 +312,8 @@  discard block
 block discarded – undo
312 312
 		$fields = FrmField::field_selection();
313 313
 		$fields = array_merge( $fields, FrmField::pro_field_selection() );
314 314
 
315
-		if ( isset( $fields[ $this->type ] ) ) {
316
-			$name = is_array( $fields[ $this->type ] ) ? $fields[ $this->type ]['name'] : $fields[ $this->type ];
315
+		if ( isset( $fields[$this->type] ) ) {
316
+			$name = is_array( $fields[$this->type] ) ? $fields[$this->type]['name'] : $fields[$this->type];
317 317
 		}
318 318
 
319 319
 		return $name;
@@ -462,8 +462,8 @@  discard block
 block discarded – undo
462 462
 
463 463
 	protected function fill_display_field_values( $args = array() ) {
464 464
 		$defaults = array(
465
-			'field_name'    => 'item_meta[' . $this->get_field_column('id') . ']',
466
-			'field_id'      => $this->get_field_column('id'),
465
+			'field_name'    => 'item_meta[' . $this->get_field_column( 'id' ) . ']',
466
+			'field_id'      => $this->get_field_column( 'id' ),
467 467
 			'field_plus_id' => '',
468 468
 			'section_id'    => '',
469 469
 		);
@@ -500,8 +500,8 @@  discard block
 block discarded – undo
500 500
 		$value = $this->prepare_display_value( $value, $atts );
501 501
 
502 502
 		if ( is_array( $value ) ) {
503
-			if ( isset( $atts['show'] ) && $atts['show'] && isset( $value[ $atts['show'] ] ) ) {
504
-				$value = $value[ $atts['show'] ];
503
+			if ( isset( $atts['show'] ) && $atts['show'] && isset( $value[$atts['show']] ) ) {
504
+				$value = $value[$atts['show']];
505 505
 			} elseif ( ! isset( $atts['return_array'] ) || ! $atts['return_array'] ) {
506 506
 				$sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
507 507
 				$value = implode( $sep, $value );
@@ -560,8 +560,8 @@  discard block
 block discarded – undo
560 560
 		$saved_entries = $atts['ids'];
561 561
 		$new_value = array();
562 562
 		foreach ( (array) $value as $old_child_id ) {
563
-			if ( isset( $saved_entries[ $old_child_id ] ) ) {
564
-				$new_value[] = $saved_entries[ $old_child_id ];
563
+			if ( isset( $saved_entries[$old_child_id] ) ) {
564
+				$new_value[] = $saved_entries[$old_child_id];
565 565
 			}
566 566
 		}
567 567
 
Please login to merge, or discard this patch.
classes/models/FrmFieldFormHtml.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
 	 * @param array $atts
42 42
 	 */
43 43
 	private function _set( $param, $atts ) {
44
-		if ( isset( $atts[ $param ] ) ) {
45
-			$this->{$param} = $atts[ $param ];
44
+		if ( isset( $atts[$param] ) ) {
45
+			$this->{$param} = $atts[$param];
46 46
 		}
47 47
 	}
48 48
 
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 		$exclude = array( 'field_obj', 'html' );
75 75
 		
76 76
 		foreach ( $exclude as $ex ) {
77
-			if ( isset( $atts[ $ex ] ) ) {
78
-				unset( $this->pass_args[ $ex ] );
77
+			if ( isset( $atts[$ex] ) ) {
78
+				unset( $this->pass_args[$ex] );
79 79
 			}
80 80
 		}
81 81
 	}
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 	 * @param array $set
88 88
 	 */
89 89
 	private function set_from_field( $atts, $set ) {
90
-		if ( isset( $atts[ $set['param'] ] ) ) {
91
-			$this->{$set['param']} = $atts[ $set['param'] ];
90
+		if ( isset( $atts[$set['param']] ) ) {
91
+			$this->{$set['param']} = $atts[$set['param']];
92 92
 		} else {
93 93
 			$this->{$set['param']} = $this->field_obj->get_field_column( $set['default'] );
94 94
 		}
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	private function replace_shortcodes_before_input() {
109 109
 
110 110
 		// Remove the for attribute for captcha
111
-		if ( $this->field_obj->get_field_column('type') == 'captcha' ) {
111
+		if ( $this->field_obj->get_field_column( 'type' ) == 'captcha' ) {
112 112
 			$this->html = str_replace( ' for="field_[key]"', '', $this->html );
113 113
 		}
114 114
 
@@ -138,10 +138,10 @@  discard block
 block discarded – undo
138 138
 		$this->html = str_replace( 'field_[key]', $this->html_id, $this->html );
139 139
 
140 140
 		//replace [key]
141
-		$this->html = str_replace( '[key]', $this->field_obj->get_field_column('field_key'), $this->html );
141
+		$this->html = str_replace( '[key]', $this->field_obj->get_field_column( 'field_key' ), $this->html );
142 142
 
143 143
 		//replace [field_name]
144
-		$this->html = str_replace('[field_name]', $this->field_obj->get_field_column('name'), $this->html );
144
+		$this->html = str_replace( '[field_name]', $this->field_obj->get_field_column( 'name' ), $this->html );
145 145
 	}
146 146
 
147 147
 	/**
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	 * @since 3.0
152 152
 	 */
153 153
 	private function add_class_to_divider() {
154
-		if ( $this->field_obj->get_field_column('type') == 'divider' ) {
154
+		if ( $this->field_obj->get_field_column( 'type' ) == 'divider' ) {
155 155
 			if ( FrmField::is_option_true( $this->field_obj->get_field(), 'description' ) ) {
156 156
 				$this->html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $this->html );
157 157
 			} else {
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	 * @since 3.0
165 165
 	 */
166 166
 	private function replace_required_label_shortcode() {
167
-		$required = FrmField::is_required( $this->field_obj->get_field() ) ? $this->field_obj->get_field_column('required_indicator') : '';
167
+		$required = FrmField::is_required( $this->field_obj->get_field() ) ? $this->field_obj->get_field_column( 'required_indicator' ) : '';
168 168
 		FrmShortcodeHelper::remove_inline_conditions( ! empty( $required ), 'required_label', $required, $this->html );
169 169
 	}
170 170
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	 * @since 3.0
173 173
 	 */
174 174
 	private function replace_description_shortcode() {
175
-		$description = $this->field_obj->get_field_column('description');
175
+		$description = $this->field_obj->get_field_column( 'description' );
176 176
 		FrmShortcodeHelper::remove_inline_conditions( ( $description && $description != '' ), 'description', $description, $this->html );
177 177
 	}
178 178
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	 * @since 3.0
181 181
 	 */
182 182
 	private function replace_error_shortcode() {
183
-		$error = isset( $this->pass_args['errors'][ 'field' . $this->field_id ] ) ? $this->pass_args['errors'][ 'field' . $this->field_id ] : false;
183
+		$error = isset( $this->pass_args['errors']['field' . $this->field_id] ) ? $this->pass_args['errors']['field' . $this->field_id] : false;
184 184
 		FrmShortcodeHelper::remove_inline_conditions( ! empty( $error ), 'error', $error, $this->html );
185 185
 	}
186 186
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 		$this->html .= "\n";
217 217
 
218 218
 		//Return html if conf_field to prevent loop
219
-		if ( $this->field_obj->get_field_column('conf_field') == 'stop' ) {
219
+		if ( $this->field_obj->get_field_column( 'conf_field' ) == 'stop' ) {
220 220
 			return;
221 221
 		}
222 222
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 	 * @since 3.0
243 243
 	 */
244 244
 	private function filter_html_field_shortcodes() {
245
-		if ( $this->field_obj->get_field_column('type') == 'html' ) {
245
+		if ( $this->field_obj->get_field_column( 'type' ) == 'html' ) {
246 246
 			FrmFieldsHelper::run_wpautop( array( 'wpautop' => true ), $this->html );
247 247
 
248 248
 			$this->html = apply_filters( 'frm_get_default_value', $this->html, (object) $this->field_obj->get_field(), false );
@@ -264,10 +264,10 @@  discard block
 block discarded – undo
264 264
 	 * @since 3.0
265 265
 	 */
266 266
 	private function replace_shortcodes_with_atts() {
267
-		preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $this->html, $shortcodes, PREG_PATTERN_ORDER);
267
+		preg_match_all( "/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $this->html, $shortcodes, PREG_PATTERN_ORDER );
268 268
 
269 269
 		foreach ( $shortcodes[0] as $short_key => $tag ) {
270
-			$shortcode_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
270
+			$shortcode_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][$short_key] );
271 271
 			$tag = FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) );
272 272
 
273 273
 			$replace_with = '';
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 				$replace_with = $this->replace_input_shortcode( $shortcode_atts );
279 279
 			}
280 280
 
281
-			$this->html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $this->html );
281
+			$this->html = str_replace( $shortcodes[0][$short_key], $replace_with, $this->html );
282 282
 		}
283 283
 	}
284 284
 
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	 */
300 300
 	private function prepare_input_shortcode_atts( $shortcode_atts ) {
301 301
 		if ( isset( $shortcode_atts['opt'] ) ) {
302
-			$shortcode_atts['opt']--;
302
+			$shortcode_atts['opt'] --;
303 303
 		}
304 304
 
305 305
 		$field_class = isset( $shortcode_atts['class'] ) ? $shortcode_atts['class'] : '';
@@ -321,9 +321,9 @@  discard block
 block discarded – undo
321 321
 	 * @since 3.0
322 322
 	 */
323 323
 	private function add_class_to_label() {
324
-		$label_class = in_array( $this->field_obj->get_field_column('type'), array( 'divider', 'end_divider', 'break' ) ) ? $this->field_obj->get_field_column('label') : ' frm_primary_label';
324
+		$label_class = in_array( $this->field_obj->get_field_column( 'type' ), array( 'divider', 'end_divider', 'break' ) ) ? $this->field_obj->get_field_column( 'label' ) : ' frm_primary_label';
325 325
 		$this->html = str_replace( '[label_position]', $label_class, $this->html );
326
-		if ( $this->field_obj->get_field_column('label') == 'inside' && $this->field_obj->get_field_column('value') != '' ) {
326
+		if ( $this->field_obj->get_field_column( 'label' ) == 'inside' && $this->field_obj->get_field_column( 'value' ) != '' ) {
327 327
 			$this->html = str_replace( 'frm_primary_label', 'frm_primary_label frm_visible', $this->html );
328 328
 		}
329 329
 	}
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 	private function add_field_div_classes() {
347 347
 		$classes = $this->get_field_div_classes();
348 348
 
349
-		if ( $this->field_obj->get_field_column('type') == 'html' && strpos( $this->html, '[error_class]' ) === false ) {
349
+		if ( $this->field_obj->get_field_column( 'type' ) == 'html' && strpos( $this->html, '[error_class]' ) === false ) {
350 350
 			// there is no error_class shortcode for HTML fields
351 351
 			$this->html = str_replace( 'class="frm_form_field', 'class="frm_form_field ' . $classes, $this->html );
352 352
 		}
@@ -363,21 +363,21 @@  discard block
 block discarded – undo
363 363
 	 */
364 364
 	private function get_field_div_classes() {
365 365
 		// Add error class
366
-		$classes = isset( $this->pass_args['errors'][ 'field' . $this->field_id ] ) ? ' frm_blank_field' : '';
366
+		$classes = isset( $this->pass_args['errors']['field' . $this->field_id] ) ? ' frm_blank_field' : '';
367 367
 
368 368
 		// Add label position class
369
-		$classes .= ' frm_' . $this->field_obj->get_field_column('label') . '_container';
369
+		$classes .= ' frm_' . $this->field_obj->get_field_column( 'label' ) . '_container';
370 370
 
371 371
 		// Add CSS layout classes
372
-		if ( ! empty( $this->field_obj->get_field_column('classes') ) ) {
373
-			if ( ! strpos( $this->html, 'frm_form_field ') ) {
372
+		if ( ! empty( $this->field_obj->get_field_column( 'classes' ) ) ) {
373
+			if ( ! strpos( $this->html, 'frm_form_field ' ) ) {
374 374
 				$classes .= ' frm_form_field';
375 375
 			}
376
-			$classes .= ' ' . $this->field_obj->get_field_column('classes');
376
+			$classes .= ' ' . $this->field_obj->get_field_column( 'classes' );
377 377
 		}
378 378
 
379 379
 		// Add class to HTML field
380
-		if ( $this->field_obj->get_field_column('type') == 'html' ) {
380
+		if ( $this->field_obj->get_field_column( 'type' ) == 'html' ) {
381 381
 			$classes .= ' frm_html_container';
382 382
 		}
383 383
 
Please login to merge, or discard this patch.
classes/helpers/FrmFormsHelper.php 2 patches
Indentation   +248 added lines, -248 removed lines patch added patch discarded remove patch
@@ -14,38 +14,38 @@  discard block
 block discarded – undo
14 14
 
15 15
 	public static function get_direct_link( $key, $form = false ) {
16 16
 		$target_url = esc_url( admin_url( 'admin-ajax.php?action=frm_forms_preview&form=' . $key ) );
17
-        $target_url = apply_filters('frm_direct_link', $target_url, $key, $form);
18
-
19
-        return $target_url;
20
-    }
21
-
22
-    public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) {
23
-        $defaults = array(
24
-            'blank'     => true,
25
-            'field_id'  => false,
26
-            'onchange'  => false,
27
-            'exclude'   => false,
28
-            'class'     => '',
17
+		$target_url = apply_filters('frm_direct_link', $target_url, $key, $form);
18
+
19
+		return $target_url;
20
+	}
21
+
22
+	public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) {
23
+		$defaults = array(
24
+			'blank'     => true,
25
+			'field_id'  => false,
26
+			'onchange'  => false,
27
+			'exclude'   => false,
28
+			'class'     => '',
29 29
 			'inc_children' => 'exclude',
30
-        );
31
-        $args = wp_parse_args( $args, $defaults );
30
+		);
31
+		$args = wp_parse_args( $args, $defaults );
32 32
 
33
-        if ( ! $args['field_id'] ) {
34
-            $args['field_id'] = $field_name;
35
-        }
33
+		if ( ! $args['field_id'] ) {
34
+			$args['field_id'] = $field_name;
35
+		}
36 36
 
37 37
 		$query = array();
38
-        if ( $args['exclude'] ) {
38
+		if ( $args['exclude'] ) {
39 39
 			$query['id !'] = $args['exclude'];
40
-        }
40
+		}
41 41
 
42
-        $where = apply_filters('frm_forms_dropdown', $query, $field_name);
42
+		$where = apply_filters('frm_forms_dropdown', $query, $field_name);
43 43
 		$forms = FrmForm::get_published_forms( $where, 999, $args['inc_children'] );
44 44
 		$add_html = array();
45 45
 		self::add_html_attr( $args['onchange'], 'onchange', $add_html );
46 46
 		self::add_html_attr( $args['class'], 'class', $add_html );
47 47
 
48
-        ?>
48
+		?>
49 49
 		<select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $args['field_id'] ) ?>" <?php echo implode( ' ', $add_html ); ?>>
50 50
 		<?php if ( $args['blank'] ) { ?>
51 51
 			<option value=""><?php echo ( $args['blank'] == 1 ) ? ' ' : '- ' . esc_attr( $args['blank'] ) . ' -'; ?></option>
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		<?php } ?>
58 58
         </select>
59 59
         <?php
60
-    }
60
+	}
61 61
 
62 62
 	/**
63 63
 	 * @param string $class
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 		}
73 73
 	}
74 74
 
75
-    public static function form_switcher() {
75
+	public static function form_switcher() {
76 76
 		$where = apply_filters( 'frm_forms_dropdown', array(), '' );
77 77
 		$forms = FrmForm::get_published_forms( $where );
78 78
 
@@ -81,32 +81,32 @@  discard block
 block discarded – undo
81 81
 			unset( $args['form'] );
82 82
 		} else if ( isset( $_GET['form']) && ! isset( $_GET['id'] ) ) {
83 83
 			unset( $args['id'] );
84
-        }
84
+		}
85 85
 
86 86
 		$frm_action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
87 87
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy_all' ) ) ) {
88
-            $args['frm_action'] = 'list';
89
-            $args['form'] = 0;
88
+			$args['frm_action'] = 'list';
89
+			$args['form'] = 0;
90 90
 		} else if ( FrmAppHelper::is_admin_page('formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) {
91
-            $args['frm_action'] = 'edit';
91
+			$args['frm_action'] = 'edit';
92 92
 		} else if ( isset( $_GET['post'] ) ) {
93
-            $args['form'] = 0;
94
-            $base = admin_url('edit.php?post_type=frm_display');
95
-        }
93
+			$args['form'] = 0;
94
+			$base = admin_url('edit.php?post_type=frm_display');
95
+		}
96 96
 
97
-        ?>
97
+		?>
98 98
 		<li class="dropdown last" id="frm_bs_dropdown">
99 99
 			<a href="#" id="frm-navbarDrop" class="frm-dropdown-toggle" data-toggle="dropdown"><?php _e( 'Switch Form', 'formidable' ) ?> <b class="caret"></b></a>
100 100
 		    <ul class="frm-dropdown-menu frm-on-top" role="menu" aria-labelledby="frm-navbarDrop">
101 101
 			<?php
102 102
 			foreach ( $forms as $form ) {
103 103
 				if ( isset( $args['id'] ) ) {
104
-			        $args['id'] = $form->id;
104
+					$args['id'] = $form->id;
105 105
 				}
106
-			    if ( isset( $args['form'] ) ) {
107
-			        $args['form'] = $form->id;
106
+				if ( isset( $args['form'] ) ) {
107
+					$args['form'] = $form->id;
108 108
 				}
109
-                ?>
109
+				?>
110 110
 				<li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)') : FrmAppHelper::truncate( $form->name, 60 ) ); ?></a></li>
111 111
 			<?php
112 112
 				unset( $form );
@@ -114,12 +114,12 @@  discard block
 block discarded – undo
114 114
 			</ul>
115 115
 		</li>
116 116
         <?php
117
-    }
117
+	}
118 118
 
119 119
 	public static function get_sortable_classes( $col, $sort_col, $sort_dir ) {
120
-        echo ($sort_col == $col) ? 'sorted' : 'sortable';
121
-        echo ($sort_col == $col && $sort_dir == 'desc') ? ' asc' : ' desc';
122
-    }
120
+		echo ($sort_col == $col) ? 'sorted' : 'sortable';
121
+		echo ($sort_col == $col && $sort_dir == 'desc') ? ' asc' : ' desc';
122
+	}
123 123
 
124 124
 	/**
125 125
 	 * Get the invalid form error message
@@ -143,104 +143,104 @@  discard block
 block discarded – undo
143 143
 		return $message;
144 144
 	}
145 145
 
146
-    /**
147
-     * Used when a form is created
148
-     */
149
-    public static function setup_new_vars( $values = array() ) {
150
-        global $wpdb;
146
+	/**
147
+	 * Used when a form is created
148
+	 */
149
+	public static function setup_new_vars( $values = array() ) {
150
+		global $wpdb;
151 151
 
152
-        if ( ! empty( $values ) ) {
153
-            $post_values = $values;
154
-        } else {
155
-            $values = array();
156
-            $post_values = isset($_POST) ? $_POST : array();
157
-        }
152
+		if ( ! empty( $values ) ) {
153
+			$post_values = $values;
154
+		} else {
155
+			$values = array();
156
+			$post_values = isset($_POST) ? $_POST : array();
157
+		}
158 158
 
159 159
 		foreach ( array( 'name' => '', 'description' => '' ) as $var => $default ) {
160 160
 			if ( ! isset( $values[ $var ] ) ) {
161 161
 				$values[ $var ] = FrmAppHelper::get_param( $var, $default );
162
-            }
163
-        }
162
+			}
163
+		}
164 164
 
165
-        $values['description'] = FrmAppHelper::use_wpautop($values['description']);
165
+		$values['description'] = FrmAppHelper::use_wpautop($values['description']);
166 166
 
167 167
 		foreach ( array( 'form_id' => '', 'logged_in' => '', 'editable' => '', 'default_template' => 0, 'is_template' => 0, 'status' => 'draft', 'parent_form_id' => 0 ) as $var => $default ) {
168
-            if ( ! isset( $values[ $var ] ) ) {
168
+			if ( ! isset( $values[ $var ] ) ) {
169 169
 				$values[ $var ] = FrmAppHelper::get_param( $var, $default );
170
-            }
171
-        }
170
+			}
171
+		}
172 172
 
173
-        if ( ! isset( $values['form_key'] ) ) {
173
+		if ( ! isset( $values['form_key'] ) ) {
174 174
 			$values['form_key'] = ( $post_values && isset( $post_values['form_key'] ) ) ? $post_values['form_key'] : FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_forms', 'form_key' );
175
-        }
175
+		}
176 176
 
177 177
 		$values = self::fill_default_opts( $values, false, $post_values );
178 178
 		$values['custom_style'] = FrmAppHelper::custom_style_value( $post_values );
179 179
 
180
-        return apply_filters('frm_setup_new_form_vars', $values);
181
-    }
180
+		return apply_filters('frm_setup_new_form_vars', $values);
181
+	}
182 182
 
183
-    /**
184
-     * Used when editing a form
185
-     */
186
-    public static function setup_edit_vars( $values, $record, $post_values = array() ) {
183
+	/**
184
+	 * Used when editing a form
185
+	 */
186
+	public static function setup_edit_vars( $values, $record, $post_values = array() ) {
187 187
 		if ( empty( $post_values ) ) {
188 188
 			$post_values = stripslashes_deep( $_POST );
189 189
 		}
190 190
 
191
-        $values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key;
192
-        $values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template;
193
-        $values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template;
194
-        $values['status'] = $record->status;
191
+		$values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key;
192
+		$values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template;
193
+		$values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template;
194
+		$values['status'] = $record->status;
195 195
 
196
-        $values = self::fill_default_opts($values, $record, $post_values);
196
+		$values = self::fill_default_opts($values, $record, $post_values);
197 197
 
198
-        return apply_filters('frm_setup_edit_form_vars', $values);
199
-    }
198
+		return apply_filters('frm_setup_edit_form_vars', $values);
199
+	}
200 200
 
201 201
 	public static function fill_default_opts( $values, $record, $post_values ) {
202 202
 
203
-        $defaults = self::get_default_opts();
203
+		$defaults = self::get_default_opts();
204 204
 		foreach ( $defaults as $var => $default ) {
205
-            if ( is_array($default) ) {
206
-                if ( ! isset( $values[ $var ] ) ) {
205
+			if ( is_array($default) ) {
206
+				if ( ! isset( $values[ $var ] ) ) {
207 207
 					$values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array();
208
-                }
208
+				}
209 209
 
210
-                foreach ( $default as $k => $v ) {
210
+				foreach ( $default as $k => $v ) {
211 211
 					$values[ $var ][ $k ] = ( $post_values && isset( $post_values[ $var ][ $k ] ) ) ? $post_values[ $var ][ $k ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) ) ? $record->options[ $var ][ $k ] : $v);
212 212
 
213
-                    if ( is_array( $v ) ) {
214
-                        foreach ( $v as $k1 => $v1 ) {
213
+					if ( is_array( $v ) ) {
214
+						foreach ( $v as $k1 => $v1 ) {
215 215
 							$values[ $var ][ $k ][ $k1 ] = ( $post_values && isset( $post_values[ $var ][ $k ][ $k1 ] ) ) ? $post_values[ $var ][ $k ][ $k1 ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) && isset( $record->options[ $var ][ $k ][ $k1 ] ) ) ? $record->options[ $var ][ $k ][ $k1 ] : $v1 );
216
-                            unset( $k1, $v1 );
217
-                        }
218
-                    }
216
+							unset( $k1, $v1 );
217
+						}
218
+					}
219 219
 
220
-                    unset($k, $v);
221
-                }
222
-            } else {
220
+					unset($k, $v);
221
+				}
222
+			} else {
223 223
 				$values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default );
224
-            }
224
+			}
225 225
 
226
-            unset($var, $default);
227
-        }
226
+			unset($var, $default);
227
+		}
228 228
 
229
-        return $values;
230
-    }
229
+		return $values;
230
+	}
231 231
 
232
-    public static function get_default_opts() {
233
-        $frm_settings = FrmAppHelper::get_settings();
232
+	public static function get_default_opts() {
233
+		$frm_settings = FrmAppHelper::get_settings();
234 234
 
235
-        return array(
236
-            'submit_value' => $frm_settings->submit_value, 'success_action' => 'message',
237
-            'success_msg' => $frm_settings->success_msg, 'show_form' => 0, 'akismet' => '',
238
-            'no_save' => 0, 'ajax_load' => 0, 'form_class' => '', 'custom_style' => 1,
239
-            'before_html' => self::get_default_html('before'),
240
-            'after_html' => '',
241
-            'submit_html' => self::get_default_html('submit'),
242
-        );
243
-    }
235
+		return array(
236
+			'submit_value' => $frm_settings->submit_value, 'success_action' => 'message',
237
+			'success_msg' => $frm_settings->success_msg, 'show_form' => 0, 'akismet' => '',
238
+			'no_save' => 0, 'ajax_load' => 0, 'form_class' => '', 'custom_style' => 1,
239
+			'before_html' => self::get_default_html('before'),
240
+			'after_html' => '',
241
+			'submit_html' => self::get_default_html('submit'),
242
+		);
243
+	}
244 244
 
245 245
 	/**
246 246
 	 * @param array $options
@@ -255,13 +255,13 @@  discard block
 block discarded – undo
255 255
 		}
256 256
 	}
257 257
 
258
-    /**
259
-     * @param string $loc
260
-     */
258
+	/**
259
+	 * @param string $loc
260
+	 */
261 261
 	public static function get_default_html( $loc ) {
262 262
 		if ( $loc == 'submit' ) {
263
-            $draft_link = self::get_draft_link();
264
-            $default_html = <<<SUBMIT_HTML
263
+			$draft_link = self::get_draft_link();
264
+			$default_html = <<<SUBMIT_HTML
265 265
 <div class="frm_submit">
266 266
 [if back_button]<button type="submit" name="frm_prev_page" formnovalidate="formnovalidate" class="frm_prev_page" [back_hook]>[back_label]</button>[/if back_button]
267 267
 <button class="frm_button_submit" type="submit"  [button_action]>[button_label]</button>
@@ -269,22 +269,22 @@  discard block
 block discarded – undo
269 269
 </div>
270 270
 SUBMIT_HTML;
271 271
 		} else if ( $loc == 'before' ) {
272
-            $default_html = <<<BEFORE_HTML
272
+			$default_html = <<<BEFORE_HTML
273 273
 <legend class="frm_hidden">[form_name]</legend>
274 274
 [if form_name]<h3 class="frm_form_title">[form_name]</h3>[/if form_name]
275 275
 [if form_description]<div class="frm_description">[form_description]</div>[/if form_description]
276 276
 BEFORE_HTML;
277 277
 		} else {
278
-            $default_html = '';
279
-        }
278
+			$default_html = '';
279
+		}
280 280
 
281
-        return $default_html;
282
-    }
281
+		return $default_html;
282
+	}
283 283
 
284
-    public static function get_draft_link() {
285
-        $link = '[if save_draft]<a href="#" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]';
286
-        return $link;
287
-    }
284
+	public static function get_draft_link() {
285
+		$link = '[if save_draft]<a href="#" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]';
286
+		return $link;
287
+	}
288 288
 
289 289
 	public static function get_custom_submit( $html, $form, $submit, $form_action, $values ) {
290 290
 		$button = self::replace_shortcodes( $html, $form, $submit, $form_action, $values );
@@ -311,13 +311,13 @@  discard block
 block discarded – undo
311 311
 		echo $button_parts[1];
312 312
 	}
313 313
 
314
-    /**
315
-     * Automatically add end section fields if they don't exist (2.0 migration)
316
-     * @since 2.0
317
-     *
318
-     * @param boolean $reset_fields
319
-     */
320
-    public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) {
314
+	/**
315
+	 * Automatically add end section fields if they don't exist (2.0 migration)
316
+	 * @since 2.0
317
+	 *
318
+	 * @param boolean $reset_fields
319
+	 */
320
+	public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) {
321 321
 		if ( empty( $fields ) ) {
322 322
 			return;
323 323
 		}
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 		$prev_order = false;
328 328
 		$add_order = 0;
329 329
 		$last_field = false;
330
-        foreach ( $fields as $field ) {
330
+		foreach ( $fields as $field ) {
331 331
 			if ( $prev_order === $field->field_order ) {
332 332
 				$add_order++;
333 333
 			}
@@ -338,48 +338,48 @@  discard block
 block discarded – undo
338 338
 				FrmField::update( $field->id, array( 'field_order' => $field->field_order ) );
339 339
 			}
340 340
 
341
-            switch ( $field->type ) {
342
-                case 'divider':
343
-                    // create an end section if open
341
+			switch ( $field->type ) {
342
+				case 'divider':
343
+					// create an end section if open
344 344
 					self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' );
345 345
 
346
-                    // mark it open for the next end section
347
-                    $open = true;
348
-                break;
349
-                case 'break';
346
+					// mark it open for the next end section
347
+					$open = true;
348
+				break;
349
+				case 'break';
350 350
 					self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' );
351
-                break;
352
-                case 'end_divider':
353
-                    if ( ! $open ) {
354
-                        // the section isn't open, so this is an extra field that needs to be removed
355
-                        FrmField::destroy( $field->id );
356
-                        $reset_fields = true;
357
-                    }
358
-
359
-                    // There is already an end section here, so there is no need to create one
360
-                    $open = false;
361
-            }
351
+				break;
352
+				case 'end_divider':
353
+					if ( ! $open ) {
354
+						// the section isn't open, so this is an extra field that needs to be removed
355
+						FrmField::destroy( $field->id );
356
+						$reset_fields = true;
357
+					}
358
+
359
+					// There is already an end section here, so there is no need to create one
360
+					$open = false;
361
+			}
362 362
 			$prev_order = $field->field_order;
363 363
 
364 364
 			$last_field = $field;
365 365
 			unset( $field );
366
-        }
366
+		}
367 367
 
368 368
 		self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $last_field );
369
-    }
369
+	}
370 370
 
371 371
 	/**
372 372
 	 * Create end section field if it doesn't exist. This is for migration from < 2.0
373 373
 	 * Fix any ordering that may be messed up
374 374
 	 */
375 375
 	public static function maybe_create_end_section( &$open, &$reset_fields, &$add_order, $end_section_values, $field, $move = 'no' ) {
376
-        if ( ! $open ) {
377
-            return;
378
-        }
376
+		if ( ! $open ) {
377
+			return;
378
+		}
379 379
 
380 380
 		$end_section_values['field_order'] = $field->field_order + 1;
381 381
 
382
-        FrmField::create( $end_section_values );
382
+		FrmField::create( $end_section_values );
383 383
 
384 384
 		if ( $move == 'move' ) {
385 385
 			// bump the order of current field unless we're at the end of the form
@@ -387,39 +387,39 @@  discard block
 block discarded – undo
387 387
 		}
388 388
 
389 389
 		$add_order += 2;
390
-        $open = false;
391
-        $reset_fields = true;
392
-    }
390
+		$open = false;
391
+		$reset_fields = true;
392
+	}
393 393
 
394
-    public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) {
394
+	public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) {
395 395
 		foreach ( array( 'form_name' => $title, 'form_description' => $description, 'entry_key' => true ) as $code => $show ) {
396
-            if ( $code == 'form_name' ) {
397
-                $replace_with = $form->name;
398
-            } else if ( $code == 'form_description' ) {
399
-                $replace_with = FrmAppHelper::use_wpautop($form->description);
400
-            } else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) {
401
-                $replace_with = FrmAppHelper::simple_get( 'entry' );
402
-            } else {
403
-                $replace_with = '';
404
-            }
396
+			if ( $code == 'form_name' ) {
397
+				$replace_with = $form->name;
398
+			} else if ( $code == 'form_description' ) {
399
+				$replace_with = FrmAppHelper::use_wpautop($form->description);
400
+			} else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) {
401
+				$replace_with = FrmAppHelper::simple_get( 'entry' );
402
+			} else {
403
+				$replace_with = '';
404
+			}
405 405
 
406 406
 			FrmShortcodeHelper::remove_inline_conditions( ( FrmAppHelper::is_true( $show ) && $replace_with != '' ), $code, $replace_with, $html );
407
-        }
407
+		}
408 408
 
409
-        //replace [form_key]
410
-        $html = str_replace('[form_key]', $form->form_key, $html);
409
+		//replace [form_key]
410
+		$html = str_replace('[form_key]', $form->form_key, $html);
411 411
 
412
-        //replace [frmurl]
413
-        $html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html);
412
+		//replace [frmurl]
413
+		$html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html);
414 414
 
415 415
 		if ( strpos( $html, '[button_label]' ) ) {
416 416
 			add_filter( 'frm_submit_button', 'FrmFormsHelper::submit_button_label', 1 );
417 417
 			$submit_label = apply_filters( 'frm_submit_button', $title, $form );
418 418
 			$submit_label = esc_attr( do_shortcode( $submit_label ) );
419 419
 			$html = str_replace( '[button_label]', $submit_label, $html );
420
-        }
420
+		}
421 421
 
422
-        $html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values);
422
+		$html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values);
423 423
 
424 424
 		if ( strpos( $html, '[if back_button]' ) ) {
425 425
 			$html = preg_replace( '/(\[if\s+back_button\])(.*?)(\[\/if\s+back_button\])/mis', '', $html );
@@ -433,17 +433,17 @@  discard block
 block discarded – undo
433 433
 			$html = do_shortcode( $html );
434 434
 		}
435 435
 
436
-        return $html;
437
-    }
436
+		return $html;
437
+	}
438 438
 
439 439
 	public static function submit_button_label( $submit ) {
440
-        if ( ! $submit || empty($submit) ) {
441
-            $frm_settings = FrmAppHelper::get_settings();
442
-            $submit = $frm_settings->submit_value;
443
-        }
440
+		if ( ! $submit || empty($submit) ) {
441
+			$frm_settings = FrmAppHelper::get_settings();
442
+			$submit = $frm_settings->submit_value;
443
+		}
444 444
 
445
-        return $submit;
446
-    }
445
+		return $submit;
446
+	}
447 447
 
448 448
 	/**
449 449
 	 * If the Formidable styling isn't being loaded,
@@ -460,19 +460,19 @@  discard block
 block discarded – undo
460 460
 	}
461 461
 
462 462
 	public static function get_form_style_class( $form = false ) {
463
-        $style = self::get_form_style($form);
464
-        $class = ' with_frm_style';
465
-
466
-        if ( empty($style) ) {
467
-            if ( FrmAppHelper::is_admin_page('formidable-entries') ) {
468
-                return $class;
469
-            } else {
470
-                return;
471
-            }
472
-        }
473
-
474
-        //If submit button needs to be inline or centered
475
-        if ( is_object($form) ) {
463
+		$style = self::get_form_style($form);
464
+		$class = ' with_frm_style';
465
+
466
+		if ( empty($style) ) {
467
+			if ( FrmAppHelper::is_admin_page('formidable-entries') ) {
468
+				return $class;
469
+			} else {
470
+				return;
471
+			}
472
+		}
473
+
474
+		//If submit button needs to be inline or centered
475
+		if ( is_object($form) ) {
476 476
 			$form = $form->options;
477 477
 		}
478 478
 
@@ -484,17 +484,17 @@  discard block
 block discarded – undo
484 484
 			$class .= ' frm_center_submit';
485 485
 		}
486 486
 
487
-        $class = apply_filters('frm_add_form_style_class', $class, $style);
487
+		$class = apply_filters('frm_add_form_style_class', $class, $style);
488 488
 
489
-        return $class;
490
-    }
489
+		return $class;
490
+	}
491 491
 
492
-    /**
493
-     * @param string|boolean $form
494
-     *
495
-     * @return string
496
-     */
497
-    public static function get_form_style( $form ) {
492
+	/**
493
+	 * @param string|boolean $form
494
+	 *
495
+	 * @return string
496
+	 */
497
+	public static function get_form_style( $form ) {
498 498
 		$style = 1;
499 499
 		if ( empty( $form ) || 'default' == 'form' ) {
500 500
 			return $style;
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 		$style = ( $form && is_object( $form ) && isset( $form->options['custom_style'] ) ) ? $form->options['custom_style'] : $style;
515 515
 
516 516
 		return $style;
517
-    }
517
+	}
518 518
 
519 519
 	/**
520 520
 	 * Display the validation error messages when an entry is submitted
@@ -576,72 +576,72 @@  discard block
 block discarded – undo
576 576
 	}
577 577
 
578 578
 	public static function get_scroll_js( $form_id ) {
579
-        ?><script type="text/javascript">document.addEventListener('DOMContentLoaded',function(){frmFrontForm.scrollMsg(<?php echo (int) $form_id ?>);})</script><?php
580
-    }
579
+		?><script type="text/javascript">document.addEventListener('DOMContentLoaded',function(){frmFrontForm.scrollMsg(<?php echo (int) $form_id ?>);})</script><?php
580
+	}
581 581
 
582 582
 	public static function edit_form_link( $form_id ) {
583
-        if ( is_object($form_id) ) {
584
-            $form = $form_id;
585
-            $name = $form->name;
586
-            $form_id = $form->id;
587
-        } else {
588
-            $name = FrmForm::getName($form_id);
589
-        }
590
-
591
-        if ( $form_id ) {
583
+		if ( is_object($form_id) ) {
584
+			$form = $form_id;
585
+			$name = $form->name;
586
+			$form_id = $form->id;
587
+		} else {
588
+			$name = FrmForm::getName($form_id);
589
+		}
590
+
591
+		if ( $form_id ) {
592 592
 			$val = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ) ) . '">' . ( '' == $name ? __( '(no title)' ) : FrmAppHelper::truncate( $name, 40 ) ) . '</a>';
593
-	    } else {
594
-	        $val = '';
595
-	    }
593
+		} else {
594
+			$val = '';
595
+		}
596 596
 
597
-	    return $val;
597
+		return $val;
598 598
 	}
599 599
 
600 600
 	public static function delete_trash_link( $id, $status, $length = 'long' ) {
601
-        $link = '';
602
-        $labels = array(
603
-            'restore' => array(
604
-                'long'  => __( 'Restore from Trash', 'formidable' ),
605
-                'short' => __( 'Restore', 'formidable' ),
606
-            ),
607
-            'trash' => array(
608
-                'long'  => __( 'Move to Trash', 'formidable' ),
609
-                'short' => __( 'Trash', 'formidable' ),
610
-            ),
611
-            'delete' => array(
612
-                'long'  => __( 'Delete Permanently', 'formidable' ),
613
-                'short' => __( 'Delete', 'formidable' ),
614
-            ),
615
-        );
616
-
617
-        $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
601
+		$link = '';
602
+		$labels = array(
603
+			'restore' => array(
604
+				'long'  => __( 'Restore from Trash', 'formidable' ),
605
+				'short' => __( 'Restore', 'formidable' ),
606
+			),
607
+			'trash' => array(
608
+				'long'  => __( 'Move to Trash', 'formidable' ),
609
+				'short' => __( 'Trash', 'formidable' ),
610
+			),
611
+			'delete' => array(
612
+				'long'  => __( 'Delete Permanently', 'formidable' ),
613
+				'short' => __( 'Delete', 'formidable' ),
614
+			),
615
+		);
616
+
617
+		$current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
618 618
 		$base_url = '?page=formidable&form_type=' . $current_page . '&id=' . $id;
619
-        if ( 'trash' == $status ) {
619
+		if ( 'trash' == $status ) {
620 620
 			$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=untrash', 'untrash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['restore'][ $length ] . '</a>';
621
-        } else if ( current_user_can('frm_delete_forms') ) {
622
-            if ( EMPTY_TRASH_DAYS ) {
621
+		} else if ( current_user_can('frm_delete_forms') ) {
622
+			if ( EMPTY_TRASH_DAYS ) {
623 623
 				$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=trash', 'trash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['trash'][ $length ] . '</a>';
624
-            } else {
624
+			} else {
625 625
 				$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=destroy', 'destroy_form_' . $id ) ) . '" class="submitdelete deletion" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete this form and all its entries?', 'formidable' ) ) . '\')">' . $labels['delete'][ $length ] . '</a>';
626
-            }
627
-        }
626
+			}
627
+		}
628 628
 
629
-        return $link;
630
-    }
629
+		return $link;
630
+	}
631 631
 
632 632
 	public static function status_nice_name( $status ) {
633
-        $nice_names = array(
634
-            'draft'     => __( 'Draft', 'formidable' ),
635
-            'trash'     => __( 'Trash', 'formidable' ),
636
-            'publish'   => __( 'Published', 'formidable' ),
637
-        );
638
-
639
-        if ( ! in_array($status, array_keys($nice_names)) ) {
640
-            $status = 'publish';
641
-        }
633
+		$nice_names = array(
634
+			'draft'     => __( 'Draft', 'formidable' ),
635
+			'trash'     => __( 'Trash', 'formidable' ),
636
+			'publish'   => __( 'Published', 'formidable' ),
637
+		);
638
+
639
+		if ( ! in_array($status, array_keys($nice_names)) ) {
640
+			$status = 'publish';
641
+		}
642 642
 
643 643
 		$name = $nice_names[ $status ];
644 644
 
645
-        return $name;
646
-    }
645
+		return $name;
646
+	}
647 647
 }
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 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
 
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 	public static function get_direct_link( $key, $form = false ) {
16 16
 		$target_url = esc_url( admin_url( 'admin-ajax.php?action=frm_forms_preview&form=' . $key ) );
17
-        $target_url = apply_filters('frm_direct_link', $target_url, $key, $form);
17
+        $target_url = apply_filters( 'frm_direct_link', $target_url, $key, $form );
18 18
 
19 19
         return $target_url;
20 20
     }
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 			$query['id !'] = $args['exclude'];
40 40
         }
41 41
 
42
-        $where = apply_filters('frm_forms_dropdown', $query, $field_name);
42
+        $where = apply_filters( 'frm_forms_dropdown', $query, $field_name );
43 43
 		$forms = FrmForm::get_published_forms( $where, 999, $args['inc_children'] );
44 44
 		$add_html = array();
45 45
 		self::add_html_attr( $args['onchange'], 'onchange', $add_html );
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 		<?php } ?>
53 53
 		<?php foreach ( $forms as $form ) { ?>
54 54
 			<option value="<?php echo esc_attr( $form->id ); ?>" <?php selected( $field_value, $form->id ); ?>><?php
55
-				echo ( '' == $form->name ) ? esc_html__( '(no title)', 'formidable' ) : esc_html( FrmAppHelper::truncate( $form->name, 50 ) ) . ( $form->parent_form_id ? esc_html__( ' (child)', 'formidable' ) : '' ) ;
55
+				echo ( '' == $form->name ) ? esc_html__( '(no title)', 'formidable' ) : esc_html( FrmAppHelper::truncate( $form->name, 50 ) ) . ( $form->parent_form_id ? esc_html__( ' (child)', 'formidable' ) : '' );
56 56
 			?></option>
57 57
 		<?php } ?>
58 58
         </select>
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	public static function add_html_attr( $class, $param, &$add_html ) {
70 70
 		if ( ! empty( $class ) ) {
71
-			$add_html[ $param ] = sanitize_title( $param ) . '="' . esc_attr( trim( sanitize_text_field( $class ) ) ) . '"';
71
+			$add_html[$param] = sanitize_title( $param ) . '="' . esc_attr( trim( sanitize_text_field( $class ) ) ) . '"';
72 72
 		}
73 73
 	}
74 74
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 		$args = array( 'id' => 0, 'form' => 0 );
80 80
 		if ( isset( $_GET['id'] ) && ! isset( $_GET['form'] ) ) {
81 81
 			unset( $args['form'] );
82
-		} else if ( isset( $_GET['form']) && ! isset( $_GET['id'] ) ) {
82
+		} else if ( isset( $_GET['form'] ) && ! isset( $_GET['id'] ) ) {
83 83
 			unset( $args['id'] );
84 84
         }
85 85
 
@@ -87,11 +87,11 @@  discard block
 block discarded – undo
87 87
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy_all' ) ) ) {
88 88
             $args['frm_action'] = 'list';
89 89
             $args['form'] = 0;
90
-		} else if ( FrmAppHelper::is_admin_page('formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) {
90
+		} else if ( FrmAppHelper::is_admin_page( 'formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) {
91 91
             $args['frm_action'] = 'edit';
92 92
 		} else if ( isset( $_GET['post'] ) ) {
93 93
             $args['form'] = 0;
94
-            $base = admin_url('edit.php?post_type=frm_display');
94
+            $base = admin_url( 'edit.php?post_type=frm_display' );
95 95
         }
96 96
 
97 97
         ?>
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 			        $args['form'] = $form->id;
108 108
 				}
109 109
                 ?>
110
-				<li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)') : FrmAppHelper::truncate( $form->name, 60 ) ); ?></a></li>
110
+				<li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 60 ) ); ?></a></li>
111 111
 			<?php
112 112
 				unset( $form );
113 113
 			} ?>
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
     }
118 118
 
119 119
 	public static function get_sortable_classes( $col, $sort_col, $sort_dir ) {
120
-        echo ($sort_col == $col) ? 'sorted' : 'sortable';
121
-        echo ($sort_col == $col && $sort_dir == 'desc') ? ' asc' : ' desc';
120
+        echo ( $sort_col == $col ) ? 'sorted' : 'sortable';
121
+        echo ( $sort_col == $col && $sort_dir == 'desc' ) ? ' asc' : ' desc';
122 122
     }
123 123
 
124 124
 	/**
@@ -153,20 +153,20 @@  discard block
 block discarded – undo
153 153
             $post_values = $values;
154 154
         } else {
155 155
             $values = array();
156
-            $post_values = isset($_POST) ? $_POST : array();
156
+            $post_values = isset( $_POST ) ? $_POST : array();
157 157
         }
158 158
 
159 159
 		foreach ( array( 'name' => '', 'description' => '' ) as $var => $default ) {
160
-			if ( ! isset( $values[ $var ] ) ) {
161
-				$values[ $var ] = FrmAppHelper::get_param( $var, $default );
160
+			if ( ! isset( $values[$var] ) ) {
161
+				$values[$var] = FrmAppHelper::get_param( $var, $default );
162 162
             }
163 163
         }
164 164
 
165
-        $values['description'] = FrmAppHelper::use_wpautop($values['description']);
165
+        $values['description'] = FrmAppHelper::use_wpautop( $values['description'] );
166 166
 
167 167
 		foreach ( array( 'form_id' => '', 'logged_in' => '', 'editable' => '', 'default_template' => 0, 'is_template' => 0, 'status' => 'draft', 'parent_form_id' => 0 ) as $var => $default ) {
168
-            if ( ! isset( $values[ $var ] ) ) {
169
-				$values[ $var ] = FrmAppHelper::get_param( $var, $default );
168
+            if ( ! isset( $values[$var] ) ) {
169
+				$values[$var] = FrmAppHelper::get_param( $var, $default );
170 170
             }
171 171
         }
172 172
 
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 		$values = self::fill_default_opts( $values, false, $post_values );
178 178
 		$values['custom_style'] = FrmAppHelper::custom_style_value( $post_values );
179 179
 
180
-        return apply_filters('frm_setup_new_form_vars', $values);
180
+        return apply_filters( 'frm_setup_new_form_vars', $values );
181 181
     }
182 182
 
183 183
     /**
@@ -188,42 +188,42 @@  discard block
 block discarded – undo
188 188
 			$post_values = stripslashes_deep( $_POST );
189 189
 		}
190 190
 
191
-        $values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key;
192
-        $values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template;
193
-        $values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template;
191
+        $values['form_key'] = isset( $post_values['form_key'] ) ? $post_values['form_key'] : $record->form_key;
192
+        $values['default_template'] = isset( $post_values['default_template'] ) ? $post_values['default_template'] : $record->default_template;
193
+        $values['is_template'] = isset( $post_values['is_template'] ) ? $post_values['is_template'] : $record->is_template;
194 194
         $values['status'] = $record->status;
195 195
 
196
-        $values = self::fill_default_opts($values, $record, $post_values);
196
+        $values = self::fill_default_opts( $values, $record, $post_values );
197 197
 
198
-        return apply_filters('frm_setup_edit_form_vars', $values);
198
+        return apply_filters( 'frm_setup_edit_form_vars', $values );
199 199
     }
200 200
 
201 201
 	public static function fill_default_opts( $values, $record, $post_values ) {
202 202
 
203 203
         $defaults = self::get_default_opts();
204 204
 		foreach ( $defaults as $var => $default ) {
205
-            if ( is_array($default) ) {
206
-                if ( ! isset( $values[ $var ] ) ) {
207
-					$values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array();
205
+            if ( is_array( $default ) ) {
206
+                if ( ! isset( $values[$var] ) ) {
207
+					$values[$var] = ( $record && isset( $record->options[$var] ) ) ? $record->options[$var] : array();
208 208
                 }
209 209
 
210 210
                 foreach ( $default as $k => $v ) {
211
-					$values[ $var ][ $k ] = ( $post_values && isset( $post_values[ $var ][ $k ] ) ) ? $post_values[ $var ][ $k ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) ) ? $record->options[ $var ][ $k ] : $v);
211
+					$values[$var][$k] = ( $post_values && isset( $post_values[$var][$k] ) ) ? $post_values[$var][$k] : ( ( $record && isset( $record->options[$var] ) && isset( $record->options[$var][$k] ) ) ? $record->options[$var][$k] : $v );
212 212
 
213 213
                     if ( is_array( $v ) ) {
214 214
                         foreach ( $v as $k1 => $v1 ) {
215
-							$values[ $var ][ $k ][ $k1 ] = ( $post_values && isset( $post_values[ $var ][ $k ][ $k1 ] ) ) ? $post_values[ $var ][ $k ][ $k1 ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) && isset( $record->options[ $var ][ $k ][ $k1 ] ) ) ? $record->options[ $var ][ $k ][ $k1 ] : $v1 );
215
+							$values[$var][$k][$k1] = ( $post_values && isset( $post_values[$var][$k][$k1] ) ) ? $post_values[$var][$k][$k1] : ( ( $record && isset( $record->options[$var] ) && isset( $record->options[$var][$k] ) && isset( $record->options[$var][$k][$k1] ) ) ? $record->options[$var][$k][$k1] : $v1 );
216 216
                             unset( $k1, $v1 );
217 217
                         }
218 218
                     }
219 219
 
220
-                    unset($k, $v);
220
+                    unset( $k, $v );
221 221
                 }
222 222
             } else {
223
-				$values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default );
223
+				$values[$var] = ( $post_values && isset( $post_values['options'][$var] ) ) ? $post_values['options'][$var] : ( ( $record && isset( $record->options[$var] ) ) ? $record->options[$var] : $default );
224 224
             }
225 225
 
226
-            unset($var, $default);
226
+            unset( $var, $default );
227 227
         }
228 228
 
229 229
         return $values;
@@ -236,9 +236,9 @@  discard block
 block discarded – undo
236 236
             'submit_value' => $frm_settings->submit_value, 'success_action' => 'message',
237 237
             'success_msg' => $frm_settings->success_msg, 'show_form' => 0, 'akismet' => '',
238 238
             'no_save' => 0, 'ajax_load' => 0, 'form_class' => '', 'custom_style' => 1,
239
-            'before_html' => self::get_default_html('before'),
239
+            'before_html' => self::get_default_html( 'before' ),
240 240
             'after_html' => '',
241
-            'submit_html' => self::get_default_html('submit'),
241
+            'submit_html' => self::get_default_html( 'submit' ),
242 242
         );
243 243
     }
244 244
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	public static function fill_form_options( &$options, $values ) {
251 251
 		$defaults = self::get_default_opts();
252 252
 		foreach ( $defaults as $var => $default ) {
253
-			$options[ $var ] = isset( $values['options'][ $var ] ) ? $values['options'][ $var ] : $default;
253
+			$options[$var] = isset( $values['options'][$var] ) ? $values['options'][$var] : $default;
254 254
 			unset( $var, $default );
255 255
 		}
256 256
 	}
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 		$last_field = false;
330 330
         foreach ( $fields as $field ) {
331 331
 			if ( $prev_order === $field->field_order ) {
332
-				$add_order++;
332
+				$add_order ++;
333 333
 			}
334 334
 
335 335
 			if ( $add_order ) {
@@ -396,8 +396,8 @@  discard block
 block discarded – undo
396 396
             if ( $code == 'form_name' ) {
397 397
                 $replace_with = $form->name;
398 398
             } else if ( $code == 'form_description' ) {
399
-                $replace_with = FrmAppHelper::use_wpautop($form->description);
400
-            } else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) {
399
+                $replace_with = FrmAppHelper::use_wpautop( $form->description );
400
+            } else if ( $code == 'entry_key' && isset( $_GET ) && isset( $_GET['entry'] ) ) {
401 401
                 $replace_with = FrmAppHelper::simple_get( 'entry' );
402 402
             } else {
403 403
                 $replace_with = '';
@@ -407,10 +407,10 @@  discard block
 block discarded – undo
407 407
         }
408 408
 
409 409
         //replace [form_key]
410
-        $html = str_replace('[form_key]', $form->form_key, $html);
410
+        $html = str_replace( '[form_key]', $form->form_key, $html );
411 411
 
412 412
         //replace [frmurl]
413
-        $html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html);
413
+        $html = str_replace( '[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html );
414 414
 
415 415
 		if ( strpos( $html, '[button_label]' ) ) {
416 416
 			add_filter( 'frm_submit_button', 'FrmFormsHelper::submit_button_label', 1 );
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 			$html = str_replace( '[button_label]', $submit_label, $html );
420 420
         }
421 421
 
422
-        $html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values);
422
+        $html = apply_filters( 'frm_form_replace_shortcodes', $html, $form, $values );
423 423
 
424 424
 		if ( strpos( $html, '[if back_button]' ) ) {
425 425
 			$html = preg_replace( '/(\[if\s+back_button\])(.*?)(\[\/if\s+back_button\])/mis', '', $html );
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
     }
438 438
 
439 439
 	public static function submit_button_label( $submit ) {
440
-        if ( ! $submit || empty($submit) ) {
440
+        if ( ! $submit || empty( $submit ) ) {
441 441
             $frm_settings = FrmAppHelper::get_settings();
442 442
             $submit = $frm_settings->submit_value;
443 443
         }
@@ -460,11 +460,11 @@  discard block
 block discarded – undo
460 460
 	}
461 461
 
462 462
 	public static function get_form_style_class( $form = false ) {
463
-        $style = self::get_form_style($form);
463
+        $style = self::get_form_style( $form );
464 464
         $class = ' with_frm_style';
465 465
 
466
-        if ( empty($style) ) {
467
-            if ( FrmAppHelper::is_admin_page('formidable-entries') ) {
466
+        if ( empty( $style ) ) {
467
+            if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) ) {
468 468
                 return $class;
469 469
             } else {
470 470
                 return;
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
         }
473 473
 
474 474
         //If submit button needs to be inline or centered
475
-        if ( is_object($form) ) {
475
+        if ( is_object( $form ) ) {
476 476
 			$form = $form->options;
477 477
 		}
478 478
 
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 			$class .= ' frm_center_submit';
485 485
 		}
486 486
 
487
-        $class = apply_filters('frm_add_form_style_class', $class, $style);
487
+        $class = apply_filters( 'frm_add_form_style_class', $class, $style );
488 488
 
489 489
         return $class;
490 490
     }
@@ -580,12 +580,12 @@  discard block
 block discarded – undo
580 580
     }
581 581
 
582 582
 	public static function edit_form_link( $form_id ) {
583
-        if ( is_object($form_id) ) {
583
+        if ( is_object( $form_id ) ) {
584 584
             $form = $form_id;
585 585
             $name = $form->name;
586 586
             $form_id = $form->id;
587 587
         } else {
588
-            $name = FrmForm::getName($form_id);
588
+            $name = FrmForm::getName( $form_id );
589 589
         }
590 590
 
591 591
         if ( $form_id ) {
@@ -617,12 +617,12 @@  discard block
 block discarded – undo
617 617
         $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
618 618
 		$base_url = '?page=formidable&form_type=' . $current_page . '&id=' . $id;
619 619
         if ( 'trash' == $status ) {
620
-			$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=untrash', 'untrash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['restore'][ $length ] . '</a>';
621
-        } else if ( current_user_can('frm_delete_forms') ) {
620
+			$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=untrash', 'untrash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['restore'][$length] . '</a>';
621
+        } else if ( current_user_can( 'frm_delete_forms' ) ) {
622 622
             if ( EMPTY_TRASH_DAYS ) {
623
-				$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=trash', 'trash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['trash'][ $length ] . '</a>';
623
+				$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=trash', 'trash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['trash'][$length] . '</a>';
624 624
             } else {
625
-				$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=destroy', 'destroy_form_' . $id ) ) . '" class="submitdelete deletion" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete this form and all its entries?', 'formidable' ) ) . '\')">' . $labels['delete'][ $length ] . '</a>';
625
+				$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=destroy', 'destroy_form_' . $id ) ) . '" class="submitdelete deletion" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete this form and all its entries?', 'formidable' ) ) . '\')">' . $labels['delete'][$length] . '</a>';
626 626
             }
627 627
         }
628 628
 
@@ -636,11 +636,11 @@  discard block
 block discarded – undo
636 636
             'publish'   => __( 'Published', 'formidable' ),
637 637
         );
638 638
 
639
-        if ( ! in_array($status, array_keys($nice_names)) ) {
639
+        if ( ! in_array( $status, array_keys( $nice_names ) ) ) {
640 640
             $status = 'publish';
641 641
         }
642 642
 
643
-		$name = $nice_names[ $status ];
643
+		$name = $nice_names[$status];
644 644
 
645 645
         return $name;
646 646
     }
Please login to merge, or discard this patch.