Completed
Pull Request — master (#2036)
by
unknown
47s
created
classes/models/FrmFieldFormHtml.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
 	 * @param array  $atts
45 45
 	 */
46 46
 	private function _set( $param, $atts ) {
47
-		if ( isset( $atts[ $param ] ) ) {
48
-			$this->{$param} = $atts[ $param ];
47
+		if ( isset( $atts[$param] ) ) {
48
+			$this->{$param} = $atts[$param];
49 49
 		}
50 50
 	}
51 51
 
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
 
90 90
 		$exclude = array( 'field_obj', 'html' );
91 91
 		foreach ( $exclude as $ex ) {
92
-			if ( isset( $atts[ $ex ] ) ) {
93
-				unset( $this->pass_args[ $ex ] );
92
+			if ( isset( $atts[$ex] ) ) {
93
+				unset( $this->pass_args[$ex] );
94 94
 			}
95 95
 		}
96 96
 	}
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 	 * @param array $set
103 103
 	 */
104 104
 	private function set_from_field( $atts, $set ) {
105
-		if ( isset( $atts[ $set['param'] ] ) ) {
106
-			$this->{$set['param']} = $atts[ $set['param'] ];
105
+		if ( isset( $atts[$set['param']] ) ) {
106
+			$this->{$set['param']} = $atts[$set['param']];
107 107
 		} else {
108 108
 			$this->{$set['param']} = $this->field_obj->get_field_column( $set['default'] );
109 109
 		}
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	 */
231 231
 	private function replace_error_shortcode() {
232 232
 		$this->maybe_add_error_id();
233
-		$error = isset( $this->pass_args['errors'][ 'field' . $this->field_id ] ) ? $this->pass_args['errors'][ 'field' . $this->field_id ] : false;
233
+		$error = isset( $this->pass_args['errors']['field' . $this->field_id] ) ? $this->pass_args['errors']['field' . $this->field_id] : false;
234 234
 
235 235
 		if ( ! empty( $error ) && false === strpos( $this->html, 'role="alert"' ) && FrmAppHelper::should_include_alert_role_on_field_errors() ) {
236 236
 			$error_body = self::get_error_body( $this->html );
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	 * @since 3.06.02
272 272
 	 */
273 273
 	private function maybe_add_error_id() {
274
-		if ( ! isset( $this->pass_args['errors'][ 'field' . $this->field_id ] ) ) {
274
+		if ( ! isset( $this->pass_args['errors']['field' . $this->field_id] ) ) {
275 275
 			return;
276 276
 		}
277 277
 
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 		preg_match_all( "/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $this->html, $shortcodes, PREG_PATTERN_ORDER );
352 352
 
353 353
 		foreach ( $shortcodes[0] as $short_key => $tag ) {
354
-			$shortcode_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
354
+			$shortcode_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][$short_key] );
355 355
 			$tag            = FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key );
356 356
 
357 357
 			$replace_with = '';
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 				$replace_with = $this->replace_input_shortcode( $shortcode_atts );
363 363
 			}
364 364
 
365
-			$this->html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $this->html );
365
+			$this->html = str_replace( $shortcodes[0][$short_key], $replace_with, $this->html );
366 366
 		}
367 367
 	}
368 368
 
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 	 */
385 385
 	private function prepare_input_shortcode_atts( $shortcode_atts ) {
386 386
 		if ( isset( $shortcode_atts['opt'] ) ) {
387
-			--$shortcode_atts['opt'];
387
+			-- $shortcode_atts['opt'];
388 388
 		}
389 389
 
390 390
 		$field_class = isset( $shortcode_atts['class'] ) ? $shortcode_atts['class'] : '';
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 		if ( $this->field_obj->get_field_column( 'type' ) === 'name' ) {
398 398
 			$this->set_aria_invalid_error_for_name_part( $shortcode_atts );
399 399
 		} else {
400
-			$shortcode_atts['aria-invalid'] = isset( $this->pass_args['errors'][ 'field' . $this->field_id ] ) ? 'true' : 'false';
400
+			$shortcode_atts['aria-invalid'] = isset( $this->pass_args['errors']['field' . $this->field_id] ) ? 'true' : 'false';
401 401
 		}
402 402
 
403 403
 		$this->field_obj->set_field_column( 'shortcodes', $shortcode_atts );
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 	 */
416 416
 	private function set_aria_invalid_error_for_name_part( &$shortcode_atts ) {
417 417
 		foreach ( array( 'first', 'middle', 'last' ) as $name_part ) {
418
-			$shortcode_atts[ 'aria-invalid-' . $name_part ] = isset( $this->pass_args['errors'][ 'field' . $this->field_id . '-' . $name_part ] ) ? 'true' : 'false';
418
+			$shortcode_atts['aria-invalid-' . $name_part] = isset( $this->pass_args['errors']['field' . $this->field_id . '-' . $name_part] ) ? 'true' : 'false';
419 419
 		}
420 420
 	}
421 421
 
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
 	 */
466 466
 	private function get_field_div_classes() {
467 467
 		// Add error class
468
-		$classes = isset( $this->pass_args['errors'][ 'field' . $this->field_id ] ) ? ' frm_blank_field' : '';
468
+		$classes = isset( $this->pass_args['errors']['field' . $this->field_id] ) ? ' frm_blank_field' : '';
469 469
 
470 470
 		// Add label position class
471 471
 		$settings = $this->field_obj->display_field_settings();
Please login to merge, or discard this patch.
classes/controllers/FrmFieldsController.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
 		$_GET['page'] = 'formidable';
27 27
 
28
-		$values     = array(
28
+		$values = array(
29 29
 			'id'         => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
30 30
 			'doing_ajax' => true,
31 31
 		);
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
 			ob_start();
50 50
 			self::load_single_field( $field, $values );
51
-			$field_html[ absint( $field->id ) ] = ob_get_contents();
51
+			$field_html[absint( $field->id )] = ob_get_contents();
52 52
 			ob_end_clean();
53 53
 		}
54 54
 
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 			foreach ( $opts as $opt_key => $opt ) {
264 264
 				if ( strpos( $opt, '|' ) !== false ) {
265 265
 					$vals             = explode( '|', $opt );
266
-					$opts[ $opt_key ] = array(
266
+					$opts[$opt_key] = array(
267 267
 						'label' => trim( $vals[0] ),
268 268
 						'value' => trim( $vals[1] ),
269 269
 					);
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 			$other_array = array();
279 279
 			foreach ( $field['options'] as $opt_key => $opt ) {
280 280
 				if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
281
-					$other_array[ $opt_key ] = $opt;
281
+					$other_array[$opt_key] = $opt;
282 282
 				}
283 283
 				unset( $opt_key, $opt );
284 284
 			}
@@ -321,18 +321,18 @@  discard block
 block discarded – undo
321 321
 		$frm_settings         = FrmAppHelper::get_settings();
322 322
 		$field_types          = FrmFieldTypeOptionData::get_field_types( $field['type'] );
323 323
 
324
-		if ( ! isset( $all_field_types[ $field['type'] ] ) ) {
324
+		if ( ! isset( $all_field_types[$field['type']] ) ) {
325 325
 			// Add fallback for an add-on field type that has been deactivated.
326
-			$all_field_types[ $field['type'] ] = array(
326
+			$all_field_types[$field['type']] = array(
327 327
 				'name' => ucfirst( $field['type'] ),
328 328
 				'icon' => 'frm_icon_font frm_pencil_icon',
329 329
 			);
330
-		} elseif ( ! is_array( $all_field_types[ $field['type'] ] ) ) {
330
+		} elseif ( ! is_array( $all_field_types[$field['type']] ) ) {
331 331
 			// Fallback for fields added in a more basic way.
332
-			FrmFormsHelper::prepare_field_type( $all_field_types[ $field['type'] ] );
332
+			FrmFormsHelper::prepare_field_type( $all_field_types[$field['type']] );
333 333
 		}
334 334
 
335
-		$type_name = $all_field_types[ $field['type'] ]['name'];
335
+		$type_name = $all_field_types[$field['type']]['name'];
336 336
 		if ( $field['type'] === 'divider' && FrmField::is_option_true( $field, 'repeat' ) ) {
337 337
 			$type_name = $all_field_types['divider|repeat']['name'];
338 338
 		}
@@ -406,13 +406,13 @@  discard block
 block discarded – undo
406 406
 		$active   = 'default_value';
407 407
 
408 408
 		foreach ( $settings as $type ) {
409
-			if ( ! empty( $field[ $type ] ) ) {
409
+			if ( ! empty( $field[$type] ) ) {
410 410
 				$active = $type;
411 411
 			}
412 412
 		}
413 413
 
414
-		$types[ $active ]['class']  .= ' current';
415
-		$types[ $active ]['current'] = true;
414
+		$types[$active]['class']  .= ' current';
415
+		$types[$active]['current'] = true;
416 416
 
417 417
 		return $types;
418 418
 	}
@@ -430,8 +430,8 @@  discard block
 block discarded – undo
430 430
 			'website' => 'url',
431 431
 			'image'   => 'url',
432 432
 		);
433
-		if ( isset( $type_switch[ $type ] ) ) {
434
-			$type = $type_switch[ $type ];
433
+		if ( isset( $type_switch[$type] ) ) {
434
+			$type = $type_switch[$type];
435 435
 		}
436 436
 
437 437
 		$pro_fields = FrmField::pro_field_selection();
@@ -584,11 +584,11 @@  discard block
 block discarded – undo
584 584
 		// include "col" for valid html
585 585
 		$unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) );
586 586
 
587
-		if ( ! isset( $calc[ $unit ] ) ) {
587
+		if ( ! isset( $calc[$unit] ) ) {
588 588
 			return;
589 589
 		}
590 590
 
591
-		$size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
591
+		$size = (float) str_replace( $unit, '', $field['size'] ) / $calc[$unit];
592 592
 
593 593
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
594 594
 	}
@@ -826,11 +826,11 @@  discard block
 block discarded – undo
826 826
 	private static function get_form_for_js_validation( $field ) {
827 827
 		global $frm_vars;
828 828
 		if ( ! empty( $frm_vars['js_validate_forms'] ) ) {
829
-			if ( isset( $frm_vars['js_validate_forms'][ $field['form_id'] ] ) ) {
830
-				return $frm_vars['js_validate_forms'][ $field['form_id'] ];
829
+			if ( isset( $frm_vars['js_validate_forms'][$field['form_id']] ) ) {
830
+				return $frm_vars['js_validate_forms'][$field['form_id']];
831 831
 			}
832
-			if ( ! empty( $field['parent_form_id'] ) && isset( $frm_vars['js_validate_forms'][ $field['parent_form_id'] ] ) ) {
833
-				return $frm_vars['js_validate_forms'][ $field['parent_form_id'] ];
832
+			if ( ! empty( $field['parent_form_id'] ) && isset( $frm_vars['js_validate_forms'][$field['parent_form_id']] ) ) {
833
+				return $frm_vars['js_validate_forms'][$field['parent_form_id']];
834 834
 			}
835 835
 		}
836 836
 		return false;
@@ -917,13 +917,13 @@  discard block
 block discarded – undo
917 917
 		foreach ( $field['shortcodes'] as $k => $v ) {
918 918
 			if ( isset( $field['subfield_name'] ) && 0 === strpos( $k, 'aria-invalid' ) ) {
919 919
 				$subfield_name = $field['subfield_name'];
920
-				if ( ! isset( $field['shortcodes'][ 'aria-invalid-' . $subfield_name ] ) ) {
920
+				if ( ! isset( $field['shortcodes']['aria-invalid-' . $subfield_name] ) ) {
921 921
 					continue;
922 922
 				}
923 923
 				// Change the key to the correct aria-invalid value so that $add_html is set correctly for the current subfield of a combo field.
924 924
 				$k = 'aria-invalid';
925
-				$v = $field['shortcodes'][ 'aria-invalid-' . $subfield_name ];
926
-				unset( $field['shortcodes'][ 'aria-invalid-' . $subfield_name ] );
925
+				$v = $field['shortcodes']['aria-invalid-' . $subfield_name];
926
+				unset( $field['shortcodes']['aria-invalid-' . $subfield_name] );
927 927
 			}
928 928
 			if ( 'opt' === $k || ! self::should_allow_input_attribute( $k ) ) {
929 929
 				continue;
@@ -931,10 +931,10 @@  discard block
 block discarded – undo
931 931
 
932 932
 			if ( is_numeric( $k ) && strpos( $v, '=' ) ) {
933 933
 				$add_html[] = $v;
934
-			} elseif ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
935
-				$add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] );
934
+			} elseif ( ! empty( $k ) && isset( $add_html[$k] ) ) {
935
+				$add_html[$k] = str_replace( $k . '="', $k . '="' . $v, $add_html[$k] );
936 936
 			} else {
937
-				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
937
+				$add_html[$k] = $k . '="' . esc_attr( $v ) . '"';
938 938
 			}
939 939
 
940 940
 			unset( $k, $v );
Please login to merge, or discard this patch.