Completed
Pull Request — master (#467)
by Stephanie
56s
created
classes/helpers/FrmAppHelper.php 1 patch
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 			'fill'   => '#4d4d4d',
158 158
 			'orange' => '#f05a24',
159 159
 		);
160
-		$atts     = array_merge( $defaults, $atts );
160
+		$atts = array_merge( $defaults, $atts );
161 161
 
162 162
 		return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 599.68 601.37" width="' . esc_attr( $atts['width'] ) . '" height="' . esc_attr( $atts['height'] ) . '">
163 163
 			<path fill="' . esc_attr( $atts['orange'] ) . '" d="M289.6 384h140v76h-140z"/>
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 	 * @return string
365 365
 	 */
366 366
 	public static function get_server_value( $value ) {
367
-		return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( wp_unslash( $_SERVER[ $value ] ) ) : '';
367
+		return isset( $_SERVER[$value] ) ? wp_strip_all_tags( wp_unslash( $_SERVER[$value] ) ) : '';
368 368
 	}
369 369
 
370 370
 	/**
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 		);
388 388
 		$ip = '';
389 389
 		foreach ( $ip_options as $key ) {
390
-			if ( ! isset( $_SERVER[ $key ] ) ) {
390
+			if ( ! isset( $_SERVER[$key] ) ) {
391 391
 				continue;
392 392
 			}
393 393
 
@@ -412,10 +412,10 @@  discard block
 block discarded – undo
412 412
 
413 413
 		if ( $src == 'get' ) {
414 414
 			// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
415
-			$value = isset( $_POST[ $param ] ) ? wp_unslash( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? wp_unslash( $_GET[ $param ] ) : $default );
416
-			if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
415
+			$value = isset( $_POST[$param] ) ? wp_unslash( $_POST[$param] ) : ( isset( $_GET[$param] ) ? wp_unslash( $_GET[$param] ) : $default );
416
+			if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) {
417 417
 				// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
418
-				$value = htmlspecialchars_decode( wp_unslash( $_GET[ $param ] ) );
418
+				$value = htmlspecialchars_decode( wp_unslash( $_GET[$param] ) );
419 419
 			}
420 420
 			self::sanitize_value( $sanitize, $value );
421 421
 		} else {
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 				}
437 437
 
438 438
 				$p     = trim( $p, ']' );
439
-				$value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
439
+				$value = isset( $value[$p] ) ? $value[$p] : $default;
440 440
 			}
441 441
 		}
442 442
 
@@ -492,26 +492,26 @@  discard block
 block discarded – undo
492 492
 			'sanitize' => 'sanitize_text_field',
493 493
 			'serialized' => false,
494 494
 		);
495
-		$args     = wp_parse_args( $args, $defaults );
495
+		$args = wp_parse_args( $args, $defaults );
496 496
 
497 497
 		$value = $args['default'];
498 498
 		if ( $args['type'] == 'get' ) {
499
-			if ( $_GET && isset( $_GET[ $args['param'] ] ) ) {
499
+			if ( $_GET && isset( $_GET[$args['param']] ) ) {
500 500
 				// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
501
-				$value = wp_unslash( $_GET[ $args['param'] ] );
501
+				$value = wp_unslash( $_GET[$args['param']] );
502 502
 			}
503 503
 		} elseif ( $args['type'] == 'post' ) {
504
-			if ( isset( $_POST[ $args['param'] ] ) ) {
504
+			if ( isset( $_POST[$args['param']] ) ) {
505 505
 				// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
506
-				$value = wp_unslash( $_POST[ $args['param'] ] );
506
+				$value = wp_unslash( $_POST[$args['param']] );
507 507
 				if ( $args['serialized'] === true && is_serialized_string( $value ) && is_serialized( $value ) ) {
508 508
 					self::unserialize_or_decode( $value );
509 509
 				}
510 510
 			}
511 511
 		} else {
512
-			if ( isset( $_REQUEST[ $args['param'] ] ) ) {
512
+			if ( isset( $_REQUEST[$args['param']] ) ) {
513 513
 				// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
514
-				$value = wp_unslash( $_REQUEST[ $args['param'] ] );
514
+				$value = wp_unslash( $_REQUEST[$args['param']] );
515 515
 			}
516 516
 		}
517 517
 
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 			if ( is_array( $value ) ) {
544 544
 				$temp_values = $value;
545 545
 				foreach ( $temp_values as $k => $v ) {
546
-					self::sanitize_value( $sanitize, $value[ $k ] );
546
+					self::sanitize_value( $sanitize, $value[$k] );
547 547
 				}
548 548
 			} else {
549 549
 				$value = call_user_func( $sanitize, $value );
@@ -554,8 +554,8 @@  discard block
 block discarded – undo
554 554
 	public static function sanitize_request( $sanitize_method, &$values ) {
555 555
 		$temp_values = $values;
556 556
 		foreach ( $temp_values as $k => $val ) {
557
-			if ( isset( $sanitize_method[ $k ] ) ) {
558
-				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
557
+			if ( isset( $sanitize_method[$k] ) ) {
558
+				$values[$k] = call_user_func( $sanitize_method[$k], $val );
559 559
 			}
560 560
 		}
561 561
 	}
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 		if ( is_array( $value ) ) {
579 579
 			$temp_values = $value;
580 580
 			foreach ( $temp_values as $k => $v ) {
581
-				self::decode_specialchars( $value[ $k ] );
581
+				self::decode_specialchars( $value[$k] );
582 582
 			}
583 583
 		} else {
584 584
 			self::decode_amp( $value );
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
 			$allowed_html = $html;
656 656
 		} elseif ( ! empty( $allowed ) ) {
657 657
 			foreach ( (array) $allowed as $a ) {
658
-				$allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array();
658
+				$allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array();
659 659
 			}
660 660
 		}
661 661
 
@@ -817,8 +817,8 @@  discard block
 block discarded – undo
817 817
 		}
818 818
 
819 819
 		global $wp_query;
820
-		if ( isset( $wp_query->query_vars[ $param ] ) ) {
821
-			$value = $wp_query->query_vars[ $param ];
820
+		if ( isset( $wp_query->query_vars[$param] ) ) {
821
+			$value = $wp_query->query_vars[$param];
822 822
 		}
823 823
 
824 824
 		return $value;
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
 				'new_file_path' => self::plugin_path() . '/js',
997 997
 			)
998 998
 		);
999
-		$new_file  = new FrmCreateFile( $file_atts );
999
+		$new_file = new FrmCreateFile( $file_atts );
1000 1000
 
1001 1001
 		$files = array(
1002 1002
 			self::plugin_path() . '/js/jquery/jquery.placeholder.min.js',
@@ -1388,8 +1388,8 @@  discard block
 block discarded – undo
1388 1388
 			return $error;
1389 1389
 		}
1390 1390
 
1391
-		$nonce_value = ( $_REQUEST && isset( $_REQUEST[ $nonce_name ] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST[ $nonce_name ] ) ) : '';
1392
-		if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $nonce_value, $nonce ) ) ) {
1391
+		$nonce_value = ( $_REQUEST && isset( $_REQUEST[$nonce_name] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST[$nonce_name] ) ) : '';
1392
+		if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $nonce_value, $nonce ) ) ) {
1393 1393
 			$frm_settings = self::get_settings();
1394 1394
 			$error        = $frm_settings->admin_permission;
1395 1395
 		}
@@ -1424,7 +1424,7 @@  discard block
 block discarded – undo
1424 1424
 			} else {
1425 1425
 				foreach ( $value as $k => $v ) {
1426 1426
 					if ( ! is_array( $v ) ) {
1427
-						$value[ $k ] = call_user_func( $original_function, $v );
1427
+						$value[$k] = call_user_func( $original_function, $v );
1428 1428
 					}
1429 1429
 				}
1430 1430
 			}
@@ -1449,7 +1449,7 @@  discard block
 block discarded – undo
1449 1449
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
1450 1450
 			} else {
1451 1451
 				if ( $keys == 'keep' ) {
1452
-					$return[ $key ] = $value;
1452
+					$return[$key] = $value;
1453 1453
 				} else {
1454 1454
 					$return[] = $value;
1455 1455
 				}
@@ -1513,11 +1513,11 @@  discard block
 block discarded – undo
1513 1513
 		}
1514 1514
 
1515 1515
 		$ver = $default;
1516
-		if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
1516
+		if ( ! isset( $wp_scripts->registered[$handle] ) ) {
1517 1517
 			return $ver;
1518 1518
 		}
1519 1519
 
1520
-		$query = $wp_scripts->registered[ $handle ];
1520
+		$query = $wp_scripts->registered[$handle];
1521 1521
 		if ( is_object( $query ) && ! empty( $query->ver ) ) {
1522 1522
 			$ver = $query->ver;
1523 1523
 		}
@@ -1675,7 +1675,7 @@  discard block
 block discarded – undo
1675 1675
 
1676 1676
 		foreach ( array( 'name', 'description' ) as $var ) {
1677 1677
 			$default_val    = isset( $record->{$var} ) ? $record->{$var} : '';
1678
-			$values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
1678
+			$values[$var] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
1679 1679
 			unset( $var, $default_val );
1680 1680
 		}
1681 1681
 
@@ -1733,9 +1733,9 @@  discard block
 block discarded – undo
1733 1733
 			}
1734 1734
 		}
1735 1735
 
1736
-		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1737
-		if ( isset( $post_values['item_meta'][ $field->id ] ) ) {
1738
-			$new_value = $post_values['item_meta'][ $field->id ];
1736
+		$field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type;
1737
+		if ( isset( $post_values['item_meta'][$field->id] ) ) {
1738
+			$new_value = $post_values['item_meta'][$field->id];
1739 1739
 			self::unserialize_or_decode( $new_value );
1740 1740
 		} else {
1741 1741
 			$new_value = $meta_value;
@@ -1756,7 +1756,7 @@  discard block
 block discarded – undo
1756 1756
 
1757 1757
 		$field_array = array_merge( (array) $field->field_options, $field_array );
1758 1758
 
1759
-		$values['fields'][ $field->id ] = $field_array;
1759
+		$values['fields'][$field->id] = $field_array;
1760 1760
 	}
1761 1761
 
1762 1762
 	/**
@@ -1803,11 +1803,11 @@  discard block
 block discarded – undo
1803 1803
 		}
1804 1804
 
1805 1805
 		foreach ( $form->options as $opt => $value ) {
1806
-			if ( isset( $post_values[ $opt ] ) ) {
1807
-				$values[ $opt ] = $post_values[ $opt ];
1808
-				self::unserialize_or_decode( $values[ $opt ] );
1806
+			if ( isset( $post_values[$opt] ) ) {
1807
+				$values[$opt] = $post_values[$opt];
1808
+				self::unserialize_or_decode( $values[$opt] );
1809 1809
 			} else {
1810
-				$values[ $opt ] = $value;
1810
+				$values[$opt] = $value;
1811 1811
 			}
1812 1812
 		}
1813 1813
 
@@ -1821,8 +1821,8 @@  discard block
 block discarded – undo
1821 1821
 		$form_defaults = FrmFormsHelper::get_default_opts();
1822 1822
 
1823 1823
 		foreach ( $form_defaults as $opt => $default ) {
1824
-			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1825
-				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1824
+			if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) {
1825
+				$values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default;
1826 1826
 			}
1827 1827
 
1828 1828
 			unset( $opt, $default );
@@ -1833,8 +1833,8 @@  discard block
 block discarded – undo
1833 1833
 		}
1834 1834
 
1835 1835
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1836
-			if ( ! isset( $values[ $h . '_html' ] ) ) {
1837
-				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1836
+			if ( ! isset( $values[$h . '_html'] ) ) {
1837
+				$values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) );
1838 1838
 			}
1839 1839
 			unset( $h );
1840 1840
 		}
@@ -1986,25 +1986,25 @@  discard block
 block discarded – undo
1986 1986
 		if ( ! is_numeric( $levels ) ) {
1987 1987
 			// Show time in specified unit.
1988 1988
 			$levels = self::get_unit( $levels );
1989
-			if ( isset( $time_strings[ $levels ] ) ) {
1989
+			if ( isset( $time_strings[$levels] ) ) {
1990 1990
 				$diff = array(
1991 1991
 					$levels => self::time_format( $levels, $diff ),
1992 1992
 				);
1993 1993
 				$time_strings = array(
1994
-					$levels => $time_strings[ $levels ],
1994
+					$levels => $time_strings[$levels],
1995 1995
 				);
1996 1996
 			}
1997 1997
 			$levels = 1;
1998 1998
 		}
1999 1999
 
2000 2000
 		foreach ( $time_strings as $k => $v ) {
2001
-			if ( isset( $diff[ $k ] ) && $diff[ $k ] ) {
2002
-				$time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] );
2003
-			} elseif ( isset( $diff[ $k ] ) && count( $time_strings ) === 1 ) {
2001
+			if ( isset( $diff[$k] ) && $diff[$k] ) {
2002
+				$time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] );
2003
+			} elseif ( isset( $diff[$k] ) && count( $time_strings ) === 1 ) {
2004 2004
 				// Account for 0.
2005
-				$time_strings[ $k ] = $diff[ $k ] . ' ' . $v[1];
2005
+				$time_strings[$k] = $diff[$k] . ' ' . $v[1];
2006 2006
 			} else {
2007
-				unset( $time_strings[ $k ] );
2007
+				unset( $time_strings[$k] );
2008 2008
 			}
2009 2009
 		}
2010 2010
 
@@ -2023,8 +2023,8 @@  discard block
 block discarded – undo
2023 2023
 			'y' => 'y',
2024 2024
 			'd' => 'days',
2025 2025
 		);
2026
-		if ( isset( $return[ $unit ] ) ) {
2027
-			return $diff[ $return[ $unit ] ];
2026
+		if ( isset( $return[$unit] ) ) {
2027
+			return $diff[$return[$unit]];
2028 2028
 		}
2029 2029
 
2030 2030
 		$total = $diff['days'] * self::convert_time( 'd', $unit );
@@ -2032,11 +2032,11 @@  discard block
 block discarded – undo
2032 2032
 		$times = array( 'h', 'i', 's' );
2033 2033
 
2034 2034
 		foreach ( $times as $time ) {
2035
-			if ( ! isset( $diff[ $time ] ) ) {
2035
+			if ( ! isset( $diff[$time] ) ) {
2036 2036
 				continue;
2037 2037
 			}
2038 2038
 
2039
-			$total += $diff[ $time ] * self::convert_time( $time, $unit );
2039
+			$total += $diff[$time] * self::convert_time( $time, $unit );
2040 2040
 		}
2041 2041
 
2042 2042
 		return floor( $total );
@@ -2056,7 +2056,7 @@  discard block
 block discarded – undo
2056 2056
 			'y' => DAY_IN_SECONDS * 365.25,
2057 2057
 		);
2058 2058
 
2059
-		return $convert[ $from ] / $convert[ $to ];
2059
+		return $convert[$from] / $convert[$to];
2060 2060
 	}
2061 2061
 
2062 2062
 	/**
@@ -2064,7 +2064,7 @@  discard block
 block discarded – undo
2064 2064
 	 */
2065 2065
 	private static function get_unit( $unit ) {
2066 2066
 		$units = self::get_time_strings();
2067
-		if ( isset( $units[ $unit ] ) || is_numeric( $unit ) ) {
2067
+		if ( isset( $units[$unit] ) || is_numeric( $unit ) ) {
2068 2068
 			return $unit;
2069 2069
 		}
2070 2070
 
@@ -2175,17 +2175,17 @@  discard block
 block discarded – undo
2175 2175
 
2176 2176
 					case 1:
2177 2177
 						$l2 = $name;
2178
-						self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
2178
+						self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] );
2179 2179
 						break;
2180 2180
 
2181 2181
 					case 2:
2182 2182
 						$l3 = $name;
2183
-						self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
2183
+						self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] );
2184 2184
 						break;
2185 2185
 
2186 2186
 					case 3:
2187 2187
 						$l4 = $name;
2188
-						self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
2188
+						self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] );
2189 2189
 				}
2190 2190
 
2191 2191
 				unset( $this_val, $n );
@@ -2204,8 +2204,8 @@  discard block
 block discarded – undo
2204 2204
 	public static function add_value_to_array( $name, $l1, $val, &$vars ) {
2205 2205
 		if ( $name == '' ) {
2206 2206
 			$vars[] = $val;
2207
-		} elseif ( ! isset( $vars[ $l1 ] ) ) {
2208
-			$vars[ $l1 ] = $val;
2207
+		} elseif ( ! isset( $vars[$l1] ) ) {
2208
+			$vars[$l1] = $val;
2209 2209
 		}
2210 2210
 	}
2211 2211
 
@@ -2221,7 +2221,7 @@  discard block
 block discarded – undo
2221 2221
 			'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ),
2222 2222
 		);
2223 2223
 
2224
-		if ( ! isset( $tooltips[ $name ] ) ) {
2224
+		if ( ! isset( $tooltips[$name] ) ) {
2225 2225
 			return;
2226 2226
 		}
2227 2227
 
@@ -2231,7 +2231,7 @@  discard block
 block discarded – undo
2231 2231
 			echo ' class="frm_help"';
2232 2232
 		}
2233 2233
 
2234
-		echo ' title="' . esc_attr( $tooltips[ $name ] );
2234
+		echo ' title="' . esc_attr( $tooltips[$name] );
2235 2235
 
2236 2236
 		if ( 'open' != $class ) {
2237 2237
 			echo '"';
@@ -2286,13 +2286,13 @@  discard block
 block discarded – undo
2286 2286
 	}
2287 2287
 
2288 2288
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
2289
-		if ( ! isset( $post_content[ $key ] ) || is_numeric( $val ) ) {
2289
+		if ( ! isset( $post_content[$key] ) || is_numeric( $val ) ) {
2290 2290
 			return;
2291 2291
 		}
2292 2292
 
2293 2293
 		if ( is_array( $val ) ) {
2294 2294
 			foreach ( $val as $k1 => $v1 ) {
2295
-				self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] );
2295
+				self::prepare_action_slashes( $v1, $k1, $post_content[$key] );
2296 2296
 				unset( $k1, $v1 );
2297 2297
 			}
2298 2298
 		} else {
@@ -2300,7 +2300,7 @@  discard block
 block discarded – undo
2300 2300
 			$val = stripslashes( $val );
2301 2301
 
2302 2302
 			// Add backslashes before double quotes and forward slashes only
2303
-			$post_content[ $key ] = addcslashes( $val, '"\\/' );
2303
+			$post_content[$key] = addcslashes( $val, '"\\/' );
2304 2304
 		}
2305 2305
 	}
2306 2306
 
@@ -2359,14 +2359,14 @@  discard block
 block discarded – undo
2359 2359
 				continue;
2360 2360
 			}
2361 2361
 			$key = $input['name'];
2362
-			if ( isset( $formatted[ $key ] ) ) {
2363
-				if ( is_array( $formatted[ $key ] ) ) {
2364
-					$formatted[ $key ][] = $input['value'];
2362
+			if ( isset( $formatted[$key] ) ) {
2363
+				if ( is_array( $formatted[$key] ) ) {
2364
+					$formatted[$key][] = $input['value'];
2365 2365
 				} else {
2366
-					$formatted[ $key ] = array( $formatted[ $key ], $input['value'] );
2366
+					$formatted[$key] = array( $formatted[$key], $input['value'] );
2367 2367
 				}
2368 2368
 			} else {
2369
-				$formatted[ $key ] = $input['value'];
2369
+				$formatted[$key] = $input['value'];
2370 2370
 			}
2371 2371
 		}
2372 2372
 
Please login to merge, or discard this patch.