Completed
Branch master (69f8ff)
by Stephanie
26s
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   +28 added lines, -28 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'] ) ) {
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 );
@@ -2387,7 +2387,7 @@  discard block
 block discarded – undo
2387 2387
 
2388 2388
 		$opt = 'update' === $args['action'] ? 'edit_' : 'success_';
2389 2389
 
2390
-		$new_args['conf_method'] = $new_args['form']->options[ $opt . 'action' ];
2390
+		$new_args['conf_method'] = $new_args['form']->options[$opt . 'action'];
2391 2391
 
2392 2392
 		/**
2393 2393
 		 * Filters the run success action args.
@@ -2407,8 +2407,8 @@  discard block
 block discarded – undo
2407 2407
 	private static function load_page_after_submit( $args ) {
2408 2408
 		global $post;
2409 2409
 		$opt = $args['success_opt'];
2410
-		if ( ! $post || $args['form']->options[ $opt . '_page_id' ] != $post->ID ) {
2411
-			$page     = get_post( $args['form']->options[ $opt . '_page_id' ] );
2410
+		if ( ! $post || $args['form']->options[$opt . '_page_id'] != $post->ID ) {
2411
+			$page     = get_post( $args['form']->options[$opt . '_page_id'] );
2412 2412
 			$old_post = $post;
2413 2413
 			$post     = $page;
2414 2414
 			$content  = apply_filters( 'frm_content', $page->post_content, $args['form'], $args['entry_id'] );
@@ -2438,7 +2438,7 @@  discard block
 block discarded – undo
2438 2438
 		add_filter( 'frm_use_wpautop', '__return_false' );
2439 2439
 
2440 2440
 		$opt         = $args['success_opt'];
2441
-		$success_url = trim( $args['form']->options[ $opt . '_url' ] );
2441
+		$success_url = trim( $args['form']->options[$opt . '_url'] );
2442 2442
 		$success_url = apply_filters( 'frm_content', $success_url, $args['form'], $args['entry_id'] );
2443 2443
 		$success_url = do_shortcode( $success_url );
2444 2444
 
@@ -2610,7 +2610,7 @@  discard block
 block discarded – undo
2610 2610
 			'description' => false,
2611 2611
 			'reset'       => false,
2612 2612
 		);
2613
-		$args     = wp_parse_args( $args, $defaults );
2613
+		$args = wp_parse_args( $args, $defaults );
2614 2614
 	}
2615 2615
 
2616 2616
 	/**
@@ -2648,7 +2648,7 @@  discard block
 block discarded – undo
2648 2648
 		$opt          = isset( $args['success_opt'] ) ? $args['success_opt'] : 'success';
2649 2649
 
2650 2650
 		if ( $entry_id && is_numeric( $entry_id ) ) {
2651
-			$message = isset( $form->options[ $opt . '_msg' ] ) ? $form->options[ $opt . '_msg' ] : $frm_settings->success_msg;
2651
+			$message = isset( $form->options[$opt . '_msg'] ) ? $form->options[$opt . '_msg'] : $frm_settings->success_msg;
2652 2652
 			$class   = 'frm_message';
2653 2653
 		} else {
2654 2654
 			$message = $frm_settings->failed_msg;
@@ -2872,7 +2872,7 @@  discard block
 block discarded – undo
2872 2872
 
2873 2873
 		check_ajax_referer( 'frm_ajax', 'nonce' );
2874 2874
 
2875
-		$html             = FrmAppHelper::clip(
2875
+		$html = FrmAppHelper::clip(
2876 2876
 			function() {
2877 2877
 				FrmAppHelper::maybe_autocomplete_pages_options(
2878 2878
 					array(
Please login to merge, or discard this patch.
classes/helpers/FrmOnSubmitHelper.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -219,25 +219,25 @@  discard block
 block discarded – undo
219 219
 	public static function populate_on_submit_data( &$form_options, $action = null, $event = 'create' ) {
220 220
 		$opt = 'update' === $event ? 'edit_' : 'success_';
221 221
 		if ( ! $action || ! is_object( $action ) ) {
222
-			$form_options[ $opt . 'action' ] = self::get_default_action_type();
223
-			$form_options[ $opt . 'msg' ]    = self::get_default_msg();
222
+			$form_options[$opt . 'action'] = self::get_default_action_type();
223
+			$form_options[$opt . 'msg']    = self::get_default_msg();
224 224
 
225 225
 			return;
226 226
 		}
227 227
 
228
-		$form_options[ $opt . 'action' ] = isset( $action->post_content['success_action'] ) ? $action->post_content['success_action'] : 'message';
228
+		$form_options[$opt . 'action'] = isset( $action->post_content['success_action'] ) ? $action->post_content['success_action'] : 'message';
229 229
 
230
-		switch ( $form_options[ $opt . 'action' ] ) {
230
+		switch ( $form_options[$opt . 'action'] ) {
231 231
 			case 'redirect':
232
-				$form_options[ $opt . 'url' ] = isset( $action->post_content['success_url'] ) ? $action->post_content['success_url'] : '';
232
+				$form_options[$opt . 'url'] = isset( $action->post_content['success_url'] ) ? $action->post_content['success_url'] : '';
233 233
 				break;
234 234
 
235 235
 			case 'page':
236
-				$form_options[ $opt . 'page_id' ] = isset( $action->post_content['success_page_id'] ) ? $action->post_content['success_page_id'] : '';
236
+				$form_options[$opt . 'page_id'] = isset( $action->post_content['success_page_id'] ) ? $action->post_content['success_page_id'] : '';
237 237
 				break;
238 238
 
239 239
 			default:
240
-				$form_options[ $opt . 'msg' ] = ! empty( $action->post_content['success_msg'] ) ? $action->post_content['success_msg'] : self::get_default_msg();
240
+				$form_options[$opt . 'msg'] = ! empty( $action->post_content['success_msg'] ) ? $action->post_content['success_msg'] : self::get_default_msg();
241 241
 				$form_options['show_form']    = ! empty( $action->post_content['show_form'] );
242 242
 		}
243 243
 	}
@@ -326,20 +326,20 @@  discard block
 block discarded – undo
326 326
 	private static function get_on_submit_action_data_from_form_options( $form_options, $event = 'create' ) {
327 327
 		$opt  = 'update' === $event ? 'edit_' : 'success_';
328 328
 		$data = array(
329
-			'success_action' => isset( $form_options[ $opt . 'action' ] ) ? $form_options[ $opt . 'action' ] : self::get_default_action_type(),
329
+			'success_action' => isset( $form_options[$opt . 'action'] ) ? $form_options[$opt . 'action'] : self::get_default_action_type(),
330 330
 		);
331 331
 
332 332
 		switch ( $data['success_action'] ) {
333 333
 			case 'redirect':
334
-				$data['success_url'] = isset( $form_options[ $opt . 'url' ] ) ? $form_options[ $opt . 'url' ] : '';
334
+				$data['success_url'] = isset( $form_options[$opt . 'url'] ) ? $form_options[$opt . 'url'] : '';
335 335
 				break;
336 336
 
337 337
 			case 'page':
338
-				$data['success_page_id'] = isset( $form_options[ $opt . 'page_id' ] ) ? $form_options[ $opt . 'page_id' ] : '';
338
+				$data['success_page_id'] = isset( $form_options[$opt . 'page_id'] ) ? $form_options[$opt . 'page_id'] : '';
339 339
 				break;
340 340
 
341 341
 			default:
342
-				$data['success_msg'] = isset( $form_options[ $opt . 'msg' ] ) ? $form_options[ $opt . 'msg' ] : self::get_default_msg();
342
+				$data['success_msg'] = isset( $form_options[$opt . 'msg'] ) ? $form_options[$opt . 'msg'] : self::get_default_msg();
343 343
 				$data['show_form']   = ! empty( $form_options['show_form'] );
344 344
 		}
345 345
 
Please login to merge, or discard this patch.