Completed
Push — master ( ff36be...05e347 )
by Stephanie
02:14
created
classes/helpers/FrmEntriesHelper.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
 		if ( $_POST ) {
118 118
 			$repeating = isset( $args['repeating'] ) && $args['repeating'];
119 119
 			if ( $repeating ) {
120
-				if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) {
120
+				if ( isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] ) ) {
121 121
 					$value_is_posted = true;
122 122
 				}
123
-			} elseif ( isset( $_POST['item_meta'][ $field->id ] ) ) {
123
+			} elseif ( isset( $_POST['item_meta'][$field->id] ) ) {
124 124
 				$value_is_posted = true;
125 125
 			}
126 126
 		}
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 		preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER );
151 151
 
152 152
 		foreach ( $shortcodes[0] as $short_key => $tag ) {
153
-			$add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
153
+			$add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][$short_key] );
154 154
 			if ( ! empty( $add_atts ) ) {
155 155
 				$this_atts = array_merge( $atts, $add_atts );
156 156
 			} else {
@@ -160,14 +160,14 @@  discard block
 block discarded – undo
160 160
 			$default = FrmEntriesController::show_entry_shortcode( $this_atts );
161 161
 
162 162
 			// Add the default message.
163
-			$message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
163
+			$message = str_replace( $shortcodes[0][$short_key], $default, $message );
164 164
 		}
165 165
 
166 166
 		return $message;
167 167
 	}
168 168
 
169 169
 	public static function prepare_display_value( $entry, $field, $atts ) {
170
-		$field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
170
+		$field_value = isset( $entry->metas[$field->id] ) ? $entry->metas[$field->id] : false;
171 171
 
172 172
 		if ( FrmAppHelper::pro_is_installed() ) {
173 173
 			FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 			$child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
186 186
 		} else {
187 187
 			// Get all values for this field.
188
-			$child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
188
+			$child_values = isset( $entry->metas[$atts['embedded_field_id']] ) ? $entry->metas[$atts['embedded_field_id']] : false;
189 189
 
190 190
 			if ( $child_values ) {
191 191
 				$child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 			$value = $args['temp_value'];
300 300
 		}
301 301
 		if ( empty( $args['parent_field_id'] ) ) {
302
-			$_POST['item_meta'][ $field->id ] = $value;
302
+			$_POST['item_meta'][$field->id] = $value;
303 303
 		} else {
304 304
 			self::set_parent_field_posted_value( $field, $value, $args );
305 305
 		}
@@ -311,20 +311,20 @@  discard block
 block discarded – undo
311 311
 	 * @since 4.01
312 312
 	 */
313 313
 	private static function set_parent_field_posted_value( $field, $value, $args ) {
314
-		if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ] ) &&
315
-			 is_array( $_POST['item_meta'][ $args['parent_field_id'] ] ) ) {
314
+		if ( isset( $_POST['item_meta'][$args['parent_field_id']] ) &&
315
+			 is_array( $_POST['item_meta'][$args['parent_field_id']] ) ) {
316 316
 
317
-			if ( ! isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) ||
318
-				 ! is_array( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) ) {
319
-				$_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] = array();
317
+			if ( ! isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']] ) ||
318
+				 ! is_array( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']] ) ) {
319
+				$_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']] = array();
320 320
 			}
321 321
 		} else {
322 322
 			// All of the section was probably removed.
323
-			$_POST['item_meta'][ $args['parent_field_id'] ] = array();
324
-			$_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] = array();
323
+			$_POST['item_meta'][$args['parent_field_id']] = array();
324
+			$_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']] = array();
325 325
 		}
326 326
 
327
-		$_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
327
+		$_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] = $value;
328 328
 	}
329 329
 
330 330
 	public static function get_posted_value( $field, &$value, $args ) {
@@ -355,10 +355,10 @@  discard block
 block discarded – undo
355 355
 		if ( empty( $args['parent_field_id'] ) ) {
356 356
 			// Sanitizing is done next.
357 357
 			// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
358
-			$value = isset( $_POST['item_meta'][ $field_id ] ) ? wp_unslash( $_POST['item_meta'][ $field_id ] ) : '';
358
+			$value = isset( $_POST['item_meta'][$field_id] ) ? wp_unslash( $_POST['item_meta'][$field_id] ) : '';
359 359
 		} else {
360 360
 			// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
361
-			$value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? wp_unslash( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) : '';
361
+			$value = isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] ) ? wp_unslash( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] ) : '';
362 362
 		}
363 363
 		return $value;
364 364
 	}
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 		self::set_other_repeating_vals( $field, $value, $args );
390 390
 
391 391
 		// Check if there are any posted "Other" values.
392
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
392
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][$field->id] ) ) {
393 393
 
394 394
 			// Save original value.
395 395
 			$args['temp_value'] = $value;
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 
398 398
 			// Sanitizing is done next.
399 399
 			// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
400
-			$other_vals = wp_unslash( $_POST['item_meta']['other'][ $field->id ] );
400
+			$other_vals = wp_unslash( $_POST['item_meta']['other'][$field->id] );
401 401
 			FrmAppHelper::sanitize_value( 'sanitize_text_field', $other_vals );
402 402
 
403 403
 			// Set the validation value now
@@ -420,13 +420,13 @@  discard block
 block discarded – undo
420 420
 		}
421 421
 
422 422
 		// Check if there are any other posted "other" values for this field.
423
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
423
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ) ) {
424 424
 			// Save original value
425 425
 			$args['temp_value'] = $value;
426 426
 			$args['other']      = true;
427 427
 
428 428
 			// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
429
-			$other_vals = wp_unslash( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] );
429
+			$other_vals = wp_unslash( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] );
430 430
 			FrmAppHelper::sanitize_value( 'sanitize_text_field', $other_vals );
431 431
 
432 432
 			// Set the validation value now.
@@ -464,25 +464,25 @@  discard block
 block discarded – undo
464 464
 
465 465
 			// Multi-select dropdown.
466 466
 			if ( is_array( $value ) ) {
467
-				$o_key = array_search( $field->options[ $other_key ], $value );
467
+				$o_key = array_search( $field->options[$other_key], $value );
468 468
 
469 469
 				if ( $o_key !== false ) {
470 470
 					// Modify the original value so other key will be preserved.
471
-					$value[ $other_key ] = $value[ $o_key ];
471
+					$value[$other_key] = $value[$o_key];
472 472
 
473 473
 					// By default, the array keys will be numeric for multi-select dropdowns.
474 474
 					// If going backwards and forwards between pages, the array key will match the other key.
475 475
 					if ( $o_key !== $other_key ) {
476
-						unset( $value[ $o_key ] );
476
+						unset( $value[$o_key] );
477 477
 					}
478 478
 
479 479
 					$args['temp_value']  = $value;
480
-					$value[ $other_key ] = reset( $other_vals );
481
-					if ( FrmAppHelper::is_empty_value( $value[ $other_key ] ) ) {
482
-						unset( $value[ $other_key ] );
480
+					$value[$other_key] = reset( $other_vals );
481
+					if ( FrmAppHelper::is_empty_value( $value[$other_key] ) ) {
482
+						unset( $value[$other_key] );
483 483
 					}
484 484
 				}
485
-			} elseif ( $field->options[ $other_key ] == $value ) {
485
+			} elseif ( $field->options[$other_key] == $value ) {
486 486
 				$value = $other_vals;
487 487
 			}
488 488
 		}
Please login to merge, or discard this patch.