Completed
Push — master ( 1af53d...4a62cc )
by Stephanie
02:20
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,18 +180,18 @@  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.
189
-			$value = wp_unslash( $_POST['field_options'][ $setting ] );
189
+			$value = wp_unslash( $_POST['field_options'][$setting] );
190 190
 		} elseif ( strpos( $setting, 'format_' ) === 0 ) {
191 191
 			// TODO: Remove stripslashes on output, and use on input only.
192
-			$value = sanitize_text_field( $_POST['field_options'][ $setting ] ); // WPCS: sanitization ok.
192
+			$value = sanitize_text_field( $_POST['field_options'][$setting] ); // WPCS: sanitization ok.
193 193
 		} else {
194
-			$value = wp_kses_post( wp_unslash( $_POST['field_options'][ $setting ] ) );
194
+			$value = wp_kses_post( wp_unslash( $_POST['field_options'][$setting] ) );
195 195
 		}
196 196
 	}
197 197
 
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 		$values['default_value'] = maybe_serialize( $field->default_value );
264 264
 
265 265
 		foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
266
-			$values[ $col ] = $field->{$col};
266
+			$values[$col] = $field->{$col};
267 267
 		}
268 268
 	}
269 269
 
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 		);
304 304
 
305 305
 		$msg = FrmField::get_option( $field, $error );
306
-		$msg = empty( $msg ) ? $defaults[ $error ]['part'] : $msg;
306
+		$msg = empty( $msg ) ? $defaults[$error]['part'] : $msg;
307 307
 		$msg = do_shortcode( $msg );
308 308
 
309 309
 		return $msg;
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 		}
412 412
 
413 413
 		$base_name = 'default_value_' . $field['id'];
414
-		$html_id    = isset( $field['html_id'] ) ? $field['html_id'] : self::get_html_id( $field );
414
+		$html_id = isset( $field['html_id'] ) ? $field['html_id'] : self::get_html_id( $field );
415 415
 
416 416
 		$default_type = self::get_default_value_type( $field );
417 417
 
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
 				continue;
708 708
 			}
709 709
 
710
-			$atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] );
710
+			$atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][$short_key] );
711 711
 			$tag  = FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key );
712 712
 
713 713
 			$atts['entry'] = $entry;
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
 
717 717
 			if ( $replace_with !== null ) {
718 718
 				self::sanitize_embedded_shortcodes( compact( 'entry' ), $replace_with );
719
-				$content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
719
+				$content = str_replace( $shortcodes[0][$short_key], $replace_with, $content );
720 720
 			}
721 721
 
722 722
 			unset( $atts, $replace_with );
@@ -759,8 +759,8 @@  discard block
 block discarded – undo
759 759
 
760 760
 		$dynamic_default = array( 'admin_email', 'siteurl', 'frmurl', 'sitename', 'get' );
761 761
 
762
-		if ( isset( $shortcode_values[ $atts['tag'] ] ) ) {
763
-			$replace_with = $shortcode_values[ $atts['tag'] ];
762
+		if ( isset( $shortcode_values[$atts['tag']] ) ) {
763
+			$replace_with = $shortcode_values[$atts['tag']];
764 764
 		} elseif ( in_array( $atts['tag'], $dynamic_default ) ) {
765 765
 			$replace_with = self::dynamic_default_values( $atts['tag'], $atts );
766 766
 		} elseif ( $clean_tag == 'user_agent' ) {
@@ -969,8 +969,8 @@  discard block
 block discarded – undo
969 969
 			self::field_types_for_input( $single_input, $field_selection, $field_types );
970 970
 		} elseif ( in_array( $type, $multiple_input ) ) {
971 971
 			self::field_types_for_input( $multiple_input, $field_selection, $field_types );
972
-		} elseif ( isset( $field_selection[ $type ] ) ) {
973
-			$field_types[ $type ] = $field_selection[ $type ];
972
+		} elseif ( isset( $field_selection[$type] ) ) {
973
+			$field_types[$type] = $field_selection[$type];
974 974
 		}
975 975
 
976 976
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
 
1004 1004
 	private static function field_types_for_input( $inputs, $fields, &$field_types ) {
1005 1005
 		foreach ( $inputs as $input ) {
1006
-			$field_types[ $input ] = $fields[ $input ];
1006
+			$field_types[$input] = $fields[$input];
1007 1007
 			unset( $input );
1008 1008
 		}
1009 1009
 	}
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
 			'parent'  => false,
1036 1036
 			'pointer' => false,
1037 1037
 		);
1038
-		$args     = wp_parse_args( $args, $defaults );
1038
+		$args = wp_parse_args( $args, $defaults );
1039 1039
 
1040 1040
 		$opt_key   = $args['opt_key'];
1041 1041
 		$field     = $args['field'];
@@ -1052,22 +1052,22 @@  discard block
 block discarded – undo
1052 1052
 		// Check posted vals before checking saved values
1053 1053
 
1054 1054
 		// For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero
1055
-		if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) {
1055
+		if ( $parent && isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ) {
1056 1056
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
1057
-				$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 ] ) ) : '';
1057
+				$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] ) ) : '';
1058 1058
 			} else {
1059
-				$other_val = sanitize_text_field( wp_unslash( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) );
1059
+				$other_val = sanitize_text_field( wp_unslash( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) );
1060 1060
 			}
1061 1061
 
1062 1062
 			return $other_val;
1063 1063
 
1064
-		} elseif ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) {
1064
+		} elseif ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][$field['id']] ) ) {
1065 1065
 			// For normal fields
1066 1066
 
1067 1067
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
1068
-				$other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ) : '';
1068
+				$other_val = isset( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ? sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ) : '';
1069 1069
 			} else {
1070
-				$other_val = sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][ $field['id'] ] ) );
1070
+				$other_val = sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][$field['id']] ) );
1071 1071
 			}
1072 1072
 
1073 1073
 			return $other_val;
@@ -1077,8 +1077,8 @@  discard block
 block discarded – undo
1077 1077
 		if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) {
1078 1078
 			// Check if there is an "other" val in saved value and make sure the
1079 1079
 			// "other" val is not equal to the Other checkbox option
1080
-			if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) {
1081
-				$other_val = $field['value'][ $opt_key ];
1080
+			if ( isset( $field['value'][$opt_key] ) && $field['options'][$opt_key] != $field['value'][$opt_key] ) {
1081
+				$other_val = $field['value'][$opt_key];
1082 1082
 			}
1083 1083
 		} else {
1084 1084
 			/**
@@ -1090,8 +1090,8 @@  discard block
 block discarded – undo
1090 1090
 				// Multi-select dropdowns - key is not preserved
1091 1091
 				if ( is_array( $field['value'] ) ) {
1092 1092
 					$o_key = array_search( $temp_val, $field['value'] );
1093
-					if ( isset( $field['value'][ $o_key ] ) ) {
1094
-						unset( $field['value'][ $o_key ], $o_key );
1093
+					if ( isset( $field['value'][$o_key] ) ) {
1094
+						unset( $field['value'][$o_key], $o_key );
1095 1095
 					}
1096 1096
 				} elseif ( $temp_val == $field['value'] ) {
1097 1097
 					// For radio and regular dropdowns
@@ -1278,7 +1278,7 @@  discard block
 block discarded – undo
1278 1278
 		}
1279 1279
 		if ( is_array( $val ) ) {
1280 1280
 			foreach ( $val as $k => $v ) {
1281
-				$val[ $k ] = str_replace( $replace, $replace_with, $v );
1281
+				$val[$k] = str_replace( $replace, $replace_with, $v );
1282 1282
 				unset( $k, $v );
1283 1283
 			}
1284 1284
 		} else {
@@ -1588,19 +1588,19 @@  discard block
 block discarded – undo
1588 1588
 	}
1589 1589
 
1590 1590
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1591
-		$prepop[ __( 'Countries', 'formidable' ) ] = self::get_countries();
1591
+		$prepop[__( 'Countries', 'formidable' )] = self::get_countries();
1592 1592
 
1593 1593
 		$states    = self::get_us_states();
1594 1594
 		$state_abv = array_keys( $states );
1595 1595
 		sort( $state_abv );
1596
-		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1596
+		$prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv;
1597 1597
 
1598 1598
 		$states = array_values( $states );
1599 1599
 		sort( $states );
1600
-		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1600
+		$prepop[__( 'U.S. States', 'formidable' )] = $states;
1601 1601
 		unset( $state_abv, $states );
1602 1602
 
1603
-		$prepop[ __( 'Age', 'formidable' ) ] = array(
1603
+		$prepop[__( 'Age', 'formidable' )] = array(
1604 1604
 			__( 'Under 18', 'formidable' ),
1605 1605
 			__( '18-24', 'formidable' ),
1606 1606
 			__( '25-34', 'formidable' ),
@@ -1611,7 +1611,7 @@  discard block
 block discarded – undo
1611 1611
 			__( 'Prefer Not to Answer', 'formidable' ),
1612 1612
 		);
1613 1613
 
1614
-		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1614
+		$prepop[__( 'Satisfaction', 'formidable' )] = array(
1615 1615
 			__( 'Very Satisfied', 'formidable' ),
1616 1616
 			__( 'Satisfied', 'formidable' ),
1617 1617
 			__( 'Neutral', 'formidable' ),
@@ -1620,7 +1620,7 @@  discard block
 block discarded – undo
1620 1620
 			__( 'N/A', 'formidable' ),
1621 1621
 		);
1622 1622
 
1623
-		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1623
+		$prepop[__( 'Importance', 'formidable' )] = array(
1624 1624
 			__( 'Very Important', 'formidable' ),
1625 1625
 			__( 'Important', 'formidable' ),
1626 1626
 			__( 'Neutral', 'formidable' ),
@@ -1629,7 +1629,7 @@  discard block
 block discarded – undo
1629 1629
 			__( 'N/A', 'formidable' ),
1630 1630
 		);
1631 1631
 
1632
-		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1632
+		$prepop[__( 'Agreement', 'formidable' )] = array(
1633 1633
 			__( 'Strongly Agree', 'formidable' ),
1634 1634
 			__( 'Agree', 'formidable' ),
1635 1635
 			__( 'Neutral', 'formidable' ),
Please login to merge, or discard this patch.