Completed
Push — master ( 3e76a9...b1aab9 )
by Stephanie
05:04 queued 01:19
created
classes/helpers/FrmFieldsHelper.php 2 patches
Indentation   +236 added lines, -236 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 );
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 ) {
45 45
 		$values = (array) $field;
@@ -239,18 +239,18 @@  discard block
 block discarded – undo
239 239
 		return $field_type->get_new_field_defaults();
240 240
 	}
241 241
 
242
-    public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
243
-        global $wpdb;
242
+	public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
243
+		global $wpdb;
244 244
 
245 245
 		$values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' );
246
-        $values['form_id'] = $form_id;
247
-        $values['options'] = maybe_serialize($field->options);
248
-        $values['default_value'] = maybe_serialize($field->default_value);
246
+		$values['form_id'] = $form_id;
247
+		$values['options'] = maybe_serialize($field->options);
248
+		$values['default_value'] = maybe_serialize($field->default_value);
249 249
 
250
-        foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
251
-            $values[ $col ] = $field->{$col};
252
-        }
253
-    }
250
+		foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
251
+			$values[ $col ] = $field->{$col};
252
+		}
253
+	}
254 254
 
255 255
 	/**
256 256
 	 * @since 2.0
@@ -405,8 +405,8 @@  discard block
 block discarded – undo
405 405
 	 */
406 406
 	public static function get_shortcode_tag( $shortcodes, $short_key, $args ) {
407 407
 		_deprecated_function( __FUNCTION__, '3.0', 'FrmShortcodeHelper::get_shortcode_tag' );
408
-        return FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key, $args );
409
-    }
408
+		return FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key, $args );
409
+	}
410 410
 
411 411
 	public static function get_checkbox_id( $field, $opt_key ) {
412 412
 		$id = $field['id'];
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 	 */
423 423
 	public static function display_recaptcha( $field ) {
424 424
 		_deprecated_function( __FUNCTION__, '3.0', 'FrmFieldCaptcha::field_input' );
425
-    }
425
+	}
426 426
 
427 427
 	public static function show_single_option( $field ) {
428 428
 		if ( ! is_array( $field['options'] ) ) {
@@ -433,26 +433,26 @@  discard block
 block discarded – undo
433 433
 		$html_id = isset( $field['html_id'] ) ? $field['html_id'] : self::get_html_id( $field );
434 434
 
435 435
 		foreach ( $field['options'] as $opt_key => $opt ) {
436
-		    $field_val = self::get_value_from_array( $opt, $opt_key, $field );
437
-		    $opt = self::get_label_from_array( $opt, $opt_key, $field );
436
+			$field_val = self::get_value_from_array( $opt, $opt_key, $field );
437
+			$opt = self::get_label_from_array( $opt, $opt_key, $field );
438 438
 
439 439
 			// Get string for Other text field, if needed
440 440
 			$other_val = self::get_other_val( compact( 'opt_key', 'field' ) );
441 441
 
442 442
 			$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"' : '';
443 443
 
444
-		    // If this is an "Other" option, get the HTML for it
444
+			// If this is an "Other" option, get the HTML for it
445 445
 			if ( self::is_other_opt( $opt_key ) ) {
446 446
 				if ( FrmAppHelper::pro_is_installed() ) {
447 447
 					require( FrmProAppHelper::plugin_path() . '/classes/views/frmpro-fields/other-option.php' );
448 448
 				}
449
-		    } else {
449
+			} else {
450 450
 				require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
451
-		    }
451
+			}
452 452
 
453 453
 			unset( $checked, $other_val );
454 454
 		}
455
-    }
455
+	}
456 456
 
457 457
 	public static function get_value_from_array( $opt, $opt_key, $field ) {
458 458
 		$opt = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
@@ -470,29 +470,29 @@  discard block
 block discarded – undo
470 470
 	 * @return string
471 471
 	 */
472 472
 	public static function get_term_link( $tax_id ) {
473
-        $tax = get_taxonomy($tax_id);
474
-        if ( ! $tax ) {
475
-            return '';
476
-        }
473
+		$tax = get_taxonomy($tax_id);
474
+		if ( ! $tax ) {
475
+			return '';
476
+		}
477 477
 
478
-        $link = sprintf(
479
-            __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
478
+		$link = sprintf(
479
+			__( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
480 480
 			'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
481
-        );
482
-        unset($tax);
481
+		);
482
+		unset($tax);
483 483
 
484
-        return $link;
485
-    }
484
+		return $link;
485
+	}
486 486
 
487 487
 	public static function value_meets_condition( $observed_value, $cond, $hide_opt ) {
488 488
 		$hide_opt = self::get_value_for_comparision( $hide_opt );
489 489
 		$observed_value = self::get_value_for_comparision( $observed_value );
490 490
 
491
-        if ( is_array($observed_value) ) {
492
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
493
-        }
491
+		if ( is_array($observed_value) ) {
492
+			return self::array_value_condition($observed_value, $cond, $hide_opt);
493
+		}
494 494
 
495
-        $m = false;
495
+		$m = false;
496 496
 		if ( $cond == '==' ) {
497 497
 			$m = $observed_value == $hide_opt;
498 498
 		} elseif ( $cond == '!=' ) {
@@ -513,8 +513,8 @@  discard block
 block discarded – undo
513 513
 				$m = ( $m === false ) ? false : true;
514 514
 			}
515 515
 		}
516
-        return $m;
517
-    }
516
+		return $m;
517
+	}
518 518
 
519 519
 	/**
520 520
 	 * Trim and sanitize the values
@@ -530,87 +530,87 @@  discard block
 block discarded – undo
530 530
 	}
531 531
 
532 532
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
533
-        $m = false;
534
-        if ( $cond == '==' ) {
535
-            if ( is_array($hide_opt) ) {
536
-                $m = array_intersect($hide_opt, $observed_value);
537
-                $m = empty($m) ? false : true;
538
-            } else {
539
-                $m = in_array($hide_opt, $observed_value);
540
-            }
541
-        } else if ( $cond == '!=' ) {
542
-            $m = ! in_array($hide_opt, $observed_value);
543
-        } else if ( $cond == '>' ) {
544
-            $min = min($observed_value);
545
-            $m = $min > $hide_opt;
546
-        } else if ( $cond == '<' ) {
547
-            $max = max($observed_value);
548
-            $m = $max < $hide_opt;
549
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
550
-            foreach ( $observed_value as $ob ) {
551
-                $m = strpos($ob, $hide_opt);
552
-                if ( $m !== false ) {
553
-                    $m = true;
554
-                    break;
555
-                }
556
-            }
557
-
558
-            if ( $cond == 'not LIKE' ) {
559
-                $m = ( $m === false ) ? true : false;
560
-            }
561
-        }
562
-
563
-        return $m;
564
-    }
565
-
566
-    /**
567
-     * Replace a few basic shortcodes and field ids
568
-     * @since 2.0
569
-     * @return string
570
-     */
533
+		$m = false;
534
+		if ( $cond == '==' ) {
535
+			if ( is_array($hide_opt) ) {
536
+				$m = array_intersect($hide_opt, $observed_value);
537
+				$m = empty($m) ? false : true;
538
+			} else {
539
+				$m = in_array($hide_opt, $observed_value);
540
+			}
541
+		} else if ( $cond == '!=' ) {
542
+			$m = ! in_array($hide_opt, $observed_value);
543
+		} else if ( $cond == '>' ) {
544
+			$min = min($observed_value);
545
+			$m = $min > $hide_opt;
546
+		} else if ( $cond == '<' ) {
547
+			$max = max($observed_value);
548
+			$m = $max < $hide_opt;
549
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
550
+			foreach ( $observed_value as $ob ) {
551
+				$m = strpos($ob, $hide_opt);
552
+				if ( $m !== false ) {
553
+					$m = true;
554
+					break;
555
+				}
556
+			}
557
+
558
+			if ( $cond == 'not LIKE' ) {
559
+				$m = ( $m === false ) ? true : false;
560
+			}
561
+		}
562
+
563
+		return $m;
564
+	}
565
+
566
+	/**
567
+	 * Replace a few basic shortcodes and field ids
568
+	 * @since 2.0
569
+	 * @return string
570
+	 */
571 571
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
572
-        if ( strpos($value, '[sitename]') !== false ) {
573
-            $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
574
-            $value = str_replace('[sitename]', $new_value, $value);
575
-        }
572
+		if ( strpos($value, '[sitename]') !== false ) {
573
+			$new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
574
+			$value = str_replace('[sitename]', $new_value, $value);
575
+		}
576 576
 
577
-        $value = apply_filters('frm_content', $value, $form, $entry);
578
-        $value = do_shortcode($value);
577
+		$value = apply_filters('frm_content', $value, $form, $entry);
578
+		$value = do_shortcode($value);
579 579
 
580
-        return $value;
581
-    }
580
+		return $value;
581
+	}
582 582
 
583 583
 	public static function get_shortcodes( $content, $form_id ) {
584
-        if ( FrmAppHelper::pro_is_installed() ) {
585
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
586
-        }
584
+		if ( FrmAppHelper::pro_is_installed() ) {
585
+			return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
586
+		}
587 587
 
588 588
 		$fields = FrmField::getAll( array(
589 589
 			'fi.form_id'  => (int) $form_id,
590 590
 			'fi.type not' => FrmField::no_save_fields(),
591 591
 		) );
592 592
 
593
-        $tagregexp = self::allowed_shortcodes($fields);
593
+		$tagregexp = self::allowed_shortcodes($fields);
594 594
 
595
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
595
+		preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
596 596
 
597
-        return $matches;
598
-    }
597
+		return $matches;
598
+	}
599 599
 
600 600
 	public static function allowed_shortcodes( $fields = array() ) {
601 601
 		$tagregexp = array( 'editlink', 'id', 'key', 'ip', 'siteurl', 'sitename', 'admin_email', 'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by', 'parent[-|_]id' );
602 602
 
603
-        foreach ( $fields as $field ) {
604
-            $tagregexp[] = $field->id;
605
-            $tagregexp[] = $field->field_key;
606
-        }
603
+		foreach ( $fields as $field ) {
604
+			$tagregexp[] = $field->id;
605
+			$tagregexp[] = $field->field_key;
606
+		}
607 607
 
608
-        $tagregexp = implode('|', $tagregexp);
609
-        return $tagregexp;
610
-    }
608
+		$tagregexp = implode('|', $tagregexp);
609
+		return $tagregexp;
610
+	}
611 611
 
612 612
 	public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
613
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
613
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
614 614
 			if ( empty( $tag ) ) {
615 615
 				continue;
616 616
 			}
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
 		}
632 632
 
633 633
 		return $content;
634
-    }
634
+	}
635 635
 
636 636
 	/**
637 637
 	 * @since 3.0
@@ -725,67 +725,67 @@  discard block
 block discarded – undo
725 725
 		return $replace_with;
726 726
 	}
727 727
 
728
-    /**
729
-     * Get the value to replace a few standard shortcodes
730
-     *
731
-     * @since 2.0
732
-     * @return string
733
-     */
734
-    public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
735
-        $new_value = '';
736
-        switch ( $tag ) {
737
-            case 'admin_email':
738
-                $new_value = get_option('admin_email');
739
-                break;
740
-            case 'siteurl':
741
-                $new_value = FrmAppHelper::site_url();
742
-                break;
743
-            case 'frmurl':
744
-                $new_value = FrmAppHelper::plugin_url();
745
-                break;
746
-            case 'sitename':
747
-                $new_value = FrmAppHelper::site_name();
748
-                break;
749
-            case 'get':
750
-                $new_value = self::process_get_shortcode( $atts, $return_array );
751
-        }
752
-
753
-        return $new_value;
754
-    }
755
-
756
-    /**
757
-     * Process the [get] shortcode
758
-     *
759
-     * @since 2.0
760
-     * @return string|array
761
-     */
762
-    public static function process_get_shortcode( $atts, $return_array = false ) {
763
-        if ( ! isset($atts['param']) ) {
764
-            return '';
765
-        }
766
-
767
-        if ( strpos($atts['param'], '&#91;') ) {
768
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
769
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
770
-        }
728
+	/**
729
+	 * Get the value to replace a few standard shortcodes
730
+	 *
731
+	 * @since 2.0
732
+	 * @return string
733
+	 */
734
+	public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
735
+		$new_value = '';
736
+		switch ( $tag ) {
737
+			case 'admin_email':
738
+				$new_value = get_option('admin_email');
739
+				break;
740
+			case 'siteurl':
741
+				$new_value = FrmAppHelper::site_url();
742
+				break;
743
+			case 'frmurl':
744
+				$new_value = FrmAppHelper::plugin_url();
745
+				break;
746
+			case 'sitename':
747
+				$new_value = FrmAppHelper::site_name();
748
+				break;
749
+			case 'get':
750
+				$new_value = self::process_get_shortcode( $atts, $return_array );
751
+		}
752
+
753
+		return $new_value;
754
+	}
755
+
756
+	/**
757
+	 * Process the [get] shortcode
758
+	 *
759
+	 * @since 2.0
760
+	 * @return string|array
761
+	 */
762
+	public static function process_get_shortcode( $atts, $return_array = false ) {
763
+		if ( ! isset($atts['param']) ) {
764
+			return '';
765
+		}
766
+
767
+		if ( strpos($atts['param'], '&#91;') ) {
768
+			$atts['param'] = str_replace('&#91;', '[', $atts['param']);
769
+			$atts['param'] = str_replace('&#93;', ']', $atts['param']);
770
+		}
771 771
 
772 772
 		$new_value = FrmAppHelper::get_param( $atts['param'], '', 'get', 'sanitize_text_field' );
773
-        $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
773
+		$new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
774 774
 
775
-        if ( $new_value == '' ) {
776
-            if ( ! isset($atts['prev_val']) ) {
777
-                $atts['prev_val'] = '';
778
-            }
775
+		if ( $new_value == '' ) {
776
+			if ( ! isset($atts['prev_val']) ) {
777
+				$atts['prev_val'] = '';
778
+			}
779 779
 
780
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
781
-        }
780
+			$new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
781
+		}
782 782
 
783
-        if ( is_array($new_value) && ! $return_array ) {
784
-            $new_value = implode(', ', $new_value);
785
-        }
783
+		if ( is_array($new_value) && ! $return_array ) {
784
+			$new_value = implode(', ', $new_value);
785
+		}
786 786
 
787
-        return $new_value;
788
-    }
787
+		return $new_value;
788
+	}
789 789
 
790 790
 	public static function get_display_value( $value, $field, $atts = array() ) {
791 791
 
@@ -855,27 +855,27 @@  discard block
 block discarded – undo
855 855
 
856 856
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
857 857
 
858
-        $field_types = array();
859
-        if ( in_array($type, $single_input) ) {
860
-            self::field_types_for_input( $single_input, $field_selection, $field_types );
861
-        } else if ( in_array($type, $multiple_input) ) {
862
-            self::field_types_for_input( $multiple_input, $field_selection, $field_types );
863
-        } else if ( in_array($type, $other_type) ) {
864
-            self::field_types_for_input( $other_type, $field_selection, $field_types );
858
+		$field_types = array();
859
+		if ( in_array($type, $single_input) ) {
860
+			self::field_types_for_input( $single_input, $field_selection, $field_types );
861
+		} else if ( in_array($type, $multiple_input) ) {
862
+			self::field_types_for_input( $multiple_input, $field_selection, $field_types );
863
+		} else if ( in_array($type, $other_type) ) {
864
+			self::field_types_for_input( $other_type, $field_selection, $field_types );
865 865
 		} else if ( isset( $field_selection[ $type ] ) ) {
866
-            $field_types[ $type ] = $field_selection[ $type ];
867
-        }
866
+			$field_types[ $type ] = $field_selection[ $type ];
867
+		}
868 868
 
869 869
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
870
-        return $field_types;
871
-    }
870
+		return $field_types;
871
+	}
872 872
 
873
-    private static function field_types_for_input( $inputs, $fields, &$field_types ) {
874
-        foreach ( $inputs as $input ) {
875
-            $field_types[ $input ] = $fields[ $input ];
876
-            unset($input);
877
-        }
878
-    }
873
+	private static function field_types_for_input( $inputs, $fields, &$field_types ) {
874
+		foreach ( $inputs as $input ) {
875
+			$field_types[ $input ] = $fields[ $input ];
876
+			unset($input);
877
+		}
878
+	}
879 879
 
880 880
 	/**
881 881
 	 * Check if current field option is an "other" option
@@ -889,14 +889,14 @@  discard block
 block discarded – undo
889 889
 		return $opt_key && strpos( $opt_key, 'other_' ) === 0;
890 890
 	}
891 891
 
892
-    /**
893
-    * Get value that belongs in "Other" text box
894
-    *
895
-    * @since 2.0.6
896
-    *
897
-    * @param array $args
898
-    */
899
-    public static function get_other_val( $args ) {
892
+	/**
893
+	 * Get value that belongs in "Other" text box
894
+	 *
895
+	 * @since 2.0.6
896
+	 *
897
+	 * @param array $args
898
+	 */
899
+	public static function get_other_val( $args ) {
900 900
 		$defaults = array(
901 901
 			'opt_key' => 0,
902 902
 			'field'   => array(),
@@ -974,20 +974,20 @@  discard block
 block discarded – undo
974 974
 		}
975 975
 
976 976
 		return $other_val;
977
-    }
978
-
979
-    /**
980
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
981
-    * Intended for front-end use
982
-    *
983
-    * @since 2.0.6
984
-    *
985
-    * @param array $args should include field, opt_key and field name
986
-    * @param boolean $other_opt
987
-    * @param string $checked
988
-    * @return array $other_args
989
-    */
990
-    public static function prepare_other_input( $args, &$other_opt, &$checked ) {
977
+	}
978
+
979
+	/**
980
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
981
+	 * Intended for front-end use
982
+	 *
983
+	 * @since 2.0.6
984
+	 *
985
+	 * @param array $args should include field, opt_key and field name
986
+	 * @param boolean $other_opt
987
+	 * @param string $checked
988
+	 * @return array $other_args
989
+	 */
990
+	public static function prepare_other_input( $args, &$other_opt, &$checked ) {
991 991
 		//Check if this is an "Other" option
992 992
 		if ( ! self::is_other_opt( $args['opt_key'] ) ) {
993 993
 			return;
@@ -1003,8 +1003,8 @@  discard block
 block discarded – undo
1003 1003
 			$checked = 'checked="checked" ';
1004 1004
 		}
1005 1005
 
1006
-        return $other_args;
1007
-    }
1006
+		return $other_args;
1007
+	}
1008 1008
 
1009 1009
 	/**
1010 1010
 	 * @param array $args
@@ -1059,8 +1059,8 @@  discard block
 block discarded – undo
1059 1059
 	 * @since 2.0.6
1060 1060
 	 */
1061 1061
 	public static function include_other_input( $args ) {
1062
-        if ( ! $args['other_opt'] ) {
1063
-        	return;
1062
+		if ( ! $args['other_opt'] ) {
1063
+			return;
1064 1064
 		}
1065 1065
 
1066 1066
 		$classes = array( 'frm_other_input' );
@@ -1085,15 +1085,15 @@  discard block
 block discarded – undo
1085 1085
 	}
1086 1086
 
1087 1087
 	/**
1088
-	* Get the HTML id for an "Other" text field
1089
-	* Note: This does not affect fields in repeating sections
1090
-	*
1091
-	* @since 2.0.08
1092
-	* @param string $type - field type
1093
-	* @param string $html_id
1094
-	* @param string|boolean $opt_key
1095
-	* @return string $other_id
1096
-	*/
1088
+	 * Get the HTML id for an "Other" text field
1089
+	 * Note: This does not affect fields in repeating sections
1090
+	 *
1091
+	 * @since 2.0.08
1092
+	 * @param string $type - field type
1093
+	 * @param string $html_id
1094
+	 * @param string|boolean $opt_key
1095
+	 * @return string $other_id
1096
+	 */
1097 1097
 	public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) {
1098 1098
 		$other_id = $html_id;
1099 1099
 
@@ -1157,10 +1157,10 @@  discard block
 block discarded – undo
1157 1157
 	}
1158 1158
 
1159 1159
 	public static function switch_field_ids( $val ) {
1160
-        global $frm_duplicate_ids;
1161
-        $replace = array();
1162
-        $replace_with = array();
1163
-        foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1160
+		global $frm_duplicate_ids;
1161
+		$replace = array();
1162
+		$replace_with = array();
1163
+		foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1164 1164
 			$replace[] = '[if ' . $old . ']';
1165 1165
 			$replace_with[] = '[if ' . $new . ']';
1166 1166
 			$replace[] = '[if ' . $old . ' ';
@@ -1175,19 +1175,19 @@  discard block
 block discarded – undo
1175 1175
 			$replace_with[] = '[' . $new . ']';
1176 1176
 			$replace[] = '[' . $old . ' ';
1177 1177
 			$replace_with[] = '[' . $new . ' ';
1178
-            unset($old, $new);
1179
-        }
1178
+			unset($old, $new);
1179
+		}
1180 1180
 		if ( is_array( $val ) ) {
1181 1181
 			foreach ( $val as $k => $v ) {
1182
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1183
-                unset($k, $v);
1184
-            }
1185
-        } else {
1186
-            $val = str_replace($replace, $replace_with, $val);
1187
-        }
1182
+				$val[ $k ] = str_replace( $replace, $replace_with, $v );
1183
+				unset($k, $v);
1184
+			}
1185
+		} else {
1186
+			$val = str_replace($replace, $replace_with, $val);
1187
+		}
1188 1188
 
1189
-        return $val;
1190
-    }
1189
+		return $val;
1190
+	}
1191 1191
 
1192 1192
 	public static function get_us_states() {
1193 1193
 		return apply_filters( 'frm_us_states', array(
@@ -1252,15 +1252,15 @@  discard block
 block discarded – undo
1252 1252
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1253 1253
 		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1254 1254
 
1255
-        $states = FrmFieldsHelper::get_us_states();
1256
-        $state_abv = array_keys($states);
1257
-        sort($state_abv);
1255
+		$states = FrmFieldsHelper::get_us_states();
1256
+		$state_abv = array_keys($states);
1257
+		sort($state_abv);
1258 1258
 		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1259 1259
 
1260
-        $states = array_values($states);
1261
-        sort($states);
1260
+		$states = array_values($states);
1261
+		sort($states);
1262 1262
 		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1263
-        unset($state_abv, $states);
1263
+		unset($state_abv, $states);
1264 1264
 
1265 1265
 		$prepop[ __( 'Age', 'formidable' ) ] = array(
1266 1266
 			__( 'Under 18', 'formidable' ),
@@ -1301,7 +1301,7 @@  discard block
 block discarded – undo
1301 1301
 		);
1302 1302
 
1303 1303
 		$prepop = apply_filters( 'frm_bulk_field_choices', $prepop );
1304
-    }
1304
+	}
1305 1305
 
1306 1306
 	/**
1307 1307
 	 * Display a field value selector
@@ -1311,10 +1311,10 @@  discard block
 block discarded – undo
1311 1311
 	 * @param int $selector_field_id
1312 1312
 	 * @param array $selector_args
1313 1313
 	 */
1314
-    public static function display_field_value_selector( $selector_field_id, $selector_args ) {
1315
-	    $field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args );
1316
-	    $field_value_selector->display();
1317
-    }
1314
+	public static function display_field_value_selector( $selector_field_id, $selector_args ) {
1315
+		$field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args );
1316
+		$field_value_selector->display();
1317
+	}
1318 1318
 
1319 1319
 	/**
1320 1320
 	 * Convert a field object to a flat array
Please login to merge, or discard this patch.
Spacing   +89 added lines, -89 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
 
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
 		}
128 128
 
129 129
 		foreach ( $defaults as $opt => $default ) {
130
-			$values[ $opt ] = isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default;
130
+			$values[$opt] = isset( $field->field_options[$opt] ) ? $field->field_options[$opt] : $default;
131 131
 
132 132
 			if ( $check_post ) {
133
-				self::get_posted_field_setting( $opt . '_' . $field->id, $values[ $opt ] );
133
+				self::get_posted_field_setting( $opt . '_' . $field->id, $values[$opt] );
134 134
 			}
135 135
 
136 136
 			unset( $opt, $default );
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
 	 * @param mixed $value
174 174
 	 */
175 175
 	private static function get_posted_field_setting( $setting, &$value ) {
176
-		if ( isset( $_POST['field_options'][ $setting ] ) ) {
177
-			$value = maybe_unserialize( $_POST['field_options'][ $setting ] );
176
+		if ( isset( $_POST['field_options'][$setting] ) ) {
177
+			$value = maybe_unserialize( $_POST['field_options'][$setting] );
178 178
 			if ( strpos( $setting, 'html' ) !== false ) {
179 179
 				// strip slashes from HTML but not regex
180 180
 				$value = stripslashes_deep( $value );
@@ -244,11 +244,11 @@  discard block
 block discarded – undo
244 244
 
245 245
 		$values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' );
246 246
         $values['form_id'] = $form_id;
247
-        $values['options'] = maybe_serialize($field->options);
248
-        $values['default_value'] = maybe_serialize($field->default_value);
247
+        $values['options'] = maybe_serialize( $field->options );
248
+        $values['default_value'] = maybe_serialize( $field->default_value );
249 249
 
250 250
         foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
251
-            $values[ $col ] = $field->{$col};
251
+            $values[$col] = $field->{$col};
252 252
         }
253 253
     }
254 254
 
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
 		$defaults = array(
270 270
 			'unique_msg' => array(
271 271
 				'full' => $default_settings['unique_msg'],
272
-				'part' => sprintf( __('%s must be unique', 'formidable' ), $field_name ),
272
+				'part' => sprintf( __( '%s must be unique', 'formidable' ), $field_name ),
273 273
 			),
274 274
 			'invalid'  => array(
275 275
 				'full' => __( 'This field is invalid', 'formidable' ),
276
-				'part' => sprintf( __('%s is invalid', 'formidable' ), $field_name ),
276
+				'part' => sprintf( __( '%s is invalid', 'formidable' ), $field_name ),
277 277
 			),
278 278
 			'blank'    => array(
279 279
 				'full' => $frm_settings->blank_msg,
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 		);
287 287
 
288 288
 		$msg = FrmField::get_option( $field, $error );
289
-		$msg = empty( $msg ) ? $defaults[ $error ]['part'] : $msg;
289
+		$msg = empty( $msg ) ? $defaults[$error]['part'] : $msg;
290 290
 		$msg = do_shortcode( $msg );
291 291
 		return $msg;
292 292
 	}
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 			$default_html = apply_filters( 'frm_other_custom_html', '', $type );
306 306
 		}
307 307
 
308
-		return apply_filters('frm_custom_html', $default_html, $type);
308
+		return apply_filters( 'frm_custom_html', $default_html, $type );
309 309
 	}
310 310
 
311 311
 	/**
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 			// Get string for Other text field, if needed
440 440
 			$other_val = self::get_other_val( compact( 'opt_key', 'field' ) );
441 441
 
442
-			$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"' : '';
442
+			$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"' : '';
443 443
 
444 444
 		    // If this is an "Other" option, get the HTML for it
445 445
 			if ( self::is_other_opt( $opt_key ) ) {
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 	 * @return string
471 471
 	 */
472 472
 	public static function get_term_link( $tax_id ) {
473
-        $tax = get_taxonomy($tax_id);
473
+        $tax = get_taxonomy( $tax_id );
474 474
         if ( ! $tax ) {
475 475
             return '';
476 476
         }
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
             __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
480 480
 			'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
481 481
         );
482
-        unset($tax);
482
+        unset( $tax );
483 483
 
484 484
         return $link;
485 485
     }
@@ -488,8 +488,8 @@  discard block
 block discarded – undo
488 488
 		$hide_opt = self::get_value_for_comparision( $hide_opt );
489 489
 		$observed_value = self::get_value_for_comparision( $observed_value );
490 490
 
491
-        if ( is_array($observed_value) ) {
492
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
491
+        if ( is_array( $observed_value ) ) {
492
+            return self::array_value_condition( $observed_value, $cond, $hide_opt );
493 493
         }
494 494
 
495 495
         $m = false;
@@ -532,23 +532,23 @@  discard block
 block discarded – undo
532 532
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
533 533
         $m = false;
534 534
         if ( $cond == '==' ) {
535
-            if ( is_array($hide_opt) ) {
536
-                $m = array_intersect($hide_opt, $observed_value);
537
-                $m = empty($m) ? false : true;
535
+            if ( is_array( $hide_opt ) ) {
536
+                $m = array_intersect( $hide_opt, $observed_value );
537
+                $m = empty( $m ) ? false : true;
538 538
             } else {
539
-                $m = in_array($hide_opt, $observed_value);
539
+                $m = in_array( $hide_opt, $observed_value );
540 540
             }
541 541
         } else if ( $cond == '!=' ) {
542
-            $m = ! in_array($hide_opt, $observed_value);
542
+            $m = ! in_array( $hide_opt, $observed_value );
543 543
         } else if ( $cond == '>' ) {
544
-            $min = min($observed_value);
544
+            $min = min( $observed_value );
545 545
             $m = $min > $hide_opt;
546 546
         } else if ( $cond == '<' ) {
547
-            $max = max($observed_value);
547
+            $max = max( $observed_value );
548 548
             $m = $max < $hide_opt;
549 549
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
550 550
             foreach ( $observed_value as $ob ) {
551
-                $m = strpos($ob, $hide_opt);
551
+                $m = strpos( $ob, $hide_opt );
552 552
                 if ( $m !== false ) {
553 553
                     $m = true;
554 554
                     break;
@@ -569,20 +569,20 @@  discard block
 block discarded – undo
569 569
      * @return string
570 570
      */
571 571
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
572
-        if ( strpos($value, '[sitename]') !== false ) {
572
+        if ( strpos( $value, '[sitename]' ) !== false ) {
573 573
             $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
574
-            $value = str_replace('[sitename]', $new_value, $value);
574
+            $value = str_replace( '[sitename]', $new_value, $value );
575 575
         }
576 576
 
577
-        $value = apply_filters('frm_content', $value, $form, $entry);
578
-        $value = do_shortcode($value);
577
+        $value = apply_filters( 'frm_content', $value, $form, $entry );
578
+        $value = do_shortcode( $value );
579 579
 
580 580
         return $value;
581 581
     }
582 582
 
583 583
 	public static function get_shortcodes( $content, $form_id ) {
584 584
         if ( FrmAppHelper::pro_is_installed() ) {
585
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
585
+            return FrmProDisplaysHelper::get_shortcodes( $content, $form_id );
586 586
         }
587 587
 
588 588
 		$fields = FrmField::getAll( array(
@@ -590,9 +590,9 @@  discard block
 block discarded – undo
590 590
 			'fi.type not' => FrmField::no_save_fields(),
591 591
 		) );
592 592
 
593
-        $tagregexp = self::allowed_shortcodes($fields);
593
+        $tagregexp = self::allowed_shortcodes( $fields );
594 594
 
595
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
595
+        preg_match_all( "/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER );
596 596
 
597 597
         return $matches;
598 598
     }
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
             $tagregexp[] = $field->field_key;
606 606
         }
607 607
 
608
-        $tagregexp = implode('|', $tagregexp);
608
+        $tagregexp = implode( '|', $tagregexp );
609 609
         return $tagregexp;
610 610
     }
611 611
 
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 				continue;
616 616
 			}
617 617
 
618
-			$atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] );
618
+			$atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][$short_key] );
619 619
 			$tag  = FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key );
620 620
 
621 621
 			$atts['entry'] = $entry;
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 
625 625
 			if ( $replace_with !== null ) {
626 626
 				$replace_with = str_replace( '[', '&#91;', $replace_with ); // prevent shortcodes in fields from being processed
627
-				$content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
627
+				$content = str_replace( $shortcodes[0][$short_key], $replace_with, $content );
628 628
 			}
629 629
 
630 630
 			unset( $atts, $replace_with );
@@ -651,8 +651,8 @@  discard block
 block discarded – undo
651 651
 
652 652
 		$dynamic_default = array( 'admin_email', 'siteurl', 'frmurl', 'sitename', 'get' );
653 653
 
654
-		if ( isset( $shortcode_values[ $atts['tag'] ] ) ) {
655
-			$replace_with = $shortcode_values[ $atts['tag'] ];
654
+		if ( isset( $shortcode_values[$atts['tag']] ) ) {
655
+			$replace_with = $shortcode_values[$atts['tag']];
656 656
 		} elseif ( in_array( $atts['tag'], $dynamic_default ) ) {
657 657
 			$replace_with = self::dynamic_default_values( $atts['tag'], $atts );
658 658
 		} elseif ( $clean_tag == 'user_agent' ) {
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
 		if ( isset( $atts['format'] ) ) {
682 682
 			$time_format = ' ';
683 683
 		} else {
684
-			$atts['format'] = get_option('date_format');
684
+			$atts['format'] = get_option( 'date_format' );
685 685
 			$time_format = '';
686 686
 		}
687 687
 
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
         $new_value = '';
736 736
         switch ( $tag ) {
737 737
             case 'admin_email':
738
-                $new_value = get_option('admin_email');
738
+                $new_value = get_option( 'admin_email' );
739 739
                 break;
740 740
             case 'siteurl':
741 741
                 $new_value = FrmAppHelper::site_url();
@@ -760,28 +760,28 @@  discard block
 block discarded – undo
760 760
      * @return string|array
761 761
      */
762 762
     public static function process_get_shortcode( $atts, $return_array = false ) {
763
-        if ( ! isset($atts['param']) ) {
763
+        if ( ! isset( $atts['param'] ) ) {
764 764
             return '';
765 765
         }
766 766
 
767
-        if ( strpos($atts['param'], '&#91;') ) {
768
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
769
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
767
+        if ( strpos( $atts['param'], '&#91;' ) ) {
768
+            $atts['param'] = str_replace( '&#91;', '[', $atts['param'] );
769
+            $atts['param'] = str_replace( '&#93;', ']', $atts['param'] );
770 770
         }
771 771
 
772 772
 		$new_value = FrmAppHelper::get_param( $atts['param'], '', 'get', 'sanitize_text_field' );
773 773
         $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
774 774
 
775 775
         if ( $new_value == '' ) {
776
-            if ( ! isset($atts['prev_val']) ) {
776
+            if ( ! isset( $atts['prev_val'] ) ) {
777 777
                 $atts['prev_val'] = '';
778 778
             }
779 779
 
780
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
780
+            $new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val'];
781 781
         }
782 782
 
783
-        if ( is_array($new_value) && ! $return_array ) {
784
-            $new_value = implode(', ', $new_value);
783
+        if ( is_array( $new_value ) && ! $return_array ) {
784
+            $new_value = implode( ', ', $new_value );
785 785
         }
786 786
 
787 787
         return $new_value;
@@ -822,9 +822,9 @@  discard block
 block discarded – undo
822 822
 			'size'  => 96,
823 823
 		);
824 824
 
825
-		$args = wp_parse_args($args, $defaults);
825
+		$args = wp_parse_args( $args, $defaults );
826 826
 
827
-		$user = get_userdata($user_id);
827
+		$user = get_userdata( $user_id );
828 828
 		$info = '';
829 829
 
830 830
 		if ( $user ) {
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
 			} elseif ( $user_info == 'author_link' ) {
834 834
 				$info = get_author_posts_url( $user_id );
835 835
 			} else {
836
-				$info = isset($user->$user_info) ? $user->$user_info : '';
836
+				$info = isset( $user->$user_info ) ? $user->$user_info : '';
837 837
 			}
838 838
 
839 839
 			if ( 'display_name' === $user_info && empty( $info ) && ! $args['blank'] ) {
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
 		}
843 843
 
844 844
 		if ( $args['link'] ) {
845
-			$info = '<a href="' . esc_url( admin_url('user-edit.php?user_id=' . $user_id ) ) . '">' . $info . '</a>';
845
+			$info = '<a href="' . esc_url( admin_url( 'user-edit.php?user_id=' . $user_id ) ) . '">' . $info . '</a>';
846 846
 		}
847 847
 
848 848
 		return $info;
@@ -856,14 +856,14 @@  discard block
 block discarded – undo
856 856
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
857 857
 
858 858
         $field_types = array();
859
-        if ( in_array($type, $single_input) ) {
859
+        if ( in_array( $type, $single_input ) ) {
860 860
             self::field_types_for_input( $single_input, $field_selection, $field_types );
861
-        } else if ( in_array($type, $multiple_input) ) {
861
+        } else if ( in_array( $type, $multiple_input ) ) {
862 862
             self::field_types_for_input( $multiple_input, $field_selection, $field_types );
863
-        } else if ( in_array($type, $other_type) ) {
863
+        } else if ( in_array( $type, $other_type ) ) {
864 864
             self::field_types_for_input( $other_type, $field_selection, $field_types );
865
-		} else if ( isset( $field_selection[ $type ] ) ) {
866
-            $field_types[ $type ] = $field_selection[ $type ];
865
+		} else if ( isset( $field_selection[$type] ) ) {
866
+            $field_types[$type] = $field_selection[$type];
867 867
         }
868 868
 
869 869
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
@@ -872,8 +872,8 @@  discard block
 block discarded – undo
872 872
 
873 873
     private static function field_types_for_input( $inputs, $fields, &$field_types ) {
874 874
         foreach ( $inputs as $input ) {
875
-            $field_types[ $input ] = $fields[ $input ];
876
-            unset($input);
875
+            $field_types[$input] = $fields[$input];
876
+            unset( $input );
877 877
         }
878 878
     }
879 879
 
@@ -920,21 +920,21 @@  discard block
 block discarded – undo
920 920
 		// Check posted vals before checking saved values
921 921
 
922 922
 		// For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero
923
-		if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) {
923
+		if ( $parent && isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ) {
924 924
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
925
-				$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 ] ) : '';
925
+				$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] ) : '';
926 926
 			} else {
927
-				$other_val = sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] );
927
+				$other_val = sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] );
928 928
 			}
929 929
 			return $other_val;
930 930
 
931
-		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) {
931
+		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][$field['id']] ) ) {
932 932
 			// For normal fields
933 933
 
934 934
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
935
-				$other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) : '';
935
+				$other_val = isset( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta']['other'][$field['id']][$opt_key] ) : '';
936 936
 			} else {
937
-				$other_val = sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ] );
937
+				$other_val = sanitize_text_field( $_POST['item_meta']['other'][$field['id']] );
938 938
 			}
939 939
 			return $other_val;
940 940
 		}
@@ -943,8 +943,8 @@  discard block
 block discarded – undo
943 943
 		if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) {
944 944
 			// Check if there is an "other" val in saved value and make sure the
945 945
 			// "other" val is not equal to the Other checkbox option
946
-			if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) {
947
-				$other_val = $field['value'][ $opt_key ];
946
+			if ( isset( $field['value'][$opt_key] ) && $field['options'][$opt_key] != $field['value'][$opt_key] ) {
947
+				$other_val = $field['value'][$opt_key];
948 948
 			}
949 949
 		} else {
950 950
 			/**
@@ -956,8 +956,8 @@  discard block
 block discarded – undo
956 956
 				// Multi-select dropdowns - key is not preserved
957 957
 				if ( is_array( $field['value'] ) ) {
958 958
 					$o_key = array_search( $temp_val, $field['value'] );
959
-					if ( isset( $field['value'][ $o_key ] ) ) {
960
-						unset( $field['value'][ $o_key ], $o_key );
959
+					if ( isset( $field['value'][$o_key] ) ) {
960
+						unset( $field['value'][$o_key], $o_key );
961 961
 					}
962 962
 				} else if ( $temp_val == $field['value'] ) {
963 963
 					// For radio and regular dropdowns
@@ -1014,7 +1014,7 @@  discard block
 block discarded – undo
1014 1014
 	private static function set_other_name( $args, &$other_args ) {
1015 1015
 		//Set up name for other field
1016 1016
 		$other_args['name'] = str_replace( '[]', '', $args['field_name'] );
1017
-		$other_args['name'] = preg_replace('/\[' . $args['field']['id'] . '\]$/', '', $other_args['name']);
1017
+		$other_args['name'] = preg_replace( '/\[' . $args['field']['id'] . '\]$/', '', $other_args['name'] );
1018 1018
 		$other_args['name'] = $other_args['name'] . '[other]' . '[' . $args['field']['id'] . ']';
1019 1019
 
1020 1020
 		//Converts item_meta[field_id] => item_meta[other][field_id] and
@@ -1041,7 +1041,7 @@  discard block
 block discarded – undo
1041 1041
 		// Count should only be greater than 3 if inside of a repeating section
1042 1042
 		if ( count( $temp_array ) > 3 ) {
1043 1043
 			$parent = str_replace( ']', '', $temp_array[1] );
1044
-			$pointer = str_replace( ']', '', $temp_array[2]);
1044
+			$pointer = str_replace( ']', '', $temp_array[2] );
1045 1045
 		}
1046 1046
 
1047 1047
 		// Get text for "other" text field
@@ -1175,15 +1175,15 @@  discard block
 block discarded – undo
1175 1175
 			$replace_with[] = '[' . $new . ']';
1176 1176
 			$replace[] = '[' . $old . ' ';
1177 1177
 			$replace_with[] = '[' . $new . ' ';
1178
-            unset($old, $new);
1178
+            unset( $old, $new );
1179 1179
         }
1180 1180
 		if ( is_array( $val ) ) {
1181 1181
 			foreach ( $val as $k => $v ) {
1182
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1183
-                unset($k, $v);
1182
+                $val[$k] = str_replace( $replace, $replace_with, $v );
1183
+                unset( $k, $v );
1184 1184
             }
1185 1185
         } else {
1186
-            $val = str_replace($replace, $replace_with, $val);
1186
+            $val = str_replace( $replace, $replace_with, $val );
1187 1187
         }
1188 1188
 
1189 1189
         return $val;
@@ -1250,19 +1250,19 @@  discard block
 block discarded – undo
1250 1250
 	}
1251 1251
 
1252 1252
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1253
-		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1253
+		$prepop[__( 'Countries', 'formidable' )] = FrmFieldsHelper::get_countries();
1254 1254
 
1255 1255
         $states = FrmFieldsHelper::get_us_states();
1256
-        $state_abv = array_keys($states);
1257
-        sort($state_abv);
1258
-		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1256
+        $state_abv = array_keys( $states );
1257
+        sort( $state_abv );
1258
+		$prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv;
1259 1259
 
1260
-        $states = array_values($states);
1261
-        sort($states);
1262
-		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1263
-        unset($state_abv, $states);
1260
+        $states = array_values( $states );
1261
+        sort( $states );
1262
+		$prepop[__( 'U.S. States', 'formidable' )] = $states;
1263
+        unset( $state_abv, $states );
1264 1264
 
1265
-		$prepop[ __( 'Age', 'formidable' ) ] = array(
1265
+		$prepop[__( 'Age', 'formidable' )] = array(
1266 1266
 			__( 'Under 18', 'formidable' ),
1267 1267
 			__( '18-24', 'formidable' ),
1268 1268
 			__( '25-34', 'formidable' ),
@@ -1273,7 +1273,7 @@  discard block
 block discarded – undo
1273 1273
 			__( 'Prefer Not to Answer', 'formidable' ),
1274 1274
 		);
1275 1275
 
1276
-		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1276
+		$prepop[__( 'Satisfaction', 'formidable' )] = array(
1277 1277
 			__( 'Very Satisfied', 'formidable' ),
1278 1278
 			__( 'Satisfied', 'formidable' ),
1279 1279
 			__( 'Neutral', 'formidable' ),
@@ -1282,7 +1282,7 @@  discard block
 block discarded – undo
1282 1282
 			__( 'N/A', 'formidable' ),
1283 1283
 		);
1284 1284
 
1285
-		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1285
+		$prepop[__( 'Importance', 'formidable' )] = array(
1286 1286
 			__( 'Very Important', 'formidable' ),
1287 1287
 			__( 'Important', 'formidable' ),
1288 1288
 			__( 'Neutral', 'formidable' ),
@@ -1291,7 +1291,7 @@  discard block
 block discarded – undo
1291 1291
 			__( 'N/A', 'formidable' ),
1292 1292
 		);
1293 1293
 
1294
-		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1294
+		$prepop[__( 'Agreement', 'formidable' )] = array(
1295 1295
 			__( 'Strongly Agree', 'formidable' ),
1296 1296
 			__( 'Agree', 'formidable' ),
1297 1297
 			__( 'Neutral', 'formidable' ),
Please login to merge, or discard this patch.