Completed
Pull Request — master (#2668)
by
unknown
50s
created
classes/models/FrmFormAction.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -227,9 +227,9 @@  discard block
 block discarded – undo
227 227
 		$groups = FrmFormActionsController::form_action_groups();
228 228
 		$group  = 'misc';
229 229
 
230
-		if ( isset( $action_options['group'] ) && isset( $groups[ $action_options['group'] ] ) ) {
230
+		if ( isset( $action_options['group'] ) && isset( $groups[$action_options['group']] ) ) {
231 231
 			$group = $action_options['group'];
232
-		} elseif ( isset( $groups[ $this->id_base ] ) ) {
232
+		} elseif ( isset( $groups[$this->id_base] ) ) {
233 233
 			$group = $this->id_base;
234 234
 		} else {
235 235
 			foreach ( $groups as $name => $check_group ) {
@@ -240,8 +240,8 @@  discard block
 block discarded – undo
240 240
 			}
241 241
 		}
242 242
 
243
-		$groups[ $group ]['id'] = $group;
244
-		return $groups[ $group ];
243
+		$groups[$group]['id'] = $group;
244
+		return $groups[$group];
245 245
 	}
246 246
 
247 247
 	/**
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 	 * @return int $post_id
367 367
 	 */
368 368
 	public function maybe_create_action( $action, $forms ) {
369
-		if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && isset( $forms[ $action['menu_order'] ] ) && $forms[ $action['menu_order'] ] === 'updated' ) {
369
+		if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && isset( $forms[$action['menu_order']] ) && $forms[$action['menu_order']] === 'updated' ) {
370 370
 			// Update action only
371 371
 			$action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] );
372 372
 			$post_id                = $this->save_settings( $action );
@@ -392,18 +392,18 @@  discard block
 block discarded – undo
392 392
 		$switch             = $this->get_global_switch_fields();
393 393
 
394 394
 		foreach ( (array) $action->post_content as $key => $val ) {
395
-			if ( is_numeric( $val ) && isset( $frm_duplicate_ids[ $val ] ) ) {
396
-				$action->post_content[ $key ] = $frm_duplicate_ids[ $val ];
395
+			if ( is_numeric( $val ) && isset( $frm_duplicate_ids[$val] ) ) {
396
+				$action->post_content[$key] = $frm_duplicate_ids[$val];
397 397
 			} elseif ( ! is_array( $val ) ) {
398
-				$action->post_content[ $key ] = FrmFieldsHelper::switch_field_ids( $val );
399
-			} elseif ( isset( $switch[ $key ] ) && is_array( $switch[ $key ] ) ) {
398
+				$action->post_content[$key] = FrmFieldsHelper::switch_field_ids( $val );
399
+			} elseif ( isset( $switch[$key] ) && is_array( $switch[$key] ) ) {
400 400
 				// loop through each value if empty
401
-				if ( empty( $switch[ $key ] ) ) {
402
-					$switch[ $key ] = array_keys( $val );
401
+				if ( empty( $switch[$key] ) ) {
402
+					$switch[$key] = array_keys( $val );
403 403
 				}
404 404
 
405
-				foreach ( $switch[ $key ] as $subkey ) {
406
-					$action->post_content[ $key ] = $this->duplicate_array_walk( $action->post_content[ $key ], $subkey, $val );
405
+				foreach ( $switch[$key] as $subkey ) {
406
+					$action->post_content[$key] = $this->duplicate_array_walk( $action->post_content[$key], $subkey, $val );
407 407
 				}
408 408
 			}
409 409
 
@@ -428,20 +428,20 @@  discard block
 block discarded – undo
428 428
 			foreach ( $subkey as $subkey2 ) {
429 429
 				foreach ( (array) $val as $ck => $cv ) {
430 430
 					if ( is_array( $cv ) ) {
431
-						$action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey2, $cv );
432
-					} elseif ( isset( $cv[ $subkey ] ) && is_numeric( $cv[ $subkey ] ) && isset( $frm_duplicate_ids[ $cv[ $subkey ] ] ) ) {
433
-						$action[ $ck ][ $subkey ] = $frm_duplicate_ids[ $cv[ $subkey ] ];
431
+						$action[$ck] = $this->duplicate_array_walk( $action[$ck], $subkey2, $cv );
432
+					} elseif ( isset( $cv[$subkey] ) && is_numeric( $cv[$subkey] ) && isset( $frm_duplicate_ids[$cv[$subkey]] ) ) {
433
+						$action[$ck][$subkey] = $frm_duplicate_ids[$cv[$subkey]];
434 434
 					}
435 435
 				}
436 436
 			}
437 437
 		} else {
438 438
 			foreach ( (array) $val as $ck => $cv ) {
439 439
 				if ( is_array( $cv ) ) {
440
-					$action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey, $cv );
441
-				} elseif ( $ck == $subkey && isset( $frm_duplicate_ids[ $cv ] ) ) {
442
-					$action[ $ck ] = $frm_duplicate_ids[ $cv ];
440
+					$action[$ck] = $this->duplicate_array_walk( $action[$ck], $subkey, $cv );
441
+				} elseif ( $ck == $subkey && isset( $frm_duplicate_ids[$cv] ) ) {
442
+					$action[$ck] = $frm_duplicate_ids[$cv];
443 443
 				} elseif ( $ck == $subkey ) {
444
-					$action[ $ck ] = $this->maybe_switch_field_ids( $action[ $ck ] );
444
+					$action[$ck] = $this->maybe_switch_field_ids( $action[$ck] );
445 445
 				}
446 446
 			}
447 447
 		}//end if
@@ -469,10 +469,10 @@  discard block
 block discarded – undo
469 469
 		}
470 470
 
471 471
 		// phpcs:ignore WordPress.Security.NonceVerification.Missing
472
-		if ( isset( $_POST[ $this->option_name ] ) && is_array( $_POST[ $this->option_name ] ) ) {
472
+		if ( isset( $_POST[$this->option_name] ) && is_array( $_POST[$this->option_name] ) ) {
473 473
 			// Sanitizing removes scripts and <email> type of values.
474 474
 			// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
475
-			$settings = wp_unslash( $_POST[ $this->option_name ] );
475
+			$settings = wp_unslash( $_POST[$this->option_name] );
476 476
 		} else {
477 477
 			return null;
478 478
 		}
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
 		foreach ( $settings as $number => $new_instance ) {
483 483
 			$this->_set( $number );
484 484
 
485
-			$old_instance = $all_instances[ $number ] ?? array();
485
+			$old_instance = $all_instances[$number] ?? array();
486 486
 
487 487
 			if ( ! isset( $new_instance['post_status'] ) ) {
488 488
 				$new_instance['post_status'] = 'draft';
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
 			$instance['post_content'] = apply_filters( 'frm_before_save_' . $this->id_base . '_action', $instance['post_content'], $instance, $new_instance, $old_instance, $this );
522 522
 
523 523
 			if ( false !== $instance ) {
524
-				$all_instances[ $number ] = $instance;
524
+				$all_instances[$number] = $instance;
525 525
 			}
526 526
 
527 527
 			$action_ids[] = $this->save_settings( $instance );
@@ -632,12 +632,12 @@  discard block
 block discarded – undo
632 632
 			// some plugins/themes are formatting the post_excerpt
633 633
 			$action->post_excerpt = sanitize_title( $action->post_excerpt );
634 634
 
635
-			if ( ! isset( $action_controls[ $action->post_excerpt ] ) ) {
635
+			if ( ! isset( $action_controls[$action->post_excerpt] ) ) {
636 636
 				continue;
637 637
 			}
638 638
 
639
-			$action                  = $action_controls[ $action->post_excerpt ]->prepare_action( $action );
640
-			$settings[ $action->ID ] = $action;
639
+			$action                  = $action_controls[$action->post_excerpt]->prepare_action( $action );
640
+			$settings[$action->ID] = $action;
641 641
 
642 642
 			if ( count( $settings ) >= $limit ) {
643 643
 				break;
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
 	 * @return int The filtered limit value.
664 664
 	 */
665 665
 	public static function get_action_limit( $form_id, $limit = 99 ) {
666
-		$type  = 'all';
666
+		$type = 'all';
667 667
 		return (int) apply_filters( 'frm_form_action_limit', (int) $limit, compact( 'type', 'form_id' ) );
668 668
 	}
669 669
 
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 			'limit'       => 99,
688 688
 			'post_status' => $default_status,
689 689
 		);
690
-		$args     = wp_parse_args( $args, $defaults );
690
+		$args = wp_parse_args( $args, $defaults );
691 691
 	}
692 692
 
693 693
 	/**
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
 
768 768
 			$action = $this->prepare_action( $action );
769 769
 
770
-			$settings[ $action->ID ] = $action;
770
+			$settings[$action->ID] = $action;
771 771
 		}
772 772
 
773 773
 		if ( 1 === $limit ) {
@@ -815,10 +815,10 @@  discard block
 block discarded – undo
815 815
 
816 816
 		foreach ( $default_values as $k => $vals ) {
817 817
 			if ( is_array( $vals ) && ! empty( $vals ) ) {
818
-				if ( 'event' === $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) {
818
+				if ( 'event' === $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[$k] ) ) {
819 819
 					continue;
820 820
 				}
821
-				$action->post_content[ $k ] = wp_parse_args( $action->post_content[ $k ], $vals );
821
+				$action->post_content[$k] = wp_parse_args( $action->post_content[$k], $vals );
822 822
 			}
823 823
 		}
824 824
 
@@ -920,9 +920,9 @@  discard block
 block discarded – undo
920 920
 
921 921
 		// fill with existing options
922 922
 		foreach ( $action->post_content as $name => $val ) {
923
-			if ( isset( $form->options[ $name ] ) ) {
924
-				$action->post_content[ $name ] = $form->options[ $name ];
925
-				unset( $form->options[ $name ] );
923
+			if ( isset( $form->options[$name] ) ) {
924
+				$action->post_content[$name] = $form->options[$name];
925
+				unset( $form->options[$name] );
926 926
 			}
927 927
 		}
928 928
 
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
 		$form_fields = FrmField::get_all_for_form( $form_id, '', 'include' );
1031 1031
 		return array_filter(
1032 1032
 			$form_fields,
1033
-			function ( $form_field ) {
1033
+			function( $form_field ) {
1034 1034
 				return ! FrmField::is_no_save_field( $form_field->type );
1035 1035
 			}
1036 1036
 		);
Please login to merge, or discard this patch.
classes/helpers/FrmListHelper.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 			return $this->get_pagenum();
247 247
 		}
248 248
 
249
-		return $this->_pagination_args[ $key ] ?? null;
249
+		return $this->_pagination_args[$key] ?? null;
250 250
 	}
251 251
 
252 252
 	/**
@@ -295,8 +295,8 @@  discard block
 block discarded – undo
295 295
 	 * @return void
296 296
 	 */
297 297
 	private function hidden_search_inputs( $param_name ) {
298
-		if ( ! empty( $_REQUEST[ $param_name ] ) ) {
299
-			$value = sanitize_text_field( wp_unslash( $_REQUEST[ $param_name ] ) );
298
+		if ( ! empty( $_REQUEST[$param_name] ) ) {
299
+			$value = sanitize_text_field( wp_unslash( $_REQUEST[$param_name] ) );
300 300
 			echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $value ) . '" />';
301 301
 		}
302 302
 	}
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 		echo "<ul class='subsubsub'>\n";
340 340
 
341 341
 		foreach ( $views as $class => $view ) {
342
-			$views[ $class ] = "\t" . '<li class="' . esc_attr( $class ) . '">' . $view;
342
+			$views[$class] = "\t" . '<li class="' . esc_attr( $class ) . '">' . $view;
343 343
 		}
344 344
 		echo implode( " |</li>\n", $views ) . "</li>\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
345 345
 		echo '</ul>';
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 		$out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
510 510
 
511 511
 		foreach ( $actions as $action => $link ) {
512
-			++$i;
512
+			++ $i;
513 513
 			$sep  = $i === $action_count ? '' : ' | ';
514 514
 			$out .= "<span class='$action'>$link$sep</span>";
515 515
 		}
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
 			'next'  => __( 'Next page', 'formidable' ),
748 748
 		);
749 749
 
750
-		return $labels[ $link ];
750
+		return $labels[$link];
751 751
 	}
752 752
 
753 753
 	private function current_url() {
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
 
847 847
 		// If the primary column doesn't exist fall back to the
848 848
 		// first non-checkbox column.
849
-		if ( ! isset( $columns[ $default ] ) ) {
849
+		if ( ! isset( $columns[$default] ) ) {
850 850
 			$default = self::get_default_primary_column_name();
851 851
 		}
852 852
 
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
 		 */
861 861
 		$column = apply_filters( 'list_table_primary_column', $default, $this->screen->id );
862 862
 
863
-		if ( empty( $column ) || ! isset( $columns[ $column ] ) ) {
863
+		if ( empty( $column ) || ! isset( $columns[$column] ) ) {
864 864
 			$column = $default;
865 865
 		}
866 866
 
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
 			$column_headers = array( array(), array(), array(), $this->get_primary_column_name() );
883 883
 
884 884
 			foreach ( $this->_column_headers as $key => $value ) {
885
-				$column_headers[ $key ] = $value;
885
+				$column_headers[$key] = $value;
886 886
 			}
887 887
 
888 888
 			return $column_headers;
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
 				$data[1] = false;
918 918
 			}
919 919
 
920
-			$sortable[ $id ] = $data;
920
+			$sortable[$id] = $data;
921 921
 		}
922 922
 
923 923
 		$primary = $this->get_primary_column_name();
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
 			static $cb_counter = 1;
969 969
 			$columns['cb']     = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All', 'formidable' ) . '</label>';
970 970
 			$columns['cb']    .= '<input id="cb-select-all-' . esc_attr( $cb_counter ) . '" type="checkbox" />';
971
-			++$cb_counter;
971
+			++ $cb_counter;
972 972
 		}
973 973
 
974 974
 		foreach ( $columns as $column_key => $column_display_name ) {
@@ -990,8 +990,8 @@  discard block
 block discarded – undo
990 990
 				$class[] = 'column-primary';
991 991
 			}
992 992
 
993
-			if ( isset( $sortable[ $column_key ] ) ) {
994
-				list( $orderby, $desc_first ) = $sortable[ $column_key ];
993
+			if ( isset( $sortable[$column_key] ) ) {
994
+				list( $orderby, $desc_first ) = $sortable[$column_key];
995 995
 
996 996
 				if ( $current_orderby == $orderby ) {
997 997
 					// The sorted column. The `aria-sort` attribute must be set only on the sorted column.
@@ -1111,7 +1111,7 @@  discard block
 block discarded – undo
1111 1111
 	 * @return bool Returns true if the setting is not set or if it is not false; otherwise, returns false.
1112 1112
 	 */
1113 1113
 	protected function should_display( $args, $settings ) {
1114
-		return ! isset( $args[ $settings ] ) || false !== $args[ $settings ];
1114
+		return ! isset( $args[$settings] ) || false !== $args[$settings];
1115 1115
 	}
1116 1116
 
1117 1117
 	/**
Please login to merge, or discard this patch.
classes/controllers/FrmStylesController.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 			/**
161 161
 			 * Update the form data on the "Manage Styles" tab after global settings are saved.
162 162
 			 */
163
-			function () {
163
+			function() {
164 164
 				self::manage_styles();
165 165
 			}
166 166
 		);
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 		$style_id = self::get_style_id_for_styler();
348 348
 
349 349
 		if ( ! $style_id ) {
350
-			$error_args   = array(
350
+			$error_args = array(
351 351
 				'title'      => __( 'No styles', 'formidable' ),
352 352
 				'body'       => __( 'You must have a style to use the Visual Styler.', 'formidable' ),
353 353
 				'cancel_url' => admin_url( 'admin.php?page=formidable' ),
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 		$form = FrmForm::getOne( $form_id );
366 366
 
367 367
 		if ( ! is_object( $form ) ) {
368
-			$error_args   = array(
368
+			$error_args = array(
369 369
 				'title'      => __( 'No forms', 'formidable' ),
370 370
 				'body'       => __( 'You must have a form to use the Visual Styler.', 'formidable' ),
371 371
 				'cancel_url' => admin_url( 'admin.php?page=formidable' ),
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 		if ( ! $form_id ) {
443 443
 			// TODO: Show a message why a random form is being shown (because no form is assigned to the style).
444 444
 			// Fallback to any form.
445
-			$where   = array(
445
+			$where = array(
446 446
 				'status'         => 'published',
447 447
 				// Make sure it's not a repeater.
448 448
 				'parent_form_id' => array( null, 0 ),
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 	private static function disable_admin_page_styling_on_submit_buttons() {
462 462
 		add_filter(
463 463
 			'frm_submit_button_class',
464
-			function ( $classes ) {
464
+			function( $classes ) {
465 465
 				$classes[] = 'frm_no_style_button';
466 466
 				return $classes;
467 467
 			}
@@ -693,13 +693,13 @@  discard block
 block discarded – undo
693 693
 	private static function force_form_style( $style ) {
694 694
 		add_filter(
695 695
 			'frm_add_form_style_class',
696
-			function ( $class ) use ( $style ) {
697
-				$split   = array_filter(
696
+			function( $class ) use ( $style ) {
697
+				$split = array_filter(
698 698
 					explode( ' ', $class ),
699 699
 					/**
700 700
 					 * @param string $class
701 701
 					 */
702
-					function ( $class ) {
702
+					function( $class ) {
703 703
 						return $class && 0 !== strpos( $class, 'frm_style_' );
704 704
 					}
705 705
 				);
@@ -827,11 +827,11 @@  discard block
 block discarded – undo
827 827
 		$forms = FrmForm::get_published_forms();
828 828
 
829 829
 		foreach ( $forms as $form ) {
830
-			if ( ! isset( $_POST['style'] ) || ! isset( $_POST['style'][ $form->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
830
+			if ( ! isset( $_POST['style'] ) || ! isset( $_POST['style'][$form->id] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
831 831
 				continue;
832 832
 			}
833 833
 
834
-			$new_style = sanitize_text_field( wp_unslash( $_POST['style'][ $form->id ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
834
+			$new_style = sanitize_text_field( wp_unslash( $_POST['style'][$form->id] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
835 835
 
836 836
 			$form->options['custom_style'] = $new_style;
837 837
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) );
@@ -1282,8 +1282,8 @@  discard block
 block discarded – undo
1282 1282
 	public static function get_style_val( $val, $form = 'default' ) {
1283 1283
 		$style = self::get_form_style( $form );
1284 1284
 
1285
-		if ( $style && isset( $style->post_content[ $val ] ) ) {
1286
-			return $style->post_content[ $val ];
1285
+		if ( $style && isset( $style->post_content[$val] ) ) {
1286
+			return $style->post_content[$val];
1287 1287
 		}
1288 1288
 
1289 1289
 		return null;
@@ -1310,7 +1310,7 @@  discard block
 block discarded – undo
1310 1310
 			} elseif ( 'alt_bg_color' == $name ) {
1311 1311
 				$setting = 'bg_color_active';
1312 1312
 			}
1313
-			$default_styles[ $name ] = $style->post_content[ $setting ];
1313
+			$default_styles[$name] = $style->post_content[$setting];
1314 1314
 			unset( $name, $val );
1315 1315
 		}
1316 1316
 
@@ -1366,16 +1366,16 @@  discard block
 block discarded – undo
1366 1366
 		$i          = 0;
1367 1367
 		$first_open = false;
1368 1368
 
1369
-		if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
1369
+		if ( isset( $wp_meta_boxes[$page][$context] ) ) {
1370 1370
 			foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
1371
-				if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
1372
-					foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
1371
+				if ( isset( $wp_meta_boxes[$page][$context][$priority] ) ) {
1372
+					foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) {
1373 1373
 						if ( false === $box || ! $box['title'] ) {
1374 1374
 							continue;
1375 1375
 						}
1376 1376
 
1377
-						++$i;
1378
-						$icon_id = array_key_exists( $box['id'], $icon_ids ) ? $icon_ids[ $box['id'] ] : 'frm-' . $box['id'];
1377
+						++ $i;
1378
+						$icon_id = array_key_exists( $box['id'], $icon_ids ) ? $icon_ids[$box['id']] : 'frm-' . $box['id'];
1379 1379
 
1380 1380
 						$open_class = '';
1381 1381
 
Please login to merge, or discard this patch.