Completed
Pull Request — master (#1091)
by Stephanie
28s
created
classes/controllers/FrmFormsController.php 2 patches
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1697,7 +1697,8 @@  discard block
 block discarded – undo
1697 1697
 		$vars   = array();
1698 1698
 		FrmAppHelper::include_svg();
1699 1699
 
1700
-		if ( isset( $_POST['frm_compact_fields'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
1700
+		if ( isset( $_POST['frm_compact_fields'] ) ) {
1701
+// phpcs:ignore WordPress.Security.NonceVerification.Missing
1701 1702
 			FrmAppHelper::permission_check( 'frm_edit_forms' );
1702 1703
 
1703 1704
 			// Javascript needs to be allowed in some field settings.
@@ -2007,7 +2008,8 @@  discard block
 block discarded – undo
2007 2008
 	private static function maybe_get_form_to_show( $id ) {
2008 2009
 		$form = false;
2009 2010
 
2010
-		if ( ! empty( $id ) ) { // form id or key is set
2011
+		if ( ! empty( $id ) ) {
2012
+// form id or key is set
2011 2013
 			$form = FrmForm::getOne( $id );
2012 2014
 			if ( ! $form || $form->parent_form_id || $form->status === 'trash' ) {
2013 2015
 				$form = false;
@@ -2090,7 +2092,8 @@  discard block
 block discarded – undo
2090 2092
 	private static function get_saved_errors( $form, $params ) {
2091 2093
 		global $frm_vars;
2092 2094
 
2093
-		if ( $params['posted_form_id'] == $form->id && $_POST && isset( $frm_vars['created_entries'][ $form->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
2095
+		if ( $params['posted_form_id'] == $form->id && $_POST && isset( $frm_vars['created_entries'][ $form->id ] ) ) {
2096
+// phpcs:ignore WordPress.Security.NonceVerification.Missing
2094 2097
 			$errors = $frm_vars['created_entries'][ $form->id ]['errors'];
2095 2098
 		} else {
2096 2099
 			$errors = array();
@@ -2243,7 +2246,8 @@  discard block
 block discarded – undo
2243 2246
 			}
2244 2247
 
2245 2248
 			if ( 'redirect' === FrmOnSubmitHelper::get_action_type( $action ) ) {
2246
-				if ( $has_redirect ) { // Do not process because we run the first redirect action only.
2249
+				if ( $has_redirect ) {
2250
+// Do not process because we run the first redirect action only.
2247 2251
 					continue;
2248 2252
 				}
2249 2253
 
@@ -2402,12 +2406,14 @@  discard block
 block discarded – undo
2402 2406
 
2403 2407
 		$doing_ajax = FrmAppHelper::doing_ajax();
2404 2408
 
2405
-		if ( ! empty( $args['ajax'] ) && $doing_ajax && empty( $args['force_delay_redirect'] ) ) { // Is AJAX submit and there is just one Redirect action runs.
2409
+		if ( ! empty( $args['ajax'] ) && $doing_ajax && empty( $args['force_delay_redirect'] ) ) {
2410
+// Is AJAX submit and there is just one Redirect action runs.
2406 2411
 			echo json_encode( array( 'redirect' => $success_url ) );
2407 2412
 			wp_die();
2408 2413
 		}
2409 2414
 
2410
-		if ( ! headers_sent() && empty( $args['force_delay_redirect'] ) ) { // Not AJAX submit, no headers sent, and there is just one Redirect action runs.
2415
+		if ( ! headers_sent() && empty( $args['force_delay_redirect'] ) ) {
2416
+// Not AJAX submit, no headers sent, and there is just one Redirect action runs.
2411 2417
 			wp_redirect( esc_url_raw( $success_url ) );
2412 2418
 			die(); // do not use wp_die or redirect fails
2413 2419
 		}
@@ -2432,7 +2438,8 @@  discard block
 block discarded – undo
2432 2438
 
2433 2439
 		echo FrmAppHelper::maybe_kses( $redirect_msg ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2434 2440
 		echo '<script>';
2435
-		if ( empty( $args['doing_ajax'] ) ) { // Not AJAX submit, delay JS until window.load.
2441
+		if ( empty( $args['doing_ajax'] ) ) {
2442
+// Not AJAX submit, delay JS until window.load.
2436 2443
 			echo 'window.onload=function(){';
2437 2444
 		}
2438 2445
 		echo 'setTimeout(function(){window.location="' . esc_url_raw( $args['success_url'] ) . '";}, ' . intval( $delay_time ) . ');';
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -520,11 +520,11 @@  discard block
 block discarded – undo
520 520
 			),
521 521
 		);
522 522
 
523
-		if ( ! isset( $available_status[ $status ] ) ) {
523
+		if ( ! isset( $available_status[$status] ) ) {
524 524
 			return;
525 525
 		}
526 526
 
527
-		FrmAppHelper::permission_check( $available_status[ $status ]['permission'] );
527
+		FrmAppHelper::permission_check( $available_status[$status]['permission'] );
528 528
 
529 529
 		$params = FrmForm::list_page_params();
530 530
 
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
 		check_admin_referer( $status . '_form_' . $params['id'] );
533 533
 
534 534
 		$count = 0;
535
-		if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) {
535
+		if ( FrmForm::set_status( $params['id'], $available_status[$status]['new_status'] ) ) {
536 536
 			$count ++;
537 537
 		}
538 538
 
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 		/* translators: %1$s: Number of forms, %2$s: Start link HTML, %3$s: End link HTML */
550 550
 		$available_status['trash']['message']   = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=untrash&form_type=' . $form_type . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' );
551 551
 
552
-		$message = $available_status[ $status ]['message'];
552
+		$message = $available_status[$status]['message'];
553 553
 
554 554
 		self::display_forms_list( $params, $message );
555 555
 	}
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 				'type'  => 'request',
571 571
 			)
572 572
 		);
573
-		$message      = sprintf(
573
+		$message = sprintf(
574 574
 			/* translators: %1$s: Number of forms, %2$s: Start link HTML, %3$s: End link HTML */
575 575
 			_n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ),
576 576
 			$count,
@@ -994,11 +994,11 @@  discard block
 block discarded – undo
994 994
 			}
995 995
 
996 996
 			foreach ( $template['categories'] as $category ) {
997
-				if ( ! isset( $templates_by_category[ $category ] ) ) {
998
-					$templates_by_category[ $category ] = array();
997
+				if ( ! isset( $templates_by_category[$category] ) ) {
998
+					$templates_by_category[$category] = array();
999 999
 				}
1000 1000
 
1001
-				$templates_by_category[ $category ][] = $template;
1001
+				$templates_by_category[$category][] = $template;
1002 1002
 			}
1003 1003
 		}
1004 1004
 		unset( $template );
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
 		$forms                    = FrmForm::get_published_forms( $where );
1028 1028
 		$view_path                = FrmAppHelper::plugin_path() . '/classes/views/frm-forms/';
1029 1029
 
1030
-		$templates_by_category[ $my_templates_translation ] = $custom_templates;
1030
+		$templates_by_category[$my_templates_translation] = $custom_templates;
1031 1031
 
1032 1032
 		unset( $pricing, $license_type, $where );
1033 1033
 		wp_enqueue_script( 'accordion' ); // register accordion for template groups
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
 
1271 1271
 		foreach ( array( 'landing', 'chat' ) as $feature ) {
1272 1272
 			if ( ! FrmAppHelper::show_new_feature( $feature ) ) {
1273
-				unset( $sections[ $feature ] );
1273
+				unset( $sections[$feature] );
1274 1274
 			}
1275 1275
 		}
1276 1276
 
@@ -1303,7 +1303,7 @@  discard block
 block discarded – undo
1303 1303
 				$section['id'] = $section['anchor'];
1304 1304
 			}
1305 1305
 
1306
-			$sections[ $key ] = $section;
1306
+			$sections[$key] = $section;
1307 1307
 		}
1308 1308
 
1309 1309
 		return $sections;
@@ -1421,7 +1421,7 @@  discard block
 block discarded – undo
1421 1421
 		if ( ! empty( $user_fields ) ) {
1422 1422
 			$user_helpers = array();
1423 1423
 			foreach ( $user_fields as $uk => $uf ) {
1424
-				$user_helpers[ '|user_id| show="' . $uk . '"' ] = $uf;
1424
+				$user_helpers['|user_id| show="' . $uk . '"'] = $uf;
1425 1425
 				unset( $uk, $uf );
1426 1426
 			}
1427 1427
 
@@ -1553,7 +1553,7 @@  discard block
 block discarded – undo
1553 1553
 		if ( ! isset( $frm_vars['js_validate_forms'] ) ) {
1554 1554
 			$frm_vars['js_validate_forms'] = array();
1555 1555
 		}
1556
-		$frm_vars['js_validate_forms'][ $form->id ] = $form;
1556
+		$frm_vars['js_validate_forms'][$form->id] = $form;
1557 1557
 	}
1558 1558
 
1559 1559
 	public static function get_email_html() {
@@ -1708,7 +1708,7 @@  discard block
 block discarded – undo
1708 1708
 				add_filter( 'frm_validate_form', 'FrmFormsController::json_error' );
1709 1709
 			} else {
1710 1710
 				$vars   = FrmAppHelper::json_to_array( $json_vars );
1711
-				$action = $vars[ $action ];
1711
+				$action = $vars[$action];
1712 1712
 				unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
1713 1713
 				$_REQUEST = array_merge( $_REQUEST, $vars ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
1714 1714
 				$_POST    = array_merge( $_POST, $_REQUEST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
@@ -1842,7 +1842,7 @@  discard block
 block discarded – undo
1842 1842
 		$actions = array();
1843 1843
 		foreach ( $frm_vars['forms_loaded'] as $form ) {
1844 1844
 			if ( is_object( $form ) ) {
1845
-				$actions[ $form->id ] = $form->name;
1845
+				$actions[$form->id] = $form->name;
1846 1846
 			}
1847 1847
 			unset( $form );
1848 1848
 		}
@@ -2083,8 +2083,8 @@  discard block
 block discarded – undo
2083 2083
 	private static function get_saved_errors( $form, $params ) {
2084 2084
 		global $frm_vars;
2085 2085
 
2086
-		if ( $params['posted_form_id'] == $form->id && $_POST && isset( $frm_vars['created_entries'][ $form->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
2087
-			$errors = $frm_vars['created_entries'][ $form->id ]['errors'];
2086
+		if ( $params['posted_form_id'] == $form->id && $_POST && isset( $frm_vars['created_entries'][$form->id] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
2087
+			$errors = $frm_vars['created_entries'][$form->id]['errors'];
2088 2088
 		} else {
2089 2089
 			$errors = array();
2090 2090
 		}
@@ -2106,7 +2106,7 @@  discard block
 block discarded – undo
2106 2106
 	public static function just_created_entry( $form_id ) {
2107 2107
 		global $frm_vars;
2108 2108
 
2109
-		return ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form_id ] ) && isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) ? $frm_vars['created_entries'][ $form_id ]['entry_id'] : 0;
2109
+		return ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][$form_id] ) && isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) ? $frm_vars['created_entries'][$form_id]['entry_id'] : 0;
2110 2110
 	}
2111 2111
 
2112 2112
 	/**
@@ -2126,7 +2126,7 @@  discard block
 block discarded – undo
2126 2126
 	private static function get_confirmation_method( $atts ) {
2127 2127
 		$action = FrmOnSubmitHelper::current_event( $atts );
2128 2128
 		$opt    = 'update' === $action ? 'edit_action' : 'success_action';
2129
-		$method = ( isset( $atts['form']->options[ $opt ] ) && ! empty( $atts['form']->options[ $opt ] ) ) ? $atts['form']->options[ $opt ] : 'message';
2129
+		$method = ( isset( $atts['form']->options[$opt] ) && ! empty( $atts['form']->options[$opt] ) ) ? $atts['form']->options[$opt] : 'message';
2130 2130
 
2131 2131
 		if ( ! empty( $atts['entry_id'] ) && FrmOnSubmitHelper::form_has_migrated( $atts['form'] ) ) {
2132 2132
 			$met_actions = self::get_met_on_submit_actions( $atts, $action );
@@ -2147,7 +2147,7 @@  discard block
 block discarded – undo
2147 2147
 	public static function maybe_trigger_redirect( $form, $params, $args ) {
2148 2148
 		if ( ! isset( $params['id'] ) ) {
2149 2149
 			global $frm_vars;
2150
-			$params['id'] = $frm_vars['created_entries'][ $form->id ]['entry_id'];
2150
+			$params['id'] = $frm_vars['created_entries'][$form->id]['entry_id'];
2151 2151
 		}
2152 2152
 
2153 2153
 		$conf_method = self::get_confirmation_method(
@@ -2228,7 +2228,7 @@  discard block
 block discarded – undo
2228 2228
 		$args['success_opt'] = $opt;
2229 2229
 		$args['ajax']        = ! empty( $frm_vars['ajax'] );
2230 2230
 
2231
-		if ( $args['conf_method'] === 'page' && is_numeric( $args['form']->options[ $opt . '_page_id' ] ) ) {
2231
+		if ( $args['conf_method'] === 'page' && is_numeric( $args['form']->options[$opt . '_page_id'] ) ) {
2232 2232
 			self::load_page_after_submit( $args );
2233 2233
 		} elseif ( $args['conf_method'] === 'redirect' ) {
2234 2234
 			self::redirect_after_submit( $args );
@@ -2383,7 +2383,7 @@  discard block
 block discarded – undo
2383 2383
 
2384 2384
 		$opt = 'update' === $args['action'] ? 'edit_' : 'success_';
2385 2385
 
2386
-		$new_args['conf_method'] = $new_args['form']->options[ $opt . 'action' ];
2386
+		$new_args['conf_method'] = $new_args['form']->options[$opt . 'action'];
2387 2387
 
2388 2388
 		/**
2389 2389
 		 * Filters the run success action args.
@@ -2403,8 +2403,8 @@  discard block
 block discarded – undo
2403 2403
 	private static function load_page_after_submit( $args ) {
2404 2404
 		global $post;
2405 2405
 		$opt = $args['success_opt'];
2406
-		if ( ! $post || $args['form']->options[ $opt . '_page_id' ] != $post->ID ) {
2407
-			$page     = get_post( $args['form']->options[ $opt . '_page_id' ] );
2406
+		if ( ! $post || $args['form']->options[$opt . '_page_id'] != $post->ID ) {
2407
+			$page     = get_post( $args['form']->options[$opt . '_page_id'] );
2408 2408
 			$old_post = $post;
2409 2409
 			$post     = $page;
2410 2410
 			$content  = apply_filters( 'frm_content', $page->post_content, $args['form'], $args['entry_id'] );
@@ -2434,7 +2434,7 @@  discard block
 block discarded – undo
2434 2434
 		add_filter( 'frm_use_wpautop', '__return_false' );
2435 2435
 
2436 2436
 		$opt         = $args['success_opt'];
2437
-		$success_url = trim( $args['form']->options[ $opt . '_url' ] );
2437
+		$success_url = trim( $args['form']->options[$opt . '_url'] );
2438 2438
 		$success_url = apply_filters( 'frm_content', $success_url, $args['form'], $args['entry_id'] );
2439 2439
 		$success_url = do_shortcode( $success_url );
2440 2440
 
@@ -2606,7 +2606,7 @@  discard block
 block discarded – undo
2606 2606
 			'description' => false,
2607 2607
 			'reset'       => false,
2608 2608
 		);
2609
-		$args     = wp_parse_args( $args, $defaults );
2609
+		$args = wp_parse_args( $args, $defaults );
2610 2610
 	}
2611 2611
 
2612 2612
 	/**
@@ -2644,7 +2644,7 @@  discard block
 block discarded – undo
2644 2644
 		$opt          = isset( $args['success_opt'] ) ? $args['success_opt'] : 'success';
2645 2645
 
2646 2646
 		if ( $entry_id && is_numeric( $entry_id ) ) {
2647
-			$message = isset( $form->options[ $opt . '_msg' ] ) ? $form->options[ $opt . '_msg' ] : $frm_settings->success_msg;
2647
+			$message = isset( $form->options[$opt . '_msg'] ) ? $form->options[$opt . '_msg'] : $frm_settings->success_msg;
2648 2648
 			$class   = 'frm_message';
2649 2649
 		} else {
2650 2650
 			$message = $frm_settings->failed_msg;
@@ -2868,7 +2868,7 @@  discard block
 block discarded – undo
2868 2868
 
2869 2869
 		check_ajax_referer( 'frm_ajax', 'nonce' );
2870 2870
 
2871
-		$html             = FrmAppHelper::clip(
2871
+		$html = FrmAppHelper::clip(
2872 2872
 			function() {
2873 2873
 				FrmAppHelper::maybe_autocomplete_pages_options(
2874 2874
 					array(
@@ -2905,7 +2905,7 @@  discard block
 block discarded – undo
2905 2905
 		FrmAppHelper::unserialize_or_decode( $form->options );
2906 2906
 
2907 2907
 		$flag_key = 'on_submit_migrated';
2908
-		if ( ! empty( $form->options[ $flag_key ] ) ) {
2908
+		if ( ! empty( $form->options[$flag_key] ) ) {
2909 2909
 			return;
2910 2910
 		}
2911 2911
 
@@ -2949,7 +2949,7 @@  discard block
 block discarded – undo
2949 2949
 		$action['post_content'] = FrmAppHelper::prepare_and_encode( $action['post_content'] );
2950 2950
 		FrmDb::save_json_post( $action );
2951 2951
 
2952
-		$form->options[ $flag_key ] = 1;
2952
+		$form->options[$flag_key] = 1;
2953 2953
 		FrmForm::update( $form->id, array( 'options' => $form->options ) );
2954 2954
 	}
2955 2955
 
@@ -2965,20 +2965,20 @@  discard block
 block discarded – undo
2965 2965
 	private static function get_on_submit_action_data_from_form_options( $form_options, $event = 'create' ) {
2966 2966
 		$opt  = 'update' === $event ? 'edit_' : 'success_';
2967 2967
 		$data = array(
2968
-			'success_action' => isset( $form_options[ $opt . 'action' ] ) ? $form_options[ $opt . 'action' ] : FrmOnSubmitHelper::get_default_action_type(),
2968
+			'success_action' => isset( $form_options[$opt . 'action'] ) ? $form_options[$opt . 'action'] : FrmOnSubmitHelper::get_default_action_type(),
2969 2969
 		);
2970 2970
 
2971 2971
 		switch ( $data['success_action'] ) {
2972 2972
 			case 'redirect':
2973
-				$data['success_url'] = isset( $form_options[ $opt . 'url' ] ) ? $form_options[ $opt . 'url' ] : '';
2973
+				$data['success_url'] = isset( $form_options[$opt . 'url'] ) ? $form_options[$opt . 'url'] : '';
2974 2974
 				break;
2975 2975
 
2976 2976
 			case 'page':
2977
-				$data['success_page_id'] = isset( $form_options[ $opt . 'page_id' ] ) ? $form_options[ $opt . 'page_id' ] : '';
2977
+				$data['success_page_id'] = isset( $form_options[$opt . 'page_id'] ) ? $form_options[$opt . 'page_id'] : '';
2978 2978
 				break;
2979 2979
 
2980 2980
 			default:
2981
-				$data['success_msg'] = isset( $form_options[ $opt . 'msg' ] ) ? $form_options[ $opt . 'msg' ] : FrmOnSubmitHelper::get_default_msg();
2981
+				$data['success_msg'] = isset( $form_options[$opt . 'msg'] ) ? $form_options[$opt . 'msg'] : FrmOnSubmitHelper::get_default_msg();
2982 2982
 				$data['show_form']   = ! empty( $form_options['show_form'] );
2983 2983
 		}
2984 2984
 
Please login to merge, or discard this patch.