Completed
Push — master ( 8cdaf3...47b27c )
by
unknown
50s queued 14s
created
classes/helpers/FrmFieldsHelper.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 			if ( in_array( $type, array( 'data', 'lookup' ), true ) ) {
32 32
 				$values['field_options']['data_type'] = $setting;
33 33
 			} else {
34
-				$values['field_options'][ $setting ] = 1;
34
+				$values['field_options'][$setting] = 1;
35 35
 			}
36 36
 		}
37 37
 
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
 		}
166 166
 
167 167
 		foreach ( $defaults as $opt => $default ) {
168
-			$values[ $opt ] = isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default;
168
+			$values[$opt] = isset( $field->field_options[$opt] ) ? $field->field_options[$opt] : $default;
169 169
 
170 170
 			if ( $check_post ) {
171
-				self::get_posted_field_setting( $opt . '_' . $field->id, $values[ $opt ] );
171
+				self::get_posted_field_setting( $opt . '_' . $field->id, $values[$opt] );
172 172
 			}
173 173
 
174 174
 			unset( $opt, $default );
@@ -244,18 +244,18 @@  discard block
 block discarded – undo
244 244
 	 * @param mixed  $value
245 245
 	 */
246 246
 	private static function get_posted_field_setting( $setting, &$value ) {
247
-		if ( ! isset( $_POST['field_options'][ $setting ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
247
+		if ( ! isset( $_POST['field_options'][$setting] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
248 248
 			return;
249 249
 		}
250 250
 
251 251
 		if ( strpos( $setting, 'html' ) !== false ) {
252 252
 			// Strip slashes from HTML but not regex or script tags.
253
-			$value = wp_unslash( $_POST['field_options'][ $setting ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
253
+			$value = wp_unslash( $_POST['field_options'][$setting] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
254 254
 		} elseif ( strpos( $setting, 'format_' ) === 0 ) {
255 255
 			// TODO: Remove stripslashes on output, and use on input only.
256
-			$value = sanitize_text_field( $_POST['field_options'][ $setting ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.NonceVerification.Missing
256
+			$value = sanitize_text_field( $_POST['field_options'][$setting] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.NonceVerification.Missing
257 257
 		} else {
258
-			$value = wp_unslash( $_POST['field_options'][ $setting ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
258
+			$value = wp_unslash( $_POST['field_options'][$setting] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
259 259
 			FrmAppHelper::sanitize_value( 'wp_kses_post', $value );
260 260
 		}
261 261
 	}
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 		$values['default_value'] = FrmAppHelper::maybe_json_encode( $field->default_value );
329 329
 
330 330
 		foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
331
-			$values[ $col ] = $field->{$col};
331
+			$values[$col] = $field->{$col};
332 332
 		}
333 333
 	}
334 334
 
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 		);
367 367
 
368 368
 		$msg = FrmField::get_option( $field, $error );
369
-		$msg = empty( $msg ) ? $defaults[ $error ]['part'] : $msg;
369
+		$msg = empty( $msg ) ? $defaults[$error]['part'] : $msg;
370 370
 		$msg = do_shortcode( $msg );
371 371
 
372 372
 		$msg = self::maybe_replace_substrings_with_field_name( $msg, $error, $field );
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
 			'title'        => '',
635 635
 			'inside_class' => 'inside',
636 636
 		);
637
-		$args     = array_merge( $defaults, $args );
637
+		$args = array_merge( $defaults, $args );
638 638
 
639 639
 		include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/inline-modal.php';
640 640
 	}
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
 				continue;
872 872
 			}
873 873
 
874
-			$atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] );
874
+			$atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][$short_key] );
875 875
 			$tag  = FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key );
876 876
 
877 877
 			$atts['entry'] = $entry;
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
 			if ( $replace_with !== null ) {
882 882
 				$replace_with = self::trigger_shortcode_atts( $replace_with, $atts );
883 883
 				self::sanitize_embedded_shortcodes( compact( 'entry' ), $replace_with );
884
-				$content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
884
+				$content = str_replace( $shortcodes[0][$short_key], $replace_with, $content );
885 885
 			}
886 886
 
887 887
 			unset( $atts, $replace_with );
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
 		$supported_atts = array( 'remove_accents', 'sanitize', 'sanitize_url' );
900 900
 		$included_atts  = array_intersect( $supported_atts, array_keys( $atts ) );
901 901
 		foreach ( $included_atts as $included_att ) {
902
-			if ( '0' === $atts[ $included_att ] ) {
902
+			if ( '0' === $atts[$included_att] ) {
903 903
 				// Skip any option that uses 0 so sanitize_url=0 does not encode.
904 904
 				continue;
905 905
 			}
@@ -972,8 +972,8 @@  discard block
 block discarded – undo
972 972
 
973 973
 		$dynamic_default = array( 'admin_email', 'siteurl', 'frmurl', 'sitename', 'get', 'default-email', 'default-from-email' );
974 974
 
975
-		if ( isset( $shortcode_values[ $atts['tag'] ] ) ) {
976
-			$replace_with = $shortcode_values[ $atts['tag'] ];
975
+		if ( isset( $shortcode_values[$atts['tag']] ) ) {
976
+			$replace_with = $shortcode_values[$atts['tag']];
977 977
 		} elseif ( in_array( $atts['tag'], $dynamic_default, true ) ) {
978 978
 			$replace_with = self::dynamic_default_values( $atts['tag'], $atts );
979 979
 		} elseif ( $clean_tag === 'user_agent' ) {
@@ -1197,8 +1197,8 @@  discard block
 block discarded – undo
1197 1197
 			self::field_types_for_input( $single_input, $field_selection, $field_types );
1198 1198
 		} elseif ( in_array( $type, $multiple_input, true ) ) {
1199 1199
 			self::field_types_for_input( $multiple_input, $field_selection, $field_types );
1200
-		} elseif ( isset( $field_selection[ $type ] ) ) {
1201
-			$field_types[ $type ] = $field_selection[ $type ];
1200
+		} elseif ( isset( $field_selection[$type] ) ) {
1201
+			$field_types[$type] = $field_selection[$type];
1202 1202
 		}
1203 1203
 
1204 1204
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type', 'field_selection' ) );
@@ -1239,7 +1239,7 @@  discard block
 block discarded – undo
1239 1239
 		foreach ( $inputs as $input ) {
1240 1240
 			// This may not be set if a field type was removed using the frm_available_fields or frm_pro_available_fields filters.
1241 1241
 			if ( array_key_exists( $input, $fields ) ) {
1242
-				$field_types[ $input ] = $fields[ $input ];
1242
+				$field_types[$input] = $fields[$input];
1243 1243
 			}
1244 1244
 			unset( $input );
1245 1245
 		}
@@ -1272,7 +1272,7 @@  discard block
 block discarded – undo
1272 1272
 			'parent'  => false,
1273 1273
 			'pointer' => false,
1274 1274
 		);
1275
-		$args     = wp_parse_args( $args, $defaults );
1275
+		$args = wp_parse_args( $args, $defaults );
1276 1276
 
1277 1277
 		$opt_key   = $args['opt_key'];
1278 1278
 		$field     = $args['field'];
@@ -1288,25 +1288,25 @@  discard block
 block discarded – undo
1288 1288
 
1289 1289
 		// Check posted vals before checking saved values
1290 1290
 		// For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero
1291
-		if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
1291
+		if ( $parent && isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
1292 1292
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
1293 1293
 				// phpcs:ignore WordPress.Security.NonceVerification.Missing
1294
-				$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 ] ) ) : '';
1294
+				$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] ) ) : '';
1295 1295
 			} else {
1296
-				$other_val = sanitize_text_field( wp_unslash( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
1296
+				$other_val = sanitize_text_field( wp_unslash( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
1297 1297
 			}
1298 1298
 
1299 1299
 			return $other_val;
1300 1300
 		}
1301 1301
 
1302
-		if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
1302
+		if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][$field['id']] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
1303 1303
 			// For normal fields
1304 1304
 
1305 1305
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
1306 1306
 				// phpcs:ignore WordPress.Security.NonceVerification.Missing
1307
-				$other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ) : '';
1307
+				$other_val = isset( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ? sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ) : '';
1308 1308
 			} else {
1309
-				$other_val = sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][ $field['id'] ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
1309
+				$other_val = sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][$field['id']] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
1310 1310
 			}
1311 1311
 
1312 1312
 			return $other_val;
@@ -1316,8 +1316,8 @@  discard block
 block discarded – undo
1316 1316
 		if ( $field['type'] === 'checkbox' && is_array( $field['value'] ) ) {
1317 1317
 			// Check if there is an "other" val in saved value and make sure the
1318 1318
 			// "other" val is not equal to the Other checkbox option
1319
-			if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) {
1320
-				$other_val = $field['value'][ $opt_key ];
1319
+			if ( isset( $field['value'][$opt_key] ) && $field['options'][$opt_key] != $field['value'][$opt_key] ) {
1320
+				$other_val = $field['value'][$opt_key];
1321 1321
 			}
1322 1322
 		} else {
1323 1323
 			/**
@@ -1329,8 +1329,8 @@  discard block
 block discarded – undo
1329 1329
 				// Multi-select dropdowns - key is not preserved
1330 1330
 				if ( is_array( $field['value'] ) ) {
1331 1331
 					$o_key = array_search( $temp_val, $field['value'] );
1332
-					if ( isset( $field['value'][ $o_key ] ) ) {
1333
-						unset( $field['value'][ $o_key ], $o_key );
1332
+					if ( isset( $field['value'][$o_key] ) ) {
1333
+						unset( $field['value'][$o_key], $o_key );
1334 1334
 					}
1335 1335
 				} elseif ( $temp_val == $field['value'] ) {
1336 1336
 					// For radio and regular dropdowns
@@ -1538,11 +1538,11 @@  discard block
 block discarded – undo
1538 1538
 			foreach ( $val as $k => $v ) {
1539 1539
 				if ( is_string( $v ) ) {
1540 1540
 					if ( 'custom_html' === $k ) {
1541
-						$val[ $k ] = self::switch_ids_except_strings( $replace, $replace_with, array( '[if description]', '[description]', '[/if description]' ), $v );
1541
+						$val[$k] = self::switch_ids_except_strings( $replace, $replace_with, array( '[if description]', '[description]', '[/if description]' ), $v );
1542 1542
 						unset( $k, $v );
1543 1543
 						continue;
1544 1544
 					}
1545
-					$val[ $k ] = str_replace( $replace, $replace_with, $v );
1545
+					$val[$k] = str_replace( $replace, $replace_with, $v );
1546 1546
 					unset( $k, $v );
1547 1547
 				}
1548 1548
 			}
@@ -1571,8 +1571,8 @@  discard block
 block discarded – undo
1571 1571
 			if ( false === $index ) {
1572 1572
 				continue;
1573 1573
 			}
1574
-			unset( $replace[ $index ] );
1575
-			unset( $replace_with[ $index ] );
1574
+			unset( $replace[$index] );
1575
+			unset( $replace_with[$index] );
1576 1576
 		}
1577 1577
 		$value = str_replace( $replace, $replace_with, $value );
1578 1578
 		return $value;
@@ -1920,7 +1920,7 @@  discard block
 block discarded – undo
1920 1920
 			$countries['class'] = 'frm-countries-opts';
1921 1921
 		}
1922 1922
 
1923
-		$prepop[ __( 'Countries', 'formidable' ) ] = $countries;
1923
+		$prepop[__( 'Countries', 'formidable' )] = $countries;
1924 1924
 
1925 1925
 		// State abv.
1926 1926
 		$states    = self::get_us_states();
@@ -1930,7 +1930,7 @@  discard block
 block discarded – undo
1930 1930
 			$state_abv['class'] = 'frm-state-abv-opts';
1931 1931
 		}
1932 1932
 
1933
-		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1933
+		$prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv;
1934 1934
 
1935 1935
 		// States.
1936 1936
 		$states = array_values( $states );
@@ -1939,7 +1939,7 @@  discard block
 block discarded – undo
1939 1939
 			$states['class'] = 'frm-states-opts';
1940 1940
 		}
1941 1941
 
1942
-		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1942
+		$prepop[__( 'U.S. States', 'formidable' )] = $states;
1943 1943
 		unset( $state_abv, $states );
1944 1944
 
1945 1945
 		// Age.
@@ -1957,7 +1957,7 @@  discard block
 block discarded – undo
1957 1957
 			$ages['class'] = 'frm-age-opts';
1958 1958
 		}
1959 1959
 
1960
-		$prepop[ __( 'Age', 'formidable' ) ] = $ages;
1960
+		$prepop[__( 'Age', 'formidable' )] = $ages;
1961 1961
 
1962 1962
 		// Satisfaction.
1963 1963
 		$satisfaction = array(
@@ -1972,7 +1972,7 @@  discard block
 block discarded – undo
1972 1972
 			$satisfaction['class'] = 'frm-satisfaction-opts';
1973 1973
 		}
1974 1974
 
1975
-		$prepop[ __( 'Satisfaction', 'formidable' ) ] = $satisfaction;
1975
+		$prepop[__( 'Satisfaction', 'formidable' )] = $satisfaction;
1976 1976
 
1977 1977
 		// Importance.
1978 1978
 		$importance = array(
@@ -1987,7 +1987,7 @@  discard block
 block discarded – undo
1987 1987
 			$importance['class'] = 'frm-importance-opts';
1988 1988
 		}
1989 1989
 
1990
-		$prepop[ __( 'Importance', 'formidable' ) ] = $importance;
1990
+		$prepop[__( 'Importance', 'formidable' )] = $importance;
1991 1991
 
1992 1992
 		// Agreement.
1993 1993
 		$agreement = array(
@@ -2002,7 +2002,7 @@  discard block
 block discarded – undo
2002 2002
 			$agreement['class'] = 'frm-agreement-opts';
2003 2003
 		}
2004 2004
 
2005
-		$prepop[ __( 'Agreement', 'formidable' ) ] = $agreement;
2005
+		$prepop[__( 'Agreement', 'formidable' )] = $agreement;
2006 2006
 
2007 2007
 		// Likely.
2008 2008
 		$likely = array(
@@ -2017,7 +2017,7 @@  discard block
 block discarded – undo
2017 2017
 			$likely['class'] = 'frm-likely-opts';
2018 2018
 		}
2019 2019
 
2020
-		$prepop[ __( 'Likely', 'formidable' ) ] = $likely;
2020
+		$prepop[__( 'Likely', 'formidable' )] = $likely;
2021 2021
 
2022 2022
 		$prepop = apply_filters( 'frm_bulk_field_choices', $prepop );
2023 2023
 	}
@@ -2238,16 +2238,16 @@  discard block
 block discarded – undo
2238 2238
 	 */
2239 2239
 	private static function fill_image_setting_options( $options, &$args ) {
2240 2240
 		foreach ( $options as $key => $option ) {
2241
-			$args['options'][ $key ] = $option;
2241
+			$args['options'][$key] = $option;
2242 2242
 
2243 2243
 			if ( ! empty( $option['addon'] ) ) {
2244
-				$args['options'][ $key ]['custom_attrs'] = self::fill_image_setting_addon_link( $option );
2244
+				$args['options'][$key]['custom_attrs'] = self::fill_image_setting_addon_link( $option );
2245 2245
 			}
2246 2246
 
2247
-			unset( $args['options'][ $key ]['addon'] );
2247
+			unset( $args['options'][$key]['addon'] );
2248 2248
 			$fill = array( 'upgrade', 'message', 'content' );
2249 2249
 			foreach ( $fill as $f ) {
2250
-				unset( $args['options'][ $key ][ $f ], $f );
2250
+				unset( $args['options'][$key][$f], $f );
2251 2251
 			}
2252 2252
 		}
2253 2253
 	}
@@ -2268,8 +2268,8 @@  discard block
 block discarded – undo
2268 2268
 
2269 2269
 		$fill = array( 'upgrade', 'message', 'content' );
2270 2270
 		foreach ( $fill as $f ) {
2271
-			if ( isset( $option[ $f ] ) ) {
2272
-				$custom_attrs[ 'data-' . $f ] = $option[ $f ];
2271
+			if ( isset( $option[$f] ) ) {
2272
+				$custom_attrs['data-' . $f] = $option[$f];
2273 2273
 			}
2274 2274
 		}
2275 2275
 
@@ -2335,7 +2335,7 @@  discard block
 block discarded – undo
2335 2335
 
2336 2336
 		return array_filter(
2337 2337
 			$rows,
2338
-			function ( $row ) {
2338
+			function( $row ) {
2339 2339
 				FrmAppHelper::unserialize_or_decode( $row->field_options );
2340 2340
 				return is_array( $row->field_options ) && ! empty( $row->field_options['draft'] );
2341 2341
 			}
Please login to merge, or discard this patch.