Completed
Push — master ( ab036a...e5a1c7 )
by Stephanie
02:09
created
classes/helpers/FrmFieldsHelper.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 			if ( in_array( $type, array( 'data', 'lookup' ) ) ) {
27 27
 				$values['field_options']['data_type'] = $setting;
28 28
 			} else {
29
-				$values['field_options'][ $setting ] = 1;
29
+				$values['field_options'][$setting] = 1;
30 30
 			}
31 31
 		}
32 32
 
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
 		}
134 134
 
135 135
 		foreach ( $defaults as $opt => $default ) {
136
-			$values[ $opt ] = isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default;
136
+			$values[$opt] = isset( $field->field_options[$opt] ) ? $field->field_options[$opt] : $default;
137 137
 
138 138
 			if ( $check_post ) {
139
-				self::get_posted_field_setting( $opt . '_' . $field->id, $values[ $opt ] );
139
+				self::get_posted_field_setting( $opt . '_' . $field->id, $values[$opt] );
140 140
 			}
141 141
 
142 142
 			unset( $opt, $default );
@@ -180,20 +180,20 @@  discard block
 block discarded – undo
180 180
 	 * @param mixed $value
181 181
 	 */
182 182
 	private static function get_posted_field_setting( $setting, &$value ) {
183
-		if ( ! isset( $_POST['field_options'][ $setting ] ) ) {
183
+		if ( ! isset( $_POST['field_options'][$setting] ) ) {
184 184
 			return;
185 185
 		}
186 186
 
187 187
 		if ( strpos( $setting, 'html' ) !== false ) {
188 188
 			// Strip slashes from HTML but not regex or script tags.
189 189
 			// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
190
-			$value = wp_unslash( $_POST['field_options'][ $setting ] );
190
+			$value = wp_unslash( $_POST['field_options'][$setting] );
191 191
 		} elseif ( strpos( $setting, 'format_' ) === 0 ) {
192 192
 			// TODO: Remove stripslashes on output, and use on input only.
193
-			$value = sanitize_text_field( $_POST['field_options'][ $setting ] ); // WPCS: sanitization ok.
193
+			$value = sanitize_text_field( $_POST['field_options'][$setting] ); // WPCS: sanitization ok.
194 194
 		} else {
195 195
 			// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
196
-			$value = wp_unslash( $_POST['field_options'][ $setting ] );
196
+			$value = wp_unslash( $_POST['field_options'][$setting] );
197 197
 			FrmAppHelper::sanitize_value( 'wp_kses_post', $value );
198 198
 		}
199 199
 	}
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 		$values['default_value'] = FrmAppHelper::maybe_json_encode( $field->default_value );
267 267
 
268 268
 		foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
269
-			$values[ $col ] = $field->{$col};
269
+			$values[$col] = $field->{$col};
270 270
 		}
271 271
 	}
272 272
 
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 		);
307 307
 
308 308
 		$msg = FrmField::get_option( $field, $error );
309
-		$msg = empty( $msg ) ? $defaults[ $error ]['part'] : $msg;
309
+		$msg = empty( $msg ) ? $defaults[$error]['part'] : $msg;
310 310
 		$msg = do_shortcode( $msg );
311 311
 
312 312
 		return $msg;
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 		}
415 415
 
416 416
 		$base_name = 'default_value_' . $field['id'];
417
-		$html_id    = isset( $field['html_id'] ) ? $field['html_id'] : self::get_html_id( $field );
417
+		$html_id = isset( $field['html_id'] ) ? $field['html_id'] : self::get_html_id( $field );
418 418
 
419 419
 		$default_type = self::get_default_value_type( $field );
420 420
 
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
 				continue;
711 711
 			}
712 712
 
713
-			$atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] );
713
+			$atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][$short_key] );
714 714
 			$tag  = FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key );
715 715
 
716 716
 			$atts['entry'] = $entry;
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 
720 720
 			if ( $replace_with !== null ) {
721 721
 				self::sanitize_embedded_shortcodes( compact( 'entry' ), $replace_with );
722
-				$content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
722
+				$content = str_replace( $shortcodes[0][$short_key], $replace_with, $content );
723 723
 			}
724 724
 
725 725
 			unset( $atts, $replace_with );
@@ -762,8 +762,8 @@  discard block
 block discarded – undo
762 762
 
763 763
 		$dynamic_default = array( 'admin_email', 'siteurl', 'frmurl', 'sitename', 'get' );
764 764
 
765
-		if ( isset( $shortcode_values[ $atts['tag'] ] ) ) {
766
-			$replace_with = $shortcode_values[ $atts['tag'] ];
765
+		if ( isset( $shortcode_values[$atts['tag']] ) ) {
766
+			$replace_with = $shortcode_values[$atts['tag']];
767 767
 		} elseif ( in_array( $atts['tag'], $dynamic_default ) ) {
768 768
 			$replace_with = self::dynamic_default_values( $atts['tag'], $atts );
769 769
 		} elseif ( $clean_tag == 'user_agent' ) {
@@ -972,8 +972,8 @@  discard block
 block discarded – undo
972 972
 			self::field_types_for_input( $single_input, $field_selection, $field_types );
973 973
 		} elseif ( in_array( $type, $multiple_input ) ) {
974 974
 			self::field_types_for_input( $multiple_input, $field_selection, $field_types );
975
-		} elseif ( isset( $field_selection[ $type ] ) ) {
976
-			$field_types[ $type ] = $field_selection[ $type ];
975
+		} elseif ( isset( $field_selection[$type] ) ) {
976
+			$field_types[$type] = $field_selection[$type];
977 977
 		}
978 978
 
979 979
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
 
1007 1007
 	private static function field_types_for_input( $inputs, $fields, &$field_types ) {
1008 1008
 		foreach ( $inputs as $input ) {
1009
-			$field_types[ $input ] = $fields[ $input ];
1009
+			$field_types[$input] = $fields[$input];
1010 1010
 			unset( $input );
1011 1011
 		}
1012 1012
 	}
@@ -1038,7 +1038,7 @@  discard block
 block discarded – undo
1038 1038
 			'parent'  => false,
1039 1039
 			'pointer' => false,
1040 1040
 		);
1041
-		$args     = wp_parse_args( $args, $defaults );
1041
+		$args = wp_parse_args( $args, $defaults );
1042 1042
 
1043 1043
 		$opt_key   = $args['opt_key'];
1044 1044
 		$field     = $args['field'];
@@ -1055,22 +1055,22 @@  discard block
 block discarded – undo
1055 1055
 		// Check posted vals before checking saved values
1056 1056
 
1057 1057
 		// For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero
1058
-		if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) {
1058
+		if ( $parent && isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ) {
1059 1059
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
1060
-				$other_val = isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( wp_unslash( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ) : '';
1060
+				$other_val = isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) ? sanitize_text_field( wp_unslash( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) ) : '';
1061 1061
 			} else {
1062
-				$other_val = sanitize_text_field( wp_unslash( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) );
1062
+				$other_val = sanitize_text_field( wp_unslash( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) );
1063 1063
 			}
1064 1064
 
1065 1065
 			return $other_val;
1066 1066
 
1067
-		} elseif ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) {
1067
+		} elseif ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][$field['id']] ) ) {
1068 1068
 			// For normal fields
1069 1069
 
1070 1070
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
1071
-				$other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ) : '';
1071
+				$other_val = isset( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ? sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ) : '';
1072 1072
 			} else {
1073
-				$other_val = sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][ $field['id'] ] ) );
1073
+				$other_val = sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][$field['id']] ) );
1074 1074
 			}
1075 1075
 
1076 1076
 			return $other_val;
@@ -1080,8 +1080,8 @@  discard block
 block discarded – undo
1080 1080
 		if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) {
1081 1081
 			// Check if there is an "other" val in saved value and make sure the
1082 1082
 			// "other" val is not equal to the Other checkbox option
1083
-			if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) {
1084
-				$other_val = $field['value'][ $opt_key ];
1083
+			if ( isset( $field['value'][$opt_key] ) && $field['options'][$opt_key] != $field['value'][$opt_key] ) {
1084
+				$other_val = $field['value'][$opt_key];
1085 1085
 			}
1086 1086
 		} else {
1087 1087
 			/**
@@ -1093,8 +1093,8 @@  discard block
 block discarded – undo
1093 1093
 				// Multi-select dropdowns - key is not preserved
1094 1094
 				if ( is_array( $field['value'] ) ) {
1095 1095
 					$o_key = array_search( $temp_val, $field['value'] );
1096
-					if ( isset( $field['value'][ $o_key ] ) ) {
1097
-						unset( $field['value'][ $o_key ], $o_key );
1096
+					if ( isset( $field['value'][$o_key] ) ) {
1097
+						unset( $field['value'][$o_key], $o_key );
1098 1098
 					}
1099 1099
 				} elseif ( $temp_val == $field['value'] ) {
1100 1100
 					// For radio and regular dropdowns
@@ -1281,7 +1281,7 @@  discard block
 block discarded – undo
1281 1281
 		}
1282 1282
 		if ( is_array( $val ) ) {
1283 1283
 			foreach ( $val as $k => $v ) {
1284
-				$val[ $k ] = str_replace( $replace, $replace_with, $v );
1284
+				$val[$k] = str_replace( $replace, $replace_with, $v );
1285 1285
 				unset( $k, $v );
1286 1286
 			}
1287 1287
 		} else {
@@ -1591,19 +1591,19 @@  discard block
 block discarded – undo
1591 1591
 	}
1592 1592
 
1593 1593
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1594
-		$prepop[ __( 'Countries', 'formidable' ) ] = self::get_countries();
1594
+		$prepop[__( 'Countries', 'formidable' )] = self::get_countries();
1595 1595
 
1596 1596
 		$states    = self::get_us_states();
1597 1597
 		$state_abv = array_keys( $states );
1598 1598
 		sort( $state_abv );
1599
-		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1599
+		$prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv;
1600 1600
 
1601 1601
 		$states = array_values( $states );
1602 1602
 		sort( $states );
1603
-		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1603
+		$prepop[__( 'U.S. States', 'formidable' )] = $states;
1604 1604
 		unset( $state_abv, $states );
1605 1605
 
1606
-		$prepop[ __( 'Age', 'formidable' ) ] = array(
1606
+		$prepop[__( 'Age', 'formidable' )] = array(
1607 1607
 			__( 'Under 18', 'formidable' ),
1608 1608
 			__( '18-24', 'formidable' ),
1609 1609
 			__( '25-34', 'formidable' ),
@@ -1614,7 +1614,7 @@  discard block
 block discarded – undo
1614 1614
 			__( 'Prefer Not to Answer', 'formidable' ),
1615 1615
 		);
1616 1616
 
1617
-		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1617
+		$prepop[__( 'Satisfaction', 'formidable' )] = array(
1618 1618
 			__( 'Very Satisfied', 'formidable' ),
1619 1619
 			__( 'Satisfied', 'formidable' ),
1620 1620
 			__( 'Neutral', 'formidable' ),
@@ -1623,7 +1623,7 @@  discard block
 block discarded – undo
1623 1623
 			__( 'N/A', 'formidable' ),
1624 1624
 		);
1625 1625
 
1626
-		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1626
+		$prepop[__( 'Importance', 'formidable' )] = array(
1627 1627
 			__( 'Very Important', 'formidable' ),
1628 1628
 			__( 'Important', 'formidable' ),
1629 1629
 			__( 'Neutral', 'formidable' ),
@@ -1632,7 +1632,7 @@  discard block
 block discarded – undo
1632 1632
 			__( 'N/A', 'formidable' ),
1633 1633
 		);
1634 1634
 
1635
-		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1635
+		$prepop[__( 'Agreement', 'formidable' )] = array(
1636 1636
 			__( 'Strongly Agree', 'formidable' ),
1637 1637
 			__( 'Agree', 'formidable' ),
1638 1638
 			__( 'Neutral', 'formidable' ),
Please login to merge, or discard this patch.