Completed
Push — master ( 81d0ae...22327a )
by Stephanie
02:13
created
classes/helpers/FrmAppHelper.php 2 patches
Doc Comments   +26 added lines patch added patch discarded remove patch
@@ -69,6 +69,9 @@  discard block
 block discarded – undo
69 69
 		return $url;
70 70
 	}
71 71
 
72
+	/**
73
+	 * @return string
74
+	 */
72 75
 	public static function get_affiliate() {
73 76
 		return absint( apply_filters( 'frm_affiliate_id', 0 ) );
74 77
 	}
@@ -129,6 +132,9 @@  discard block
 block discarded – undo
129 132
 		return $frm_settings;
130 133
 	}
131 134
 
135
+	/**
136
+	 * @return string
137
+	 */
132 138
 	public static function get_menu_name() {
133 139
 		$frm_settings = self::get_settings();
134 140
 
@@ -412,6 +418,9 @@  discard block
 block discarded – undo
412 418
 		return $value;
413 419
 	}
414 420
 
421
+	/**
422
+	 * @param string $param
423
+	 */
415 424
 	public static function get_post_param( $param, $default = '', $sanitize = '', $serialized = false ) {
416 425
 		return self::get_simple_request(
417 426
 			array(
@@ -1183,6 +1192,9 @@  discard block
 block discarded – undo
1183 1192
 		return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current );
1184 1193
 	}
1185 1194
 
1195
+	/**
1196
+	 * @param string $function
1197
+	 */
1186 1198
 	public static function recursive_function_map( $value, $function ) {
1187 1199
 		if ( is_array( $value ) ) {
1188 1200
 			$original_function = $function;
@@ -1231,6 +1243,9 @@  discard block
 block discarded – undo
1231 1243
 		return $return;
1232 1244
 	}
1233 1245
 
1246
+	/**
1247
+	 * @return string
1248
+	 */
1234 1249
 	public static function esc_textarea( $text, $is_rich_text = false ) {
1235 1250
 		$safe_text = str_replace( '"', '"', $text );
1236 1251
 		if ( ! $is_rich_text ) {
@@ -1443,6 +1458,9 @@  discard block
 block discarded – undo
1443 1458
 		return $values;
1444 1459
 	}
1445 1460
 
1461
+	/**
1462
+	 * @param string $fields
1463
+	 */
1446 1464
 	private static function prepare_field_arrays( $fields, $record, array &$values, $args ) {
1447 1465
 		if ( ! empty( $fields ) ) {
1448 1466
 			foreach ( (array) $fields as $field ) {
@@ -1646,6 +1664,9 @@  discard block
 block discarded – undo
1646 1664
 		return $sub . ( ( $len < $original_len ) ? $continue : '' );
1647 1665
 	}
1648 1666
 
1667
+	/**
1668
+	 * @param string[] $function_names
1669
+	 */
1649 1670
 	public static function mb_function( $function_names, $args ) {
1650 1671
 		$mb_function_name = $function_names[0];
1651 1672
 		$function_name    = $function_names[1];
@@ -1680,6 +1701,9 @@  discard block
 block discarded – undo
1680 1701
 		return $formatted;
1681 1702
 	}
1682 1703
 
1704
+	/**
1705
+	 * @param string $time_format
1706
+	 */
1683 1707
 	private static function add_time_to_date( $time_format, $date ) {
1684 1708
 		if ( empty( $time_format ) ) {
1685 1709
 			$time_format = get_option( 'time_format' );
@@ -2004,6 +2028,7 @@  discard block
 block discarded – undo
2004 2028
 
2005 2029
 	/**
2006 2030
 	 * @since 4.02.03
2031
+	 * @return string
2007 2032
 	 */
2008 2033
 	public static function maybe_json_encode( $value ) {
2009 2034
 		if ( is_array( $value ) ) {
@@ -2157,6 +2182,7 @@  discard block
 block discarded – undo
2157 2182
 	 * If Pro is far outdated, show a message.
2158 2183
 	 *
2159 2184
 	 * @since 4.0.01
2185
+	 * @param string $min_version
2160 2186
 	 */
2161 2187
 	public static function min_pro_version_notice( $min_version ) {
2162 2188
 		if ( ! self::is_formidable_admin() ) {
Please login to merge, or discard this patch.
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 			'fill'   => '#4d4d4d',
146 146
 			'orange' => '#f05a24',
147 147
 		);
148
-		$atts     = array_merge( $defaults, $atts );
148
+		$atts = array_merge( $defaults, $atts );
149 149
 
150 150
 		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'] ) . '">
151 151
 			<path fill="' . esc_attr( $atts['orange'] ) . '" d="M289.6 384h140v76h-140z"/>
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 	 * @return string
334 334
 	 */
335 335
 	public static function get_server_value( $value ) {
336
-		return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( wp_unslash( $_SERVER[ $value ] ) ) : '';
336
+		return isset( $_SERVER[$value] ) ? wp_strip_all_tags( wp_unslash( $_SERVER[$value] ) ) : '';
337 337
 	}
338 338
 
339 339
 	/**
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 		);
357 357
 		$ip = '';
358 358
 		foreach ( $ip_options as $key ) {
359
-			if ( ! isset( $_SERVER[ $key ] ) ) {
359
+			if ( ! isset( $_SERVER[$key] ) ) {
360 360
 				continue;
361 361
 			}
362 362
 
@@ -381,10 +381,10 @@  discard block
 block discarded – undo
381 381
 
382 382
 		if ( $src == 'get' ) {
383 383
 			// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
384
-			$value = isset( $_POST[ $param ] ) ? wp_unslash( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? wp_unslash( $_GET[ $param ] ) : $default );
385
-			if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
384
+			$value = isset( $_POST[$param] ) ? wp_unslash( $_POST[$param] ) : ( isset( $_GET[$param] ) ? wp_unslash( $_GET[$param] ) : $default );
385
+			if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) {
386 386
 				// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
387
-				$value = htmlspecialchars_decode( wp_unslash( $_GET[ $param ] ) );
387
+				$value = htmlspecialchars_decode( wp_unslash( $_GET[$param] ) );
388 388
 			}
389 389
 			self::sanitize_value( $sanitize, $value );
390 390
 		} else {
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 				}
406 406
 
407 407
 				$p     = trim( $p, ']' );
408
-				$value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
408
+				$value = isset( $value[$p] ) ? $value[$p] : $default;
409 409
 			}
410 410
 		}
411 411
 
@@ -461,26 +461,26 @@  discard block
 block discarded – undo
461 461
 			'sanitize' => 'sanitize_text_field',
462 462
 			'serialized' => false,
463 463
 		);
464
-		$args     = wp_parse_args( $args, $defaults );
464
+		$args = wp_parse_args( $args, $defaults );
465 465
 
466 466
 		$value = $args['default'];
467 467
 		if ( $args['type'] == 'get' ) {
468
-			if ( $_GET && isset( $_GET[ $args['param'] ] ) ) {
468
+			if ( $_GET && isset( $_GET[$args['param']] ) ) {
469 469
 				// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
470
-				$value = wp_unslash( $_GET[ $args['param'] ] );
470
+				$value = wp_unslash( $_GET[$args['param']] );
471 471
 			}
472 472
 		} elseif ( $args['type'] == 'post' ) {
473
-			if ( isset( $_POST[ $args['param'] ] ) ) {
473
+			if ( isset( $_POST[$args['param']] ) ) {
474 474
 				// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
475
-				$value = wp_unslash( $_POST[ $args['param'] ] );
475
+				$value = wp_unslash( $_POST[$args['param']] );
476 476
 				if ( $args['serialized'] === true && is_serialized_string( $value ) && is_serialized( $value ) ) {
477 477
 					self::unserialize_or_decode( $value );
478 478
 				}
479 479
 			}
480 480
 		} else {
481
-			if ( isset( $_REQUEST[ $args['param'] ] ) ) {
481
+			if ( isset( $_REQUEST[$args['param']] ) ) {
482 482
 				// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
483
-				$value = wp_unslash( $_REQUEST[ $args['param'] ] );
483
+				$value = wp_unslash( $_REQUEST[$args['param']] );
484 484
 			}
485 485
 		}
486 486
 
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 			if ( is_array( $value ) ) {
513 513
 				$temp_values = $value;
514 514
 				foreach ( $temp_values as $k => $v ) {
515
-					self::sanitize_value( $sanitize, $value[ $k ] );
515
+					self::sanitize_value( $sanitize, $value[$k] );
516 516
 				}
517 517
 			} else {
518 518
 				$value = call_user_func( $sanitize, $value );
@@ -523,8 +523,8 @@  discard block
 block discarded – undo
523 523
 	public static function sanitize_request( $sanitize_method, &$values ) {
524 524
 		$temp_values = $values;
525 525
 		foreach ( $temp_values as $k => $val ) {
526
-			if ( isset( $sanitize_method[ $k ] ) ) {
527
-				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
526
+			if ( isset( $sanitize_method[$k] ) ) {
527
+				$values[$k] = call_user_func( $sanitize_method[$k], $val );
528 528
 			}
529 529
 		}
530 530
 	}
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 		if ( is_array( $value ) ) {
548 548
 			$temp_values = $value;
549 549
 			foreach ( $temp_values as $k => $v ) {
550
-				self::decode_specialchars( $value[ $k ] );
550
+				self::decode_specialchars( $value[$k] );
551 551
 			}
552 552
 		} else {
553 553
 			$value = wp_specialchars_decode( $value, ENT_COMPAT );
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
 			$allowed_html = $html;
581 581
 		} elseif ( ! empty( $allowed ) ) {
582 582
 			foreach ( (array) $allowed as $a ) {
583
-				$allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array();
583
+				$allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array();
584 584
 			}
585 585
 		}
586 586
 
@@ -737,8 +737,8 @@  discard block
 block discarded – undo
737 737
 		}
738 738
 
739 739
 		global $wp_query;
740
-		if ( isset( $wp_query->query_vars[ $param ] ) ) {
741
-			$value = $wp_query->query_vars[ $param ];
740
+		if ( isset( $wp_query->query_vars[$param] ) ) {
741
+			$value = $wp_query->query_vars[$param];
742 742
 		}
743 743
 
744 744
 		return $value;
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
 				'new_file_path' => self::plugin_path() . '/js',
903 903
 			)
904 904
 		);
905
-		$new_file  = new FrmCreateFile( $file_atts );
905
+		$new_file = new FrmCreateFile( $file_atts );
906 906
 
907 907
 		$files = array(
908 908
 			self::plugin_path() . '/js/jquery/jquery.placeholder.min.js',
@@ -1160,8 +1160,8 @@  discard block
 block discarded – undo
1160 1160
 			return $error;
1161 1161
 		}
1162 1162
 
1163
-		$nonce_value = ( $_REQUEST && isset( $_REQUEST[ $nonce_name ] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST[ $nonce_name ] ) ) : '';
1164
-		if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $nonce_value, $nonce ) ) ) {
1163
+		$nonce_value = ( $_REQUEST && isset( $_REQUEST[$nonce_name] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST[$nonce_name] ) ) : '';
1164
+		if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $nonce_value, $nonce ) ) ) {
1165 1165
 			$frm_settings = self::get_settings();
1166 1166
 			$error        = $frm_settings->admin_permission;
1167 1167
 		}
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
 			} else {
1197 1197
 				foreach ( $value as $k => $v ) {
1198 1198
 					if ( ! is_array( $v ) ) {
1199
-						$value[ $k ] = call_user_func( $original_function, $v );
1199
+						$value[$k] = call_user_func( $original_function, $v );
1200 1200
 					}
1201 1201
 				}
1202 1202
 			}
@@ -1221,7 +1221,7 @@  discard block
 block discarded – undo
1221 1221
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
1222 1222
 			} else {
1223 1223
 				if ( $keys == 'keep' ) {
1224
-					$return[ $key ] = $value;
1224
+					$return[$key] = $value;
1225 1225
 				} else {
1226 1226
 					$return[] = $value;
1227 1227
 				}
@@ -1285,11 +1285,11 @@  discard block
 block discarded – undo
1285 1285
 		}
1286 1286
 
1287 1287
 		$ver = $default;
1288
-		if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
1288
+		if ( ! isset( $wp_scripts->registered[$handle] ) ) {
1289 1289
 			return $ver;
1290 1290
 		}
1291 1291
 
1292
-		$query = $wp_scripts->registered[ $handle ];
1292
+		$query = $wp_scripts->registered[$handle];
1293 1293
 		if ( is_object( $query ) && ! empty( $query->ver ) ) {
1294 1294
 			$ver = $query->ver;
1295 1295
 		}
@@ -1424,7 +1424,7 @@  discard block
 block discarded – undo
1424 1424
 
1425 1425
 		foreach ( array( 'name', 'description' ) as $var ) {
1426 1426
 			$default_val    = isset( $record->{$var} ) ? $record->{$var} : '';
1427
-			$values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
1427
+			$values[$var] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
1428 1428
 			unset( $var, $default_val );
1429 1429
 		}
1430 1430
 
@@ -1479,9 +1479,9 @@  discard block
 block discarded – undo
1479 1479
 			}
1480 1480
 		}
1481 1481
 
1482
-		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1483
-		if ( isset( $post_values['item_meta'][ $field->id ] ) ) {
1484
-			$new_value = $post_values['item_meta'][ $field->id ];
1482
+		$field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type;
1483
+		if ( isset( $post_values['item_meta'][$field->id] ) ) {
1484
+			$new_value = $post_values['item_meta'][$field->id];
1485 1485
 			self::unserialize_or_decode( $new_value );
1486 1486
 		} else {
1487 1487
 			$new_value = $meta_value;
@@ -1502,7 +1502,7 @@  discard block
 block discarded – undo
1502 1502
 
1503 1503
 		$field_array = array_merge( $field->field_options, $field_array );
1504 1504
 
1505
-		$values['fields'][ $field->id ] = $field_array;
1505
+		$values['fields'][$field->id] = $field_array;
1506 1506
 	}
1507 1507
 
1508 1508
 	/**
@@ -1549,11 +1549,11 @@  discard block
 block discarded – undo
1549 1549
 		}
1550 1550
 
1551 1551
 		foreach ( $form->options as $opt => $value ) {
1552
-			if ( isset( $post_values[ $opt ] ) ) {
1553
-				$values[ $opt ] = $post_values[ $opt ];
1554
-				self::unserialize_or_decode( $values[ $opt ] );
1552
+			if ( isset( $post_values[$opt] ) ) {
1553
+				$values[$opt] = $post_values[$opt];
1554
+				self::unserialize_or_decode( $values[$opt] );
1555 1555
 			} else {
1556
-				$values[ $opt ] = $value;
1556
+				$values[$opt] = $value;
1557 1557
 			}
1558 1558
 		}
1559 1559
 
@@ -1567,8 +1567,8 @@  discard block
 block discarded – undo
1567 1567
 		$form_defaults = FrmFormsHelper::get_default_opts();
1568 1568
 
1569 1569
 		foreach ( $form_defaults as $opt => $default ) {
1570
-			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1571
-				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1570
+			if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) {
1571
+				$values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default;
1572 1572
 			}
1573 1573
 
1574 1574
 			unset( $opt, $default );
@@ -1579,8 +1579,8 @@  discard block
 block discarded – undo
1579 1579
 		}
1580 1580
 
1581 1581
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1582
-			if ( ! isset( $values[ $h . '_html' ] ) ) {
1583
-				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1582
+			if ( ! isset( $values[$h . '_html'] ) ) {
1583
+				$values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) );
1584 1584
 			}
1585 1585
 			unset( $h );
1586 1586
 		}
@@ -1730,10 +1730,10 @@  discard block
 block discarded – undo
1730 1730
 		$time_strings = self::get_time_strings();
1731 1731
 
1732 1732
 		foreach ( $time_strings as $k => $v ) {
1733
-			if ( $diff[ $k ] ) {
1734
-				$time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] );
1733
+			if ( $diff[$k] ) {
1734
+				$time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] );
1735 1735
 			} else {
1736
-				unset( $time_strings[ $k ] );
1736
+				unset( $time_strings[$k] );
1737 1737
 			}
1738 1738
 		}
1739 1739
 
@@ -1814,17 +1814,17 @@  discard block
 block discarded – undo
1814 1814
 
1815 1815
 					case 1:
1816 1816
 						$l2 = $name;
1817
-						self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1817
+						self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] );
1818 1818
 						break;
1819 1819
 
1820 1820
 					case 2:
1821 1821
 						$l3 = $name;
1822
-						self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1822
+						self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] );
1823 1823
 						break;
1824 1824
 
1825 1825
 					case 3:
1826 1826
 						$l4 = $name;
1827
-						self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1827
+						self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] );
1828 1828
 				}
1829 1829
 
1830 1830
 				unset( $this_val, $n );
@@ -1843,8 +1843,8 @@  discard block
 block discarded – undo
1843 1843
 	public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1844 1844
 		if ( $name == '' ) {
1845 1845
 			$vars[] = $val;
1846
-		} elseif ( ! isset( $vars[ $l1 ] ) ) {
1847
-			$vars[ $l1 ] = $val;
1846
+		} elseif ( ! isset( $vars[$l1] ) ) {
1847
+			$vars[$l1] = $val;
1848 1848
 		}
1849 1849
 	}
1850 1850
 
@@ -1860,7 +1860,7 @@  discard block
 block discarded – undo
1860 1860
 			'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() ) ),
1861 1861
 		);
1862 1862
 
1863
-		if ( ! isset( $tooltips[ $name ] ) ) {
1863
+		if ( ! isset( $tooltips[$name] ) ) {
1864 1864
 			return;
1865 1865
 		}
1866 1866
 
@@ -1870,7 +1870,7 @@  discard block
 block discarded – undo
1870 1870
 			echo ' class="frm_help"';
1871 1871
 		}
1872 1872
 
1873
-		echo ' title="' . esc_attr( $tooltips[ $name ] );
1873
+		echo ' title="' . esc_attr( $tooltips[$name] );
1874 1874
 
1875 1875
 		if ( 'open' != $class ) {
1876 1876
 			echo '"';
@@ -1923,13 +1923,13 @@  discard block
 block discarded – undo
1923 1923
 	}
1924 1924
 
1925 1925
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1926
-		if ( ! isset( $post_content[ $key ] ) ) {
1926
+		if ( ! isset( $post_content[$key] ) ) {
1927 1927
 			return;
1928 1928
 		}
1929 1929
 
1930 1930
 		if ( is_array( $val ) ) {
1931 1931
 			foreach ( $val as $k1 => $v1 ) {
1932
-				self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] );
1932
+				self::prepare_action_slashes( $v1, $k1, $post_content[$key] );
1933 1933
 				unset( $k1, $v1 );
1934 1934
 			}
1935 1935
 		} else {
@@ -1937,7 +1937,7 @@  discard block
 block discarded – undo
1937 1937
 			$val = stripslashes( $val );
1938 1938
 
1939 1939
 			// Add backslashes before double quotes and forward slashes only
1940
-			$post_content[ $key ] = addcslashes( $val, '"\\/' );
1940
+			$post_content[$key] = addcslashes( $val, '"\\/' );
1941 1941
 		}
1942 1942
 	}
1943 1943
 
@@ -1988,14 +1988,14 @@  discard block
 block discarded – undo
1988 1988
 
1989 1989
 		foreach ( $form as $input ) {
1990 1990
 			$key = $input['name'];
1991
-			if ( isset( $formatted[ $key ] ) ) {
1992
-				if ( is_array( $formatted[ $key ] ) ) {
1993
-					$formatted[ $key ][] = $input['value'];
1991
+			if ( isset( $formatted[$key] ) ) {
1992
+				if ( is_array( $formatted[$key] ) ) {
1993
+					$formatted[$key][] = $input['value'];
1994 1994
 				} else {
1995
-					$formatted[ $key ] = array( $formatted[ $key ], $input['value'] );
1995
+					$formatted[$key] = array( $formatted[$key], $input['value'] );
1996 1996
 				}
1997 1997
 			} else {
1998
-				$formatted[ $key ] = $input['value'];
1998
+				$formatted[$key] = $input['value'];
1999 1999
 			}
2000 2000
 		}
2001 2001
 
Please login to merge, or discard this patch.
classes/models/FrmFormAction.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -2,15 +2,15 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmFormAction {
4 4
 
5
-	public $id_base;         // Root id for all actions of this type.
6
-	public $name;            // Name for this action type.
5
+	public $id_base; // Root id for all actions of this type.
6
+	public $name; // Name for this action type.
7 7
 	public $option_name;
8
-	public $action_options;  // Option array passed to wp_register_sidebar_widget()
8
+	public $action_options; // Option array passed to wp_register_sidebar_widget()
9 9
 	public $control_options; // Option array passed to wp_register_widget_control()
10 10
 
11
-	public $form_id;         // The ID of the form to evaluate
12
-	public $number = false;  // Unique ID number of the current instance.
13
-	public $id = '';         // Unique ID string of the current instance (id_base-number)
11
+	public $form_id; // The ID of the form to evaluate
12
+	public $number = false; // Unique ID number of the current instance.
13
+	public $id = ''; // Unique ID string of the current instance (id_base-number)
14 14
 	public $updated = false; // Set true when we update the data after a POST submit - makes sure we don't do it twice.
15 15
 
16 16
 	// Member functions that you must over-ride.
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
 		$groups = FrmFormActionsController::form_action_groups();
134 134
 		$group  = 'misc';
135 135
 
136
-		if ( isset( $action_options['group'] ) && isset( $groups[ $action_options['group'] ] ) ) {
136
+		if ( isset( $action_options['group'] ) && isset( $groups[$action_options['group']] ) ) {
137 137
 			$group = $action_options['group'];
138
-		} elseif ( isset( $groups[ $this->id_base ] ) ) {
138
+		} elseif ( isset( $groups[$this->id_base] ) ) {
139 139
 			$group = $this->id_base;
140 140
 		} else {
141 141
 			foreach ( $groups as $name => $check_group ) {
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 			}
147 147
 		}
148 148
 
149
-		$groups[ $group ]['id'] = $group;
150
-		return $groups[ $group ];
149
+		$groups[$group]['id'] = $group;
150
+		return $groups[$group];
151 151
 	}
152 152
 
153 153
 	/**
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 	 * @return integer $post_id
250 250
 	 */
251 251
 	public function maybe_create_action( $action, $forms ) {
252
-		if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && isset( $forms[ $action['menu_order'] ] ) && $forms[ $action['menu_order'] ] == 'updated' ) {
252
+		if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && isset( $forms[$action['menu_order']] ) && $forms[$action['menu_order']] == 'updated' ) {
253 253
 			// Update action only
254 254
 			$action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] );
255 255
 			$post_id                = $this->save_settings( $action );
@@ -268,18 +268,18 @@  discard block
 block discarded – undo
268 268
 		$action->menu_order = $form_id;
269 269
 		$switch             = $this->get_global_switch_fields();
270 270
 		foreach ( (array) $action->post_content as $key => $val ) {
271
-			if ( is_numeric( $val ) && isset( $frm_duplicate_ids[ $val ] ) ) {
272
-				$action->post_content[ $key ] = $frm_duplicate_ids[ $val ];
271
+			if ( is_numeric( $val ) && isset( $frm_duplicate_ids[$val] ) ) {
272
+				$action->post_content[$key] = $frm_duplicate_ids[$val];
273 273
 			} elseif ( ! is_array( $val ) ) {
274
-				$action->post_content[ $key ] = FrmFieldsHelper::switch_field_ids( $val );
275
-			} elseif ( isset( $switch[ $key ] ) && is_array( $switch[ $key ] ) ) {
274
+				$action->post_content[$key] = FrmFieldsHelper::switch_field_ids( $val );
275
+			} elseif ( isset( $switch[$key] ) && is_array( $switch[$key] ) ) {
276 276
 				// loop through each value if empty
277
-				if ( empty( $switch[ $key ] ) ) {
278
-					$switch[ $key ] = array_keys( $val );
277
+				if ( empty( $switch[$key] ) ) {
278
+					$switch[$key] = array_keys( $val );
279 279
 				}
280 280
 
281
-				foreach ( $switch[ $key ] as $subkey ) {
282
-					$action->post_content[ $key ] = $this->duplicate_array_walk( $action->post_content[ $key ], $subkey, $val );
281
+				foreach ( $switch[$key] as $subkey ) {
282
+					$action->post_content[$key] = $this->duplicate_array_walk( $action->post_content[$key], $subkey, $val );
283 283
 				}
284 284
 			}
285 285
 
@@ -297,20 +297,20 @@  discard block
 block discarded – undo
297 297
 			foreach ( $subkey as $subkey2 ) {
298 298
 				foreach ( (array) $val as $ck => $cv ) {
299 299
 					if ( is_array( $cv ) ) {
300
-						$action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey2, $cv );
301
-					} elseif ( isset( $cv[ $subkey ] ) && is_numeric( $cv[ $subkey ] ) && isset( $frm_duplicate_ids[ $cv[ $subkey ] ] ) ) {
302
-						$action[ $ck ][ $subkey ] = $frm_duplicate_ids[ $cv[ $subkey ] ];
300
+						$action[$ck] = $this->duplicate_array_walk( $action[$ck], $subkey2, $cv );
301
+					} elseif ( isset( $cv[$subkey] ) && is_numeric( $cv[$subkey] ) && isset( $frm_duplicate_ids[$cv[$subkey]] ) ) {
302
+						$action[$ck][$subkey] = $frm_duplicate_ids[$cv[$subkey]];
303 303
 					}
304 304
 				}
305 305
 			}
306 306
 		} else {
307 307
 			foreach ( (array) $val as $ck => $cv ) {
308 308
 				if ( is_array( $cv ) ) {
309
-					$action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey, $cv );
310
-				} elseif ( $ck == $subkey && isset( $frm_duplicate_ids[ $cv ] ) ) {
311
-					$action[ $ck ] = $frm_duplicate_ids[ $cv ];
309
+					$action[$ck] = $this->duplicate_array_walk( $action[$ck], $subkey, $cv );
310
+				} elseif ( $ck == $subkey && isset( $frm_duplicate_ids[$cv] ) ) {
311
+					$action[$ck] = $frm_duplicate_ids[$cv];
312 312
 				} elseif ( $ck == $subkey ) {
313
-					$action[ $ck ] = FrmFieldsHelper::switch_field_ids( $action[ $ck ] );
313
+					$action[$ck] = FrmFieldsHelper::switch_field_ids( $action[$ck] );
314 314
 				}
315 315
 			}
316 316
 		}
@@ -333,10 +333,10 @@  discard block
 block discarded – undo
333 333
 			return;
334 334
 		}
335 335
 
336
-		if ( isset( $_POST[ $this->option_name ] ) && is_array( $_POST[ $this->option_name ] ) ) {
336
+		if ( isset( $_POST[$this->option_name] ) && is_array( $_POST[$this->option_name] ) ) {
337 337
 			// Sanitizing removes scripts and <email> type of values.
338 338
 			// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
339
-			$settings = wp_unslash( $_POST[ $this->option_name ] );
339
+			$settings = wp_unslash( $_POST[$this->option_name] );
340 340
 		} else {
341 341
 			return;
342 342
 		}
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 		foreach ( $settings as $number => $new_instance ) {
347 347
 			$this->_set( $number );
348 348
 
349
-			$old_instance = isset( $all_instances[ $number ] ) ? $all_instances[ $number ] : array();
349
+			$old_instance = isset( $all_instances[$number] ) ? $all_instances[$number] : array();
350 350
 
351 351
 			if ( ! isset( $new_instance['post_status'] ) ) {
352 352
 				$new_instance['post_status'] = 'draft';
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 			$instance['post_content'] = apply_filters( 'frm_before_save_' . $this->id_base . '_action', $new_instance['post_content'], $instance, $new_instance, $old_instance, $this );
387 387
 
388 388
 			if ( false !== $instance ) {
389
-				$all_instances[ $number ] = $instance;
389
+				$all_instances[$number] = $instance;
390 390
 			}
391 391
 
392 392
 			$action_ids[] = $this->save_settings( $instance );
@@ -462,12 +462,12 @@  discard block
 block discarded – undo
462 462
 			// some plugins/themes are formatting the post_excerpt
463 463
 			$action->post_excerpt = sanitize_title( $action->post_excerpt );
464 464
 
465
-			if ( ! isset( $action_controls[ $action->post_excerpt ] ) ) {
465
+			if ( ! isset( $action_controls[$action->post_excerpt] ) ) {
466 466
 				continue;
467 467
 			}
468 468
 
469
-			$action                  = $action_controls[ $action->post_excerpt ]->prepare_action( $action );
470
-			$settings[ $action->ID ] = $action;
469
+			$action                  = $action_controls[$action->post_excerpt]->prepare_action( $action );
470
+			$settings[$action->ID] = $action;
471 471
 
472 472
 			if ( count( $settings ) >= $limit ) {
473 473
 				break;
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 			'limit'       => 99,
498 498
 			'post_status' => $default_status,
499 499
 		);
500
-		$args     = wp_parse_args( $args, $defaults );
500
+		$args = wp_parse_args( $args, $defaults );
501 501
 	}
502 502
 
503 503
 	/**
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 
559 559
 			$action = $this->prepare_action( $action );
560 560
 
561
-			$settings[ $action->ID ] = $action;
561
+			$settings[$action->ID] = $action;
562 562
 		}
563 563
 
564 564
 		if ( 1 === $limit ) {
@@ -595,10 +595,10 @@  discard block
 block discarded – undo
595 595
 
596 596
 		foreach ( $default_values as $k => $vals ) {
597 597
 			if ( is_array( $vals ) && ! empty( $vals ) ) {
598
-				if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) {
598
+				if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[$k] ) ) {
599 599
 					continue;
600 600
 				}
601
-				$action->post_content[ $k ] = wp_parse_args( $action->post_content[ $k ], $vals );
601
+				$action->post_content[$k] = wp_parse_args( $action->post_content[$k], $vals );
602 602
 			}
603 603
 		}
604 604
 
@@ -671,14 +671,14 @@  discard block
 block discarded – undo
671 671
 	 * Migrate settings from form->options into new action.
672 672
 	 */
673 673
 	public function migrate_to_2( $form, $update = 'update' ) {
674
-		$action        = $this->prepare_new( $form->id );
674
+		$action = $this->prepare_new( $form->id );
675 675
 		FrmAppHelper::unserialize_or_decode( $form->options );
676 676
 
677 677
 		// fill with existing options
678 678
 		foreach ( $action->post_content as $name => $val ) {
679
-			if ( isset( $form->options[ $name ] ) ) {
680
-				$action->post_content[ $name ] = $form->options[ $name ];
681
-				unset( $form->options[ $name ] );
679
+			if ( isset( $form->options[$name] ) ) {
680
+				$action->post_content[$name] = $form->options[$name];
681
+				unset( $form->options[$name] );
682 682
 			}
683 683
 		}
684 684
 
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
 				$stop = $stop ? false : true;
740 740
 			}
741 741
 
742
-			$met[ $stop ] = $stop;
742
+			$met[$stop] = $stop;
743 743
 		}
744 744
 
745 745
 		if ( $notification['conditions']['any_all'] == 'all' && ! empty( $met ) && isset( $met[0] ) && isset( $met[1] ) ) {
@@ -781,8 +781,8 @@  discard block
 block discarded – undo
781 781
 	private static function get_value_from_entry( $entry, $field_id ) {
782 782
 		$observed_value = '';
783 783
 
784
-		if ( isset( $entry->metas[ $field_id ] ) ) {
785
-			$observed_value = $entry->metas[ $field_id ];
784
+		if ( isset( $entry->metas[$field_id] ) ) {
785
+			$observed_value = $entry->metas[$field_id];
786 786
 		} elseif ( $entry->post_id && FrmAppHelper::pro_is_installed() ) {
787 787
 			$field          = FrmField::getOne( $field_id );
788 788
 			$observed_value = FrmProEntryMetaHelper::get_post_or_meta_value(
Please login to merge, or discard this patch.
classes/helpers/FrmEntriesHelper.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
 		if ( $_POST ) {
118 118
 			$repeating = isset( $args['repeating'] ) && $args['repeating'];
119 119
 			if ( $repeating ) {
120
-				if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) {
120
+				if ( isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] ) ) {
121 121
 					$value_is_posted = true;
122 122
 				}
123
-			} elseif ( isset( $_POST['item_meta'][ $field->id ] ) ) {
123
+			} elseif ( isset( $_POST['item_meta'][$field->id] ) ) {
124 124
 				$value_is_posted = true;
125 125
 			}
126 126
 		}
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 		preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER );
151 151
 
152 152
 		foreach ( $shortcodes[0] as $short_key => $tag ) {
153
-			$add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
153
+			$add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][$short_key] );
154 154
 			if ( ! empty( $add_atts ) ) {
155 155
 				$this_atts = array_merge( $atts, $add_atts );
156 156
 			} else {
@@ -160,14 +160,14 @@  discard block
 block discarded – undo
160 160
 			$default = FrmEntriesController::show_entry_shortcode( $this_atts );
161 161
 
162 162
 			// Add the default message.
163
-			$message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
163
+			$message = str_replace( $shortcodes[0][$short_key], $default, $message );
164 164
 		}
165 165
 
166 166
 		return $message;
167 167
 	}
168 168
 
169 169
 	public static function prepare_display_value( $entry, $field, $atts ) {
170
-		$field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
170
+		$field_value = isset( $entry->metas[$field->id] ) ? $entry->metas[$field->id] : false;
171 171
 
172 172
 		if ( FrmAppHelper::pro_is_installed() ) {
173 173
 			FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 			$child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
186 186
 		} else {
187 187
 			// Get all values for this field.
188
-			$child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
188
+			$child_values = isset( $entry->metas[$atts['embedded_field_id']] ) ? $entry->metas[$atts['embedded_field_id']] : false;
189 189
 
190 190
 			if ( $child_values ) {
191 191
 				$child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 			$value = $args['temp_value'];
300 300
 		}
301 301
 		if ( empty( $args['parent_field_id'] ) ) {
302
-			$_POST['item_meta'][ $field->id ] = $value;
302
+			$_POST['item_meta'][$field->id] = $value;
303 303
 		} else {
304 304
 			self::set_parent_field_posted_value( $field, $value, $args );
305 305
 		}
@@ -311,20 +311,20 @@  discard block
 block discarded – undo
311 311
 	 * @since 4.01
312 312
 	 */
313 313
 	private static function set_parent_field_posted_value( $field, $value, $args ) {
314
-		if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ] ) &&
315
-			 is_array( $_POST['item_meta'][ $args['parent_field_id'] ] ) ) {
314
+		if ( isset( $_POST['item_meta'][$args['parent_field_id']] ) &&
315
+			 is_array( $_POST['item_meta'][$args['parent_field_id']] ) ) {
316 316
 
317
-			if ( ! isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) ||
318
-				 ! is_array( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) ) {
319
-				$_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] = array();
317
+			if ( ! isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']] ) ||
318
+				 ! is_array( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']] ) ) {
319
+				$_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']] = array();
320 320
 			}
321 321
 		} else {
322 322
 			// All of the section was probably removed.
323
-			$_POST['item_meta'][ $args['parent_field_id'] ] = array();
324
-			$_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] = array();
323
+			$_POST['item_meta'][$args['parent_field_id']] = array();
324
+			$_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']] = array();
325 325
 		}
326 326
 
327
-		$_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
327
+		$_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] = $value;
328 328
 	}
329 329
 
330 330
 	public static function get_posted_value( $field, &$value, $args ) {
@@ -344,10 +344,10 @@  discard block
 block discarded – undo
344 344
 		if ( empty( $args['parent_field_id'] ) ) {
345 345
 			// Sanitizing is done next.
346 346
 			// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
347
-			$value = isset( $_POST['item_meta'][ $field_id ] ) ? wp_unslash( $_POST['item_meta'][ $field_id ] ) : '';
347
+			$value = isset( $_POST['item_meta'][$field_id] ) ? wp_unslash( $_POST['item_meta'][$field_id] ) : '';
348 348
 		} else {
349 349
 			// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
350
-			$value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? wp_unslash( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) : '';
350
+			$value = isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] ) ? wp_unslash( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] ) : '';
351 351
 		}
352 352
 
353 353
 		$field_obj->sanitize_value( $value );
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 		self::set_other_repeating_vals( $field, $value, $args );
380 380
 
381 381
 		// Check if there are any posted "Other" values.
382
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
382
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][$field->id] ) ) {
383 383
 
384 384
 			// Save original value.
385 385
 			$args['temp_value'] = $value;
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 
388 388
 			// Sanitizing is done next.
389 389
 			// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
390
-			$other_vals = wp_unslash( $_POST['item_meta']['other'][ $field->id ] );
390
+			$other_vals = wp_unslash( $_POST['item_meta']['other'][$field->id] );
391 391
 			FrmAppHelper::sanitize_value( 'sanitize_text_field', $other_vals );
392 392
 
393 393
 			// Set the validation value now
@@ -410,13 +410,13 @@  discard block
 block discarded – undo
410 410
 		}
411 411
 
412 412
 		// Check if there are any other posted "other" values for this field.
413
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
413
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ) ) {
414 414
 			// Save original value
415 415
 			$args['temp_value'] = $value;
416 416
 			$args['other']      = true;
417 417
 
418 418
 			// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
419
-			$other_vals = wp_unslash( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] );
419
+			$other_vals = wp_unslash( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] );
420 420
 			FrmAppHelper::sanitize_value( 'sanitize_text_field', $other_vals );
421 421
 
422 422
 			// Set the validation value now.
@@ -454,25 +454,25 @@  discard block
 block discarded – undo
454 454
 
455 455
 			// Multi-select dropdown.
456 456
 			if ( is_array( $value ) ) {
457
-				$o_key = array_search( $field->options[ $other_key ], $value );
457
+				$o_key = array_search( $field->options[$other_key], $value );
458 458
 
459 459
 				if ( $o_key !== false ) {
460 460
 					// Modify the original value so other key will be preserved.
461
-					$value[ $other_key ] = $value[ $o_key ];
461
+					$value[$other_key] = $value[$o_key];
462 462
 
463 463
 					// By default, the array keys will be numeric for multi-select dropdowns.
464 464
 					// If going backwards and forwards between pages, the array key will match the other key.
465 465
 					if ( $o_key !== $other_key ) {
466
-						unset( $value[ $o_key ] );
466
+						unset( $value[$o_key] );
467 467
 					}
468 468
 
469 469
 					$args['temp_value']  = $value;
470
-					$value[ $other_key ] = reset( $other_vals );
471
-					if ( FrmAppHelper::is_empty_value( $value[ $other_key ] ) ) {
472
-						unset( $value[ $other_key ] );
470
+					$value[$other_key] = reset( $other_vals );
471
+					if ( FrmAppHelper::is_empty_value( $value[$other_key] ) ) {
472
+						unset( $value[$other_key] );
473 473
 					}
474 474
 				}
475
-			} elseif ( $field->options[ $other_key ] == $value ) {
475
+			} elseif ( $field->options[$other_key] == $value ) {
476 476
 				$value = $other_vals;
477 477
 			}
478 478
 		}
Please login to merge, or discard this patch.
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,19 +180,19 @@  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
-			$value = wp_kses_post( wp_unslash( $_POST['field_options'][ $setting ] ) );
195
+			$value = wp_kses_post( wp_unslash( $_POST['field_options'][$setting] ) );
196 196
 		}
197 197
 	}
198 198
 
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 		$values['default_value'] = FrmAppHelper::maybe_json_encode( $field->default_value );
265 265
 
266 266
 		foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
267
-			$values[ $col ] = $field->{$col};
267
+			$values[$col] = $field->{$col};
268 268
 		}
269 269
 	}
270 270
 
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 		);
305 305
 
306 306
 		$msg = FrmField::get_option( $field, $error );
307
-		$msg = empty( $msg ) ? $defaults[ $error ]['part'] : $msg;
307
+		$msg = empty( $msg ) ? $defaults[$error]['part'] : $msg;
308 308
 		$msg = do_shortcode( $msg );
309 309
 
310 310
 		return $msg;
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 		}
413 413
 
414 414
 		$base_name = 'default_value_' . $field['id'];
415
-		$html_id    = isset( $field['html_id'] ) ? $field['html_id'] : self::get_html_id( $field );
415
+		$html_id = isset( $field['html_id'] ) ? $field['html_id'] : self::get_html_id( $field );
416 416
 
417 417
 		$default_type = self::get_default_value_type( $field );
418 418
 
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
 				continue;
709 709
 			}
710 710
 
711
-			$atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] );
711
+			$atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][$short_key] );
712 712
 			$tag  = FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key );
713 713
 
714 714
 			$atts['entry'] = $entry;
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
 
718 718
 			if ( $replace_with !== null ) {
719 719
 				self::sanitize_embedded_shortcodes( compact( 'entry' ), $replace_with );
720
-				$content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
720
+				$content = str_replace( $shortcodes[0][$short_key], $replace_with, $content );
721 721
 			}
722 722
 
723 723
 			unset( $atts, $replace_with );
@@ -760,8 +760,8 @@  discard block
 block discarded – undo
760 760
 
761 761
 		$dynamic_default = array( 'admin_email', 'siteurl', 'frmurl', 'sitename', 'get' );
762 762
 
763
-		if ( isset( $shortcode_values[ $atts['tag'] ] ) ) {
764
-			$replace_with = $shortcode_values[ $atts['tag'] ];
763
+		if ( isset( $shortcode_values[$atts['tag']] ) ) {
764
+			$replace_with = $shortcode_values[$atts['tag']];
765 765
 		} elseif ( in_array( $atts['tag'], $dynamic_default ) ) {
766 766
 			$replace_with = self::dynamic_default_values( $atts['tag'], $atts );
767 767
 		} elseif ( $clean_tag == 'user_agent' ) {
@@ -970,8 +970,8 @@  discard block
 block discarded – undo
970 970
 			self::field_types_for_input( $single_input, $field_selection, $field_types );
971 971
 		} elseif ( in_array( $type, $multiple_input ) ) {
972 972
 			self::field_types_for_input( $multiple_input, $field_selection, $field_types );
973
-		} elseif ( isset( $field_selection[ $type ] ) ) {
974
-			$field_types[ $type ] = $field_selection[ $type ];
973
+		} elseif ( isset( $field_selection[$type] ) ) {
974
+			$field_types[$type] = $field_selection[$type];
975 975
 		}
976 976
 
977 977
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
 
1005 1005
 	private static function field_types_for_input( $inputs, $fields, &$field_types ) {
1006 1006
 		foreach ( $inputs as $input ) {
1007
-			$field_types[ $input ] = $fields[ $input ];
1007
+			$field_types[$input] = $fields[$input];
1008 1008
 			unset( $input );
1009 1009
 		}
1010 1010
 	}
@@ -1036,7 +1036,7 @@  discard block
 block discarded – undo
1036 1036
 			'parent'  => false,
1037 1037
 			'pointer' => false,
1038 1038
 		);
1039
-		$args     = wp_parse_args( $args, $defaults );
1039
+		$args = wp_parse_args( $args, $defaults );
1040 1040
 
1041 1041
 		$opt_key   = $args['opt_key'];
1042 1042
 		$field     = $args['field'];
@@ -1053,22 +1053,22 @@  discard block
 block discarded – undo
1053 1053
 		// Check posted vals before checking saved values
1054 1054
 
1055 1055
 		// For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero
1056
-		if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) {
1056
+		if ( $parent && isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ) {
1057 1057
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
1058
-				$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
+				$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] ) ) : '';
1059 1059
 			} else {
1060
-				$other_val = sanitize_text_field( wp_unslash( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) );
1060
+				$other_val = sanitize_text_field( wp_unslash( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) );
1061 1061
 			}
1062 1062
 
1063 1063
 			return $other_val;
1064 1064
 
1065
-		} elseif ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) {
1065
+		} elseif ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][$field['id']] ) ) {
1066 1066
 			// For normal fields
1067 1067
 
1068 1068
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
1069
-				$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
+				$other_val = isset( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ? sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ) : '';
1070 1070
 			} else {
1071
-				$other_val = sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][ $field['id'] ] ) );
1071
+				$other_val = sanitize_text_field( wp_unslash( $_POST['item_meta']['other'][$field['id']] ) );
1072 1072
 			}
1073 1073
 
1074 1074
 			return $other_val;
@@ -1078,8 +1078,8 @@  discard block
 block discarded – undo
1078 1078
 		if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) {
1079 1079
 			// Check if there is an "other" val in saved value and make sure the
1080 1080
 			// "other" val is not equal to the Other checkbox option
1081
-			if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) {
1082
-				$other_val = $field['value'][ $opt_key ];
1081
+			if ( isset( $field['value'][$opt_key] ) && $field['options'][$opt_key] != $field['value'][$opt_key] ) {
1082
+				$other_val = $field['value'][$opt_key];
1083 1083
 			}
1084 1084
 		} else {
1085 1085
 			/**
@@ -1091,8 +1091,8 @@  discard block
 block discarded – undo
1091 1091
 				// Multi-select dropdowns - key is not preserved
1092 1092
 				if ( is_array( $field['value'] ) ) {
1093 1093
 					$o_key = array_search( $temp_val, $field['value'] );
1094
-					if ( isset( $field['value'][ $o_key ] ) ) {
1095
-						unset( $field['value'][ $o_key ], $o_key );
1094
+					if ( isset( $field['value'][$o_key] ) ) {
1095
+						unset( $field['value'][$o_key], $o_key );
1096 1096
 					}
1097 1097
 				} elseif ( $temp_val == $field['value'] ) {
1098 1098
 					// For radio and regular dropdowns
@@ -1279,7 +1279,7 @@  discard block
 block discarded – undo
1279 1279
 		}
1280 1280
 		if ( is_array( $val ) ) {
1281 1281
 			foreach ( $val as $k => $v ) {
1282
-				$val[ $k ] = str_replace( $replace, $replace_with, $v );
1282
+				$val[$k] = str_replace( $replace, $replace_with, $v );
1283 1283
 				unset( $k, $v );
1284 1284
 			}
1285 1285
 		} else {
@@ -1589,19 +1589,19 @@  discard block
 block discarded – undo
1589 1589
 	}
1590 1590
 
1591 1591
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1592
-		$prepop[ __( 'Countries', 'formidable' ) ] = self::get_countries();
1592
+		$prepop[__( 'Countries', 'formidable' )] = self::get_countries();
1593 1593
 
1594 1594
 		$states    = self::get_us_states();
1595 1595
 		$state_abv = array_keys( $states );
1596 1596
 		sort( $state_abv );
1597
-		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1597
+		$prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv;
1598 1598
 
1599 1599
 		$states = array_values( $states );
1600 1600
 		sort( $states );
1601
-		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1601
+		$prepop[__( 'U.S. States', 'formidable' )] = $states;
1602 1602
 		unset( $state_abv, $states );
1603 1603
 
1604
-		$prepop[ __( 'Age', 'formidable' ) ] = array(
1604
+		$prepop[__( 'Age', 'formidable' )] = array(
1605 1605
 			__( 'Under 18', 'formidable' ),
1606 1606
 			__( '18-24', 'formidable' ),
1607 1607
 			__( '25-34', 'formidable' ),
@@ -1612,7 +1612,7 @@  discard block
 block discarded – undo
1612 1612
 			__( 'Prefer Not to Answer', 'formidable' ),
1613 1613
 		);
1614 1614
 
1615
-		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1615
+		$prepop[__( 'Satisfaction', 'formidable' )] = array(
1616 1616
 			__( 'Very Satisfied', 'formidable' ),
1617 1617
 			__( 'Satisfied', 'formidable' ),
1618 1618
 			__( 'Neutral', 'formidable' ),
@@ -1621,7 +1621,7 @@  discard block
 block discarded – undo
1621 1621
 			__( 'N/A', 'formidable' ),
1622 1622
 		);
1623 1623
 
1624
-		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1624
+		$prepop[__( 'Importance', 'formidable' )] = array(
1625 1625
 			__( 'Very Important', 'formidable' ),
1626 1626
 			__( 'Important', 'formidable' ),
1627 1627
 			__( 'Neutral', 'formidable' ),
@@ -1630,7 +1630,7 @@  discard block
 block discarded – undo
1630 1630
 			__( 'N/A', 'formidable' ),
1631 1631
 		);
1632 1632
 
1633
-		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1633
+		$prepop[__( 'Agreement', 'formidable' )] = array(
1634 1634
 			__( 'Strongly Agree', 'formidable' ),
1635 1635
 			__( 'Agree', 'formidable' ),
1636 1636
 			__( 'Neutral', 'formidable' ),
Please login to merge, or discard this patch.
classes/controllers/FrmXMLController.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 		// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
197 197
 		$file_type = sanitize_option( 'upload_path', $_FILES['frm_import_file']['name'] );
198 198
 		$file_type = strtolower( pathinfo( $file_type, PATHINFO_EXTENSION ) );
199
-		if ( 'xml' !== $file_type && isset( $export_format[ $file_type ] ) ) {
199
+		if ( 'xml' !== $file_type && isset( $export_format[$file_type] ) ) {
200 200
 			// allow other file types to be imported
201 201
 			do_action( 'frm_before_import_' . $file_type );
202 202
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 		foreach ( $type as $tb_type ) {
280 280
 			$where = array();
281 281
 			$join  = '';
282
-			$table = $tables[ $tb_type ];
282
+			$table = $tables[$tb_type];
283 283
 
284 284
 			$select     = $table . '.id';
285 285
 			$query_vars = array();
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 							$table . '.parent_form_id' => $args['ids'],
295 295
 						);
296 296
 					} else {
297
-						$where[ $table . '.status !' ] = 'draft';
297
+						$where[$table . '.status !'] = 'draft';
298 298
 					}
299 299
 					break;
300 300
 				case 'actions':
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 				case 'items':
308 308
 					// $join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)";
309 309
 					if ( $args['ids'] ) {
310
-						$where[ $table . '.form_id' ] = $args['ids'];
310
+						$where[$table . '.form_id'] = $args['ids'];
311 311
 					}
312 312
 					break;
313 313
 				case 'styles':
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 					}
349 349
 			}
350 350
 
351
-			$records[ $tb_type ] = FrmDb::get_col( $table . $join, $where, $select );
351
+			$records[$tb_type] = FrmDb::get_col( $table . $join, $where, $select );
352 352
 			unset( $tb_type );
353 353
 		}
354 354
 
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 		$no_export_fields = FrmField::no_save_fields();
494 494
 		foreach ( $csv_fields as $k => $f ) {
495 495
 			if ( in_array( $f->type, $no_export_fields ) ) {
496
-				unset( $csv_fields[ $k ] );
496
+				unset( $csv_fields[$k] );
497 497
 			}
498 498
 		}
499 499
 
Please login to merge, or discard this patch.