Completed
Pull Request — master (#2184)
by
unknown
36s
created
classes/controllers/FrmFormActionsController.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -113,19 +113,19 @@  discard block
 block discarded – undo
113 113
 		}
114 114
 
115 115
 		foreach ( $action_controls as $action ) {
116
-			if ( isset( $groups[ $action->id_base ] ) || in_array( $action->id_base, $grouped ) ) {
116
+			if ( isset( $groups[$action->id_base] ) || in_array( $action->id_base, $grouped ) ) {
117 117
 				continue;
118 118
 			}
119 119
 
120 120
 			$this_group = $action->action_options['group'];
121
-			if ( ! isset( $groups[ $this_group ] ) ) {
121
+			if ( ! isset( $groups[$this_group] ) ) {
122 122
 				$this_group = 'misc';
123 123
 			}
124 124
 
125
-			if ( ! isset( $groups[ $this_group ]['actions'] ) ) {
126
-				$groups[ $this_group ]['actions'] = array();
125
+			if ( ! isset( $groups[$this_group]['actions'] ) ) {
126
+				$groups[$this_group]['actions'] = array();
127 127
 			}
128
-			$groups[ $this_group ]['actions'][] = $action->id_base;
128
+			$groups[$this_group]['actions'][] = $action->id_base;
129 129
 
130 130
 			unset( $action );
131 131
 		}
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 				return $a;
280 280
 			}
281 281
 
282
-			$actions[ $a->id_base ] = $a;
282
+			$actions[$a->id_base] = $a;
283 283
 		}
284 284
 
285 285
 		return $actions;
@@ -313,18 +313,18 @@  discard block
 block discarded – undo
313 313
 		$action_map = array();
314 314
 
315 315
 		foreach ( $action_controls as $key => $control ) {
316
-			$action_map[ $control->id_base ] = $key;
316
+			$action_map[$control->id_base] = $key;
317 317
 		}
318 318
 
319 319
 		self::maybe_show_limit_warning( $form->id, $form_actions );
320 320
 
321 321
 		foreach ( $form_actions as $action ) {
322
-			if ( ! isset( $action_map[ $action->post_excerpt ] ) ) {
322
+			if ( ! isset( $action_map[$action->post_excerpt] ) ) {
323 323
 				// don't try and show settings if action no longer exists
324 324
 				continue;
325 325
 			}
326 326
 
327
-			self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values );
327
+			self::action_control( $action, $form, $action->ID, $action_controls[$action_map[$action->post_excerpt]], $values );
328 328
 		}
329 329
 	}
330 330
 
@@ -592,8 +592,8 @@  discard block
 block discarded – undo
592 592
 			}
593 593
 
594 594
 			// Store actions so they can be triggered with the correct priority.
595
-			$stored_actions[ $action->ID ]  = $action;
596
-			$action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority'];
595
+			$stored_actions[$action->ID]  = $action;
596
+			$action_priority[$action->ID] = $link_settings[$action->post_excerpt]->action_options['priority'];
597 597
 
598 598
 			unset( $action );
599 599
 		}//end foreach
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
 			new FrmNotification();
606 606
 
607 607
 			foreach ( $action_priority as $action_id => $priority ) {
608
-				$action = $stored_actions[ $action_id ];
608
+				$action = $stored_actions[$action_id];
609 609
 
610 610
 				/**
611 611
 				 * Allows custom form action trigger.
@@ -669,12 +669,12 @@  discard block
 block discarded – undo
669 669
 	}
670 670
 
671 671
 	public function register( $action_class ) {
672
-		$this->actions[ $action_class ] = new $action_class();
672
+		$this->actions[$action_class] = new $action_class();
673 673
 	}
674 674
 
675 675
 	public function unregister( $action_class ) {
676
-		if ( isset( $this->actions[ $action_class ] ) ) {
677
-			unset( $this->actions[ $action_class ] );
676
+		if ( isset( $this->actions[$action_class] ) ) {
677
+			unset( $this->actions[$action_class] );
678 678
 		}
679 679
 	}
680 680
 
@@ -683,8 +683,8 @@  discard block
 block discarded – undo
683 683
 
684 684
 		foreach ( $keys as $key ) {
685 685
 			// don't register new action if old action with the same id is already registered
686
-			if ( ! isset( $this->actions[ $key ] ) ) {
687
-				$this->actions[ $key ]->_register();
686
+			if ( ! isset( $this->actions[$key] ) ) {
687
+				$this->actions[$key]->_register();
688 688
 			}
689 689
 		}
690 690
 	}
Please login to merge, or discard this patch.
classes/models/FrmFormAction.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -208,9 +208,9 @@  discard block
 block discarded – undo
208 208
 		$groups = FrmFormActionsController::form_action_groups();
209 209
 		$group  = 'misc';
210 210
 
211
-		if ( isset( $action_options['group'] ) && isset( $groups[ $action_options['group'] ] ) ) {
211
+		if ( isset( $action_options['group'] ) && isset( $groups[$action_options['group']] ) ) {
212 212
 			$group = $action_options['group'];
213
-		} elseif ( isset( $groups[ $this->id_base ] ) ) {
213
+		} elseif ( isset( $groups[$this->id_base] ) ) {
214 214
 			$group = $this->id_base;
215 215
 		} else {
216 216
 			foreach ( $groups as $name => $check_group ) {
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 			}
222 222
 		}
223 223
 
224
-		$groups[ $group ]['id'] = $group;
225
-		return $groups[ $group ];
224
+		$groups[$group]['id'] = $group;
225
+		return $groups[$group];
226 226
 	}
227 227
 
228 228
 	/**
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 	 * @return int $post_id
334 334
 	 */
335 335
 	public function maybe_create_action( $action, $forms ) {
336
-		if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && isset( $forms[ $action['menu_order'] ] ) && $forms[ $action['menu_order'] ] === 'updated' ) {
336
+		if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && isset( $forms[$action['menu_order']] ) && $forms[$action['menu_order']] === 'updated' ) {
337 337
 			// Update action only
338 338
 			$action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] );
339 339
 			$post_id                = $this->save_settings( $action );
@@ -356,18 +356,18 @@  discard block
 block discarded – undo
356 356
 		$switch             = $this->get_global_switch_fields();
357 357
 
358 358
 		foreach ( (array) $action->post_content as $key => $val ) {
359
-			if ( is_numeric( $val ) && isset( $frm_duplicate_ids[ $val ] ) ) {
360
-				$action->post_content[ $key ] = $frm_duplicate_ids[ $val ];
359
+			if ( is_numeric( $val ) && isset( $frm_duplicate_ids[$val] ) ) {
360
+				$action->post_content[$key] = $frm_duplicate_ids[$val];
361 361
 			} elseif ( ! is_array( $val ) ) {
362
-				$action->post_content[ $key ] = FrmFieldsHelper::switch_field_ids( $val );
363
-			} elseif ( isset( $switch[ $key ] ) && is_array( $switch[ $key ] ) ) {
362
+				$action->post_content[$key] = FrmFieldsHelper::switch_field_ids( $val );
363
+			} elseif ( isset( $switch[$key] ) && is_array( $switch[$key] ) ) {
364 364
 				// loop through each value if empty
365
-				if ( empty( $switch[ $key ] ) ) {
366
-					$switch[ $key ] = array_keys( $val );
365
+				if ( empty( $switch[$key] ) ) {
366
+					$switch[$key] = array_keys( $val );
367 367
 				}
368 368
 
369
-				foreach ( $switch[ $key ] as $subkey ) {
370
-					$action->post_content[ $key ] = $this->duplicate_array_walk( $action->post_content[ $key ], $subkey, $val );
369
+				foreach ( $switch[$key] as $subkey ) {
370
+					$action->post_content[$key] = $this->duplicate_array_walk( $action->post_content[$key], $subkey, $val );
371 371
 				}
372 372
 			}
373 373
 
@@ -385,20 +385,20 @@  discard block
 block discarded – undo
385 385
 			foreach ( $subkey as $subkey2 ) {
386 386
 				foreach ( (array) $val as $ck => $cv ) {
387 387
 					if ( is_array( $cv ) ) {
388
-						$action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey2, $cv );
389
-					} elseif ( isset( $cv[ $subkey ] ) && is_numeric( $cv[ $subkey ] ) && isset( $frm_duplicate_ids[ $cv[ $subkey ] ] ) ) {
390
-						$action[ $ck ][ $subkey ] = $frm_duplicate_ids[ $cv[ $subkey ] ];
388
+						$action[$ck] = $this->duplicate_array_walk( $action[$ck], $subkey2, $cv );
389
+					} elseif ( isset( $cv[$subkey] ) && is_numeric( $cv[$subkey] ) && isset( $frm_duplicate_ids[$cv[$subkey]] ) ) {
390
+						$action[$ck][$subkey] = $frm_duplicate_ids[$cv[$subkey]];
391 391
 					}
392 392
 				}
393 393
 			}
394 394
 		} else {
395 395
 			foreach ( (array) $val as $ck => $cv ) {
396 396
 				if ( is_array( $cv ) ) {
397
-					$action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey, $cv );
398
-				} elseif ( $ck == $subkey && isset( $frm_duplicate_ids[ $cv ] ) ) {
399
-					$action[ $ck ] = $frm_duplicate_ids[ $cv ];
397
+					$action[$ck] = $this->duplicate_array_walk( $action[$ck], $subkey, $cv );
398
+				} elseif ( $ck == $subkey && isset( $frm_duplicate_ids[$cv] ) ) {
399
+					$action[$ck] = $frm_duplicate_ids[$cv];
400 400
 				} elseif ( $ck == $subkey ) {
401
-					$action[ $ck ] = $this->maybe_switch_field_ids( $action[ $ck ] );
401
+					$action[$ck] = $this->maybe_switch_field_ids( $action[$ck] );
402 402
 				}
403 403
 			}
404 404
 		}//end if
@@ -422,10 +422,10 @@  discard block
 block discarded – undo
422 422
 		}
423 423
 
424 424
 		// phpcs:ignore WordPress.Security.NonceVerification.Missing
425
-		if ( isset( $_POST[ $this->option_name ] ) && is_array( $_POST[ $this->option_name ] ) ) {
425
+		if ( isset( $_POST[$this->option_name] ) && is_array( $_POST[$this->option_name] ) ) {
426 426
 			// Sanitizing removes scripts and <email> type of values.
427 427
 			// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
428
-			$settings = wp_unslash( $_POST[ $this->option_name ] );
428
+			$settings = wp_unslash( $_POST[$this->option_name] );
429 429
 		} else {
430 430
 			return;
431 431
 		}
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 		foreach ( $settings as $number => $new_instance ) {
436 436
 			$this->_set( $number );
437 437
 
438
-			$old_instance = isset( $all_instances[ $number ] ) ? $all_instances[ $number ] : array();
438
+			$old_instance = isset( $all_instances[$number] ) ? $all_instances[$number] : array();
439 439
 
440 440
 			if ( ! isset( $new_instance['post_status'] ) ) {
441 441
 				$new_instance['post_status'] = 'draft';
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
 			$instance['post_content'] = apply_filters( 'frm_before_save_' . $this->id_base . '_action', $instance['post_content'], $instance, $new_instance, $old_instance, $this );
475 475
 
476 476
 			if ( false !== $instance ) {
477
-				$all_instances[ $number ] = $instance;
477
+				$all_instances[$number] = $instance;
478 478
 			}
479 479
 
480 480
 			$action_ids[] = $this->save_settings( $instance );
@@ -560,12 +560,12 @@  discard block
 block discarded – undo
560 560
 			// some plugins/themes are formatting the post_excerpt
561 561
 			$action->post_excerpt = sanitize_title( $action->post_excerpt );
562 562
 
563
-			if ( ! isset( $action_controls[ $action->post_excerpt ] ) ) {
563
+			if ( ! isset( $action_controls[$action->post_excerpt] ) ) {
564 564
 				continue;
565 565
 			}
566 566
 
567
-			$action                  = $action_controls[ $action->post_excerpt ]->prepare_action( $action );
568
-			$settings[ $action->ID ] = $action;
567
+			$action                  = $action_controls[$action->post_excerpt]->prepare_action( $action );
568
+			$settings[$action->ID] = $action;
569 569
 
570 570
 			if ( count( $settings ) >= $limit ) {
571 571
 				break;
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 	 * @return int The filtered limit value.
590 590
 	 */
591 591
 	public static function get_action_limit( $form_id, $limit = 99 ) {
592
-		$type  = 'all';
592
+		$type = 'all';
593 593
 		return (int) apply_filters( 'frm_form_action_limit', (int) $limit, compact( 'type', 'form_id' ) );
594 594
 	}
595 595
 
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
 			'limit'       => 99,
613 613
 			'post_status' => $default_status,
614 614
 		);
615
-		$args     = wp_parse_args( $args, $defaults );
615
+		$args = wp_parse_args( $args, $defaults );
616 616
 	}
617 617
 
618 618
 	/**
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
 
683 683
 			$action = $this->prepare_action( $action );
684 684
 
685
-			$settings[ $action->ID ] = $action;
685
+			$settings[$action->ID] = $action;
686 686
 		}
687 687
 
688 688
 		if ( 1 === $limit ) {
@@ -725,10 +725,10 @@  discard block
 block discarded – undo
725 725
 
726 726
 		foreach ( $default_values as $k => $vals ) {
727 727
 			if ( is_array( $vals ) && ! empty( $vals ) ) {
728
-				if ( 'event' === $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) {
728
+				if ( 'event' === $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[$k] ) ) {
729 729
 					continue;
730 730
 				}
731
-				$action->post_content[ $k ] = wp_parse_args( $action->post_content[ $k ], $vals );
731
+				$action->post_content[$k] = wp_parse_args( $action->post_content[$k], $vals );
732 732
 			}
733 733
 		}
734 734
 
@@ -816,9 +816,9 @@  discard block
 block discarded – undo
816 816
 
817 817
 		// fill with existing options
818 818
 		foreach ( $action->post_content as $name => $val ) {
819
-			if ( isset( $form->options[ $name ] ) ) {
820
-				$action->post_content[ $name ] = $form->options[ $name ];
821
-				unset( $form->options[ $name ] );
819
+			if ( isset( $form->options[$name] ) ) {
820
+				$action->post_content[$name] = $form->options[$name];
821
+				unset( $form->options[$name] );
822 822
 			}
823 823
 		}
824 824
 
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
 				$stop = $stop ? false : true;
885 885
 			}
886 886
 
887
-			$met[ $stop ] = $stop;
887
+			$met[$stop] = $stop;
888 888
 		}//end foreach
889 889
 
890 890
 		if ( $notification['conditions']['any_all'] === 'all' && ! empty( $met ) && isset( $met[0] ) && isset( $met[1] ) ) {
@@ -935,8 +935,8 @@  discard block
 block discarded – undo
935 935
 	private static function get_value_from_entry( $entry, $field_id ) {
936 936
 		$observed_value = '';
937 937
 
938
-		if ( isset( $entry->metas[ $field_id ] ) ) {
939
-			$observed_value = $entry->metas[ $field_id ];
938
+		if ( isset( $entry->metas[$field_id] ) ) {
939
+			$observed_value = $entry->metas[$field_id];
940 940
 		} elseif ( $entry->post_id && FrmAppHelper::pro_is_installed() ) {
941 941
 			$field          = FrmField::getOne( $field_id );
942 942
 			$observed_value = FrmProEntryMetaHelper::get_post_or_meta_value(
@@ -1010,7 +1010,7 @@  discard block
 block discarded – undo
1010 1010
 		$form_fields = FrmField::get_all_for_form( $form_id, '', 'include' );
1011 1011
 		return array_filter(
1012 1012
 			$form_fields,
1013
-			function ( $form_field ) {
1013
+			function( $form_field ) {
1014 1014
 				return ! FrmField::is_no_save_field( $form_field->type );
1015 1015
 			}
1016 1016
 		);
Please login to merge, or discard this patch.