Completed
Pull Request — master (#1004)
by Stephanie
49s
created
classes/controllers/FrmStylesController.php 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -119,7 +119,8 @@
 block discarded – undo
119 119
 	 * @return void
120 120
 	 */
121 121
 	private static function maybe_hook_into_global_settings_save() {
122
-		if ( empty( $_POST ) || ! isset( $_POST['style'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
122
+		if ( empty( $_POST ) || ! isset( $_POST['style'] ) ) {
123
+// phpcs:ignore WordPress.Security.NonceVerification.Missing
123 124
 			// Avoid changing any style data if the style array is not sent in the request.
124 125
 			return;
125 126
 		}
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 		}
652 652
 
653 653
 		parse_str( $query, $parsed_query );
654
-		$form_id      = ! empty( $parsed_query['form'] ) ? absint( $parsed_query['form'] ) : 0;
654
+		$form_id = ! empty( $parsed_query['form'] ) ? absint( $parsed_query['form'] ) : 0;
655 655
 
656 656
 		$style     = new stdClass();
657 657
 		$style->ID = end( $ids );
@@ -689,8 +689,8 @@  discard block
 block discarded – undo
689 689
 
690 690
 		$forms = FrmForm::get_published_forms();
691 691
 		foreach ( $forms as $form ) {
692
-			$new_style      = ( isset( $_POST['style'] ) && isset( $_POST['style'][ $form->id ] ) ) ? sanitize_text_field( wp_unslash( $_POST['style'][ $form->id ] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing
693
-			$previous_style = ( isset( $_POST['prev_style'] ) && isset( $_POST['prev_style'][ $form->id ] ) ) ? sanitize_text_field( wp_unslash( $_POST['prev_style'][ $form->id ] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing
692
+			$new_style      = ( isset( $_POST['style'] ) && isset( $_POST['style'][$form->id] ) ) ? sanitize_text_field( wp_unslash( $_POST['style'][$form->id] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing
693
+			$previous_style = ( isset( $_POST['prev_style'] ) && isset( $_POST['prev_style'][$form->id] ) ) ? sanitize_text_field( wp_unslash( $_POST['prev_style'][$form->id] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing
694 694
 			if ( $new_style == $previous_style ) {
695 695
 				continue;
696 696
 			}
@@ -1064,8 +1064,8 @@  discard block
 block discarded – undo
1064 1064
 	 */
1065 1065
 	public static function get_style_val( $val, $form = 'default' ) {
1066 1066
 		$style = self::get_form_style( $form );
1067
-		if ( $style && isset( $style->post_content[ $val ] ) ) {
1068
-			return $style->post_content[ $val ];
1067
+		if ( $style && isset( $style->post_content[$val] ) ) {
1068
+			return $style->post_content[$val];
1069 1069
 		}
1070 1070
 	}
1071 1071
 
@@ -1084,7 +1084,7 @@  discard block
 block discarded – undo
1084 1084
 			} elseif ( 'alt_bg_color' == $name ) {
1085 1085
 				$setting = 'bg_color_active';
1086 1086
 			}
1087
-			$default_styles[ $name ] = $style->post_content[ $setting ];
1087
+			$default_styles[$name] = $style->post_content[$setting];
1088 1088
 			unset( $name, $val );
1089 1089
 		}
1090 1090
 
Please login to merge, or discard this patch.
classes/models/FrmStyle.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -84,21 +84,21 @@  discard block
 block discarded – undo
84 84
 			$default_settings = $this->get_defaults();
85 85
 
86 86
 			foreach ( $default_settings as $setting => $default ) {
87
-				if ( ! isset( $new_instance['post_content'][ $setting ] ) ) {
88
-					$new_instance['post_content'][ $setting ] = $default;
87
+				if ( ! isset( $new_instance['post_content'][$setting] ) ) {
88
+					$new_instance['post_content'][$setting] = $default;
89 89
 				}
90 90
 
91 91
 				if ( $this->is_color( $setting ) ) {
92
-					$color_val = $new_instance['post_content'][ $setting ];
92
+					$color_val = $new_instance['post_content'][$setting];
93 93
 					if ( $color_val !== '' && 0 === strpos( $color_val, 'rgb' ) ) {
94 94
 						// maybe sanitize if invalid rgba value is entered
95 95
 						$this->maybe_sanitize_rgba_value( $color_val );
96 96
 					}
97
-					$new_instance['post_content'][ $setting ] = str_replace( '#', '', $color_val );
98
-				} elseif ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ), true ) && ! isset( $new_instance['post_content'][ $setting ] ) ) {
99
-					$new_instance['post_content'][ $setting ] = 0;
97
+					$new_instance['post_content'][$setting] = str_replace( '#', '', $color_val );
98
+				} elseif ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ), true ) && ! isset( $new_instance['post_content'][$setting] ) ) {
99
+					$new_instance['post_content'][$setting] = 0;
100 100
 				} elseif ( $setting === 'font' ) {
101
-					$new_instance['post_content'][ $setting ] = $this->force_balanced_quotation( $new_instance['post_content'][ $setting ] );
101
+					$new_instance['post_content'][$setting] = $this->force_balanced_quotation( $new_instance['post_content'][$setting] );
102 102
 				}
103 103
 			}
104 104
 
@@ -211,10 +211,10 @@  discard block
 block discarded – undo
211 211
 		$valid_keys         = array_keys( $defaults );
212 212
 		$sanitized_settings = array();
213 213
 		foreach ( $valid_keys as $key ) {
214
-			if ( isset( $settings[ $key ] ) ) {
215
-				$sanitized_settings[ $key ] = sanitize_textarea_field( $settings[ $key ] );
214
+			if ( isset( $settings[$key] ) ) {
215
+				$sanitized_settings[$key] = sanitize_textarea_field( $settings[$key] );
216 216
 			} else {
217
-				$sanitized_settings[ $key ] = $defaults[ $key ];
217
+				$sanitized_settings[$key] = $defaults[$key];
218 218
 			}
219 219
 		}
220 220
 		return $sanitized_settings;
@@ -381,13 +381,13 @@  discard block
 block discarded – undo
381 381
 			$style->post_content = $this->override_defaults( $style->post_content );
382 382
 			$style->post_content = wp_parse_args( $style->post_content, $default_values );
383 383
 
384
-			$styles[ $style->ID ] = $style;
384
+			$styles[$style->ID] = $style;
385 385
 		}
386 386
 
387 387
 		if ( ! $default_style ) {
388 388
 			$default_style = reset( $styles );
389 389
 
390
-			$styles[ $default_style->ID ]->menu_order = 1;
390
+			$styles[$default_style->ID]->menu_order = 1;
391 391
 		}
392 392
 
393 393
 		return $styles;
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,8 @@
 block discarded – undo
67 67
 			$new_instance = (array) $new_instance;
68 68
 			$this->id     = $new_instance['ID'];
69 69
 
70
-			if ( $id != $this->id || ! $_POST || ! isset( $_POST['frm_style_setting'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
70
+			if ( $id != $this->id || ! $_POST || ! isset( $_POST['frm_style_setting'] ) ) {
71
+// phpcs:ignore WordPress.Security.NonceVerification.Missing
71 72
 				// Don't continue if not saving this style.
72 73
 				continue;
73 74
 			}
Please login to merge, or discard this patch.
classes/helpers/FrmStylesHelper.php 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -285,7 +285,8 @@
 block discarded – undo
285 285
 	public static function get_settings_for_output( $style ) {
286 286
 		if ( self::previewing_style() ) {
287 287
 			$frm_style = new FrmStyle();
288
-			if ( isset( $_POST['frm_style_setting'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
288
+			if ( isset( $_POST['frm_style_setting'] ) ) {
289
+// phpcs:ignore WordPress.Security.NonceVerification.Missing
289 290
 
290 291
 				// Sanitizing is done later.
291 292
 				$posted = wp_unslash( $_POST['frm_style_setting'] ); //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 				'-' => 'down',
136 136
 				'+' => 'up',
137 137
 			);
138
-			$class = 'frm_arrow' . $arrow[ $icon ];
138
+			$class = 'frm_arrow' . $arrow[$icon];
139 139
 		} else {
140 140
 			//frm_minus1_icon
141 141
 			$key   = str_replace( 'p', '', $key );
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 				'-' => 'minus',
144 144
 				'+' => 'plus',
145 145
 			);
146
-			$class = 'frm_' . $plus[ $icon ];
146
+			$class = 'frm_' . $plus[$icon];
147 147
 		}
148 148
 
149 149
 		if ( $key ) {
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
 		?>
170 170
 		<div class="btn-group" id="frm_<?php echo esc_attr( $name ); ?>_select">
171 171
 			<button class="multiselect dropdown-toggle btn btn-default" data-toggle="dropdown" type="button">
172
-				<?php FrmAppHelper::icon_by_class( 'frmfont ' . self::icon_key_to_class( $style->post_content[ $name ], '+', $type ) ); ?>
173
-				<?php FrmAppHelper::icon_by_class( 'frmfont ' . self::icon_key_to_class( $style->post_content[ $name ], '-', $type ) ); ?>
172
+				<?php FrmAppHelper::icon_by_class( 'frmfont ' . self::icon_key_to_class( $style->post_content[$name], '+', $type ) ); ?>
173
+				<?php FrmAppHelper::icon_by_class( 'frmfont ' . self::icon_key_to_class( $style->post_content[$name], '-', $type ) ); ?>
174 174
 				<b class="caret"></b>
175 175
 			</button>
176 176
 			<ul class="multiselect-container frm-dropdown-menu">
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 					<li <?php echo ( $style->post_content['collapse_icon'] == $key ) ? 'class="active"' : ''; ?>>
179 179
 						<a href="javascript:void(0);">
180 180
 							<label>
181
-								<input type="radio" value="<?php echo esc_attr( $key ); ?>" name="<?php echo esc_attr( $frm_style->get_field_name( $name ) ); ?>" <?php checked( $style->post_content[ $name ], $key ); ?> />
181
+								<input type="radio" value="<?php echo esc_attr( $key ); ?>" name="<?php echo esc_attr( $frm_style->get_field_name( $name ) ); ?>" <?php checked( $style->post_content[$name], $key ); ?> />
182 182
 								<span>
183 183
 									<?php
184 184
 									FrmAppHelper::icon_by_class( 'frmfont ' . self::icon_key_to_class( $key, '+', $type ) );
@@ -271,15 +271,15 @@  discard block
 block discarded – undo
271 271
 		$vars   = array_diff( $vars, $remove );
272 272
 
273 273
 		foreach ( $vars as $var ) {
274
-			if ( ! isset( $settings[ $var ] ) ) {
274
+			if ( ! isset( $settings[$var] ) ) {
275 275
 				continue;
276 276
 			}
277
-			if ( ! isset( $defaults[ $var ] ) ) {
278
-				$defaults[ $var ] = '';
277
+			if ( ! isset( $defaults[$var] ) ) {
278
+				$defaults[$var] = '';
279 279
 			}
280
-			$show = empty( $defaults ) || ( $settings[ $var ] !== '' && $settings[ $var ] !== $defaults[ $var ] );
280
+			$show = empty( $defaults ) || ( $settings[$var] !== '' && $settings[$var] !== $defaults[$var] );
281 281
 			if ( $show ) {
282
-				echo '--' . esc_html( str_replace( '_', '-', $var ) ) . ':' . ( $var === 'font' ? FrmAppHelper::kses( $settings[ $var ] ) : esc_html( $settings[ $var ] ) ) . ';'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
282
+				echo '--' . esc_html( str_replace( '_', '-', $var ) ) . ':' . ( $var === 'font' ? FrmAppHelper::kses( $settings[$var] ) : esc_html( $settings[$var] ) ) . ';'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
283 283
 			}
284 284
 		}
285 285
 	}
@@ -328,8 +328,8 @@  discard block
 block discarded – undo
328 328
 
329 329
 		$checkbox_opts = array( 'important_style', 'auto_width', 'submit_style', 'collapse_icon', 'center_form' );
330 330
 		foreach ( $checkbox_opts as $opt ) {
331
-			if ( ! isset( $settings[ $opt ] ) ) {
332
-				$settings[ $opt ] = 0;
331
+			if ( ! isset( $settings[$opt] ) ) {
332
+				$settings[$opt] = 0;
333 333
 			}
334 334
 		}
335 335
 
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 				$css = '';
358 358
 			}
359 359
 			foreach ( $opts as $opt ) {
360
-				self::get_color_output( $css, $settings[ $opt ] );
360
+				self::get_color_output( $css, $settings[$opt] );
361 361
 			}
362 362
 		}
363 363
 	}
Please login to merge, or discard this patch.
classes/helpers/FrmStylesPreviewHelper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -168,7 +168,7 @@
 block discarded – undo
168 168
 			return;
169 169
 		}
170 170
 
171
-		unset( $dependencies[ $index ] );
171
+		unset( $dependencies[$index] );
172 172
 		$dependencies = array_values( $dependencies );
173 173
 
174 174
 		$styles->registered['wp-admin']->deps = $dependencies;
Please login to merge, or discard this patch.
classes/helpers/FrmStylesCardHelper.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -349,12 +349,12 @@
 block discarded – undo
349 349
 		array_walk(
350 350
 			$styles,
351 351
 			/**
352
-			* Echo a style card for a single style in the $styles array.
353
-			*
354
-			* @param WP_Post $style
355
-			* @param int     $count Used for pagination.
356
-			* @return void
357
-			*/
352
+			 * Echo a style card for a single style in the $styles array.
353
+			 *
354
+			 * @param WP_Post $style
355
+			 * @param int     $count Used for pagination.
356
+			 * @return void
357
+			 */
358 358
 			function( $style ) use ( &$count ) {
359 359
 				$hidden = $count > ( self::PAGE_SIZE - 1 );
360 360
 				$this->echo_style_card( $style, $hidden );
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 					),
197 197
 					'/style-templates/' . $style['slug'],
198 198
 				);
199
-				$params['data-requires']    = FrmFormsHelper::get_plan_required( $style );
199
+				$params['data-requires'] = FrmFormsHelper::get_plan_required( $style );
200 200
 				return $params;
201 201
 			};
202 202
 		} else {
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 				continue;
247 247
 			}
248 248
 
249
-			$value = $style->post_content[ $key ];
249
+			$value = $style->post_content[$key];
250 250
 
251 251
 			if ( in_array( $key, $color_settings, true ) && $value && '#' !== $value[0] && false === strpos( $value, 'rgb' ) ) {
252 252
 				$value = '#' . $value;
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 
376 376
 				$hidden = $count > ( self::PAGE_SIZE - 1 );
377 377
 				if ( $this->echo_card_template( $style, $hidden ) ) {
378
-					++$count;
378
+					++ $count;
379 379
 				}
380 380
 			}
381 381
 		);
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 			function( $style ) use ( &$count ) {
403 403
 				$hidden = $count > ( self::PAGE_SIZE - 1 );
404 404
 				$this->echo_style_card( $style, $hidden );
405
-				++$count;
405
+				++ $count;
406 406
 			}
407 407
 		);
408 408
 
Please login to merge, or discard this patch.