Completed
Push — master ( c8461e...05dfa7 )
by Stephanie
21s queued 10s
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 ) );
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 			$value = $args['temp_value'];
299 299
 		}
300 300
 		if ( empty( $args['parent_field_id'] ) ) {
301
-			$_POST['item_meta'][ $field->id ] = $value;
301
+			$_POST['item_meta'][$field->id] = $value;
302 302
 		} else {
303 303
 			self::set_parent_field_posted_value( $field, $value, $args );
304 304
 		}
@@ -306,29 +306,29 @@  discard block
 block discarded – undo
306 306
 
307 307
 	public static function set_parent_field_posted_value( $field, $value, $args ) {
308 308
 		// init arrays if necessary, else we get fatal error
309
-		if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ] ) && 
310
-			 is_array( $_POST['item_meta'][ $args['parent_field_id'] ] ) ) {
309
+		if ( isset( $_POST['item_meta'][$args['parent_field_id']] ) && 
310
+			 is_array( $_POST['item_meta'][$args['parent_field_id']] ) ) {
311 311
 
312
-			if ( ! isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) ||
313
-				 ! is_array( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) ) {
314
-				$_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] = array();
312
+			if ( ! isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']] ) ||
313
+				 ! is_array( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']] ) ) {
314
+				$_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']] = array();
315 315
 			}
316 316
 		} else {
317 317
 			// All of the section was probably removed.
318
-			$_POST['item_meta'][ $args['parent_field_id'] ] = array();
319
-			$_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] = array();
318
+			$_POST['item_meta'][$args['parent_field_id']] = array();
319
+			$_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']] = array();
320 320
 		}
321 321
 
322
-		$_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
322
+		$_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] = $value;
323 323
 	}
324 324
 
325 325
 	public static function get_posted_value( $field, &$value, $args ) {
326 326
 		$field_id = is_object( $field ) ? $field->id : $field;
327 327
 
328 328
 		if ( empty( $args['parent_field_id'] ) ) {
329
-			$value = isset( $_POST['item_meta'][ $field_id ] ) ? wp_unslash( $_POST['item_meta'][ $field_id ] ) : '';
329
+			$value = isset( $_POST['item_meta'][$field_id] ) ? wp_unslash( $_POST['item_meta'][$field_id] ) : '';
330 330
 		} else {
331
-			$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 ] ) : '';
331
+			$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] ) : '';
332 332
 		}
333 333
 
334 334
 		if ( is_array( $field ) ) {
@@ -359,12 +359,12 @@  discard block
 block discarded – undo
359 359
 		self::set_other_repeating_vals( $field, $value, $args );
360 360
 
361 361
 		// Check if there are any posted "Other" values.
362
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
362
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][$field->id] ) ) {
363 363
 
364 364
 			// Save original value.
365 365
 			$args['temp_value'] = $value;
366 366
 			$args['other']      = true;
367
-			$other_vals         = wp_unslash( $_POST['item_meta']['other'][ $field->id ] );
367
+			$other_vals         = wp_unslash( $_POST['item_meta']['other'][$field->id] );
368 368
 
369 369
 			// Set the validation value now
370 370
 			self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -386,12 +386,12 @@  discard block
 block discarded – undo
386 386
 		}
387 387
 
388 388
 		// Check if there are any other posted "other" values for this field.
389
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
389
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ) ) {
390 390
 			// Save original value
391 391
 			$args['temp_value'] = $value;
392 392
 			$args['other']      = true;
393 393
 
394
-			$other_vals = wp_unslash( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] );
394
+			$other_vals = wp_unslash( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] );
395 395
 
396 396
 			// Set the validation value now.
397 397
 			self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -428,25 +428,25 @@  discard block
 block discarded – undo
428 428
 
429 429
 			// Multi-select dropdown.
430 430
 			if ( is_array( $value ) ) {
431
-				$o_key = array_search( $field->options[ $other_key ], $value );
431
+				$o_key = array_search( $field->options[$other_key], $value );
432 432
 
433 433
 				if ( $o_key !== false ) {
434 434
 					// Modify the original value so other key will be preserved.
435
-					$value[ $other_key ] = $value[ $o_key ];
435
+					$value[$other_key] = $value[$o_key];
436 436
 
437 437
 					// By default, the array keys will be numeric for multi-select dropdowns.
438 438
 					// If going backwards and forwards between pages, the array key will match the other key.
439 439
 					if ( $o_key !== $other_key ) {
440
-						unset( $value[ $o_key ] );
440
+						unset( $value[$o_key] );
441 441
 					}
442 442
 
443 443
 					$args['temp_value']  = $value;
444
-					$value[ $other_key ] = reset( $other_vals );
445
-					if ( FrmAppHelper::is_empty_value( $value[ $other_key ] ) ) {
446
-						unset( $value[ $other_key ] );
444
+					$value[$other_key] = reset( $other_vals );
445
+					if ( FrmAppHelper::is_empty_value( $value[$other_key] ) ) {
446
+						unset( $value[$other_key] );
447 447
 					}
448 448
 				}
449
-			} elseif ( $field->options[ $other_key ] == $value ) {
449
+			} elseif ( $field->options[$other_key] == $value ) {
450 450
 				$value = $other_vals;
451 451
 			}
452 452
 		}
Please login to merge, or discard this patch.