Completed
Push — master ( dc38fa...e1b5b7 )
by Stephanie
03: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 ) );
@@ -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
 		}
@@ -310,29 +310,29 @@  discard block
 block discarded – undo
310 310
 	 * @since 4.0.05
311 311
 	 */
312 312
 	private static function set_parent_field_posted_value( $field, $value, $args ) {
313
-		if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ] ) &&
314
-			 is_array( $_POST['item_meta'][ $args['parent_field_id'] ] ) ) {
313
+		if ( isset( $_POST['item_meta'][$args['parent_field_id']] ) &&
314
+			 is_array( $_POST['item_meta'][$args['parent_field_id']] ) ) {
315 315
 
316
-			if ( ! isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) ||
317
-				 ! is_array( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) ) {
318
-				$_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] = array();
316
+			if ( ! isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']] ) ||
317
+				 ! is_array( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']] ) ) {
318
+				$_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']] = array();
319 319
 			}
320 320
 		} else {
321 321
 			// All of the section was probably removed.
322
-			$_POST['item_meta'][ $args['parent_field_id'] ] = array();
323
-			$_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] = array();
322
+			$_POST['item_meta'][$args['parent_field_id']] = array();
323
+			$_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']] = array();
324 324
 		}
325 325
 
326
-		$_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
326
+		$_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] = $value;
327 327
 	}
328 328
 
329 329
 	public static function get_posted_value( $field, &$value, $args ) {
330 330
 		$field_id = is_object( $field ) ? $field->id : $field;
331 331
 
332 332
 		if ( empty( $args['parent_field_id'] ) ) {
333
-			$value = isset( $_POST['item_meta'][ $field_id ] ) ? wp_unslash( $_POST['item_meta'][ $field_id ] ) : '';
333
+			$value = isset( $_POST['item_meta'][$field_id] ) ? wp_unslash( $_POST['item_meta'][$field_id] ) : '';
334 334
 		} else {
335
-			$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 ] ) : '';
335
+			$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] ) : '';
336 336
 		}
337 337
 
338 338
 		if ( is_array( $field ) ) {
@@ -363,12 +363,12 @@  discard block
 block discarded – undo
363 363
 		self::set_other_repeating_vals( $field, $value, $args );
364 364
 
365 365
 		// Check if there are any posted "Other" values.
366
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
366
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][$field->id] ) ) {
367 367
 
368 368
 			// Save original value.
369 369
 			$args['temp_value'] = $value;
370 370
 			$args['other']      = true;
371
-			$other_vals         = wp_unslash( $_POST['item_meta']['other'][ $field->id ] );
371
+			$other_vals         = wp_unslash( $_POST['item_meta']['other'][$field->id] );
372 372
 
373 373
 			// Set the validation value now
374 374
 			self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -390,12 +390,12 @@  discard block
 block discarded – undo
390 390
 		}
391 391
 
392 392
 		// Check if there are any other posted "other" values for this field.
393
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
393
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ) ) {
394 394
 			// Save original value
395 395
 			$args['temp_value'] = $value;
396 396
 			$args['other']      = true;
397 397
 
398
-			$other_vals = wp_unslash( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] );
398
+			$other_vals = wp_unslash( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] );
399 399
 
400 400
 			// Set the validation value now.
401 401
 			self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -432,25 +432,25 @@  discard block
 block discarded – undo
432 432
 
433 433
 			// Multi-select dropdown.
434 434
 			if ( is_array( $value ) ) {
435
-				$o_key = array_search( $field->options[ $other_key ], $value );
435
+				$o_key = array_search( $field->options[$other_key], $value );
436 436
 
437 437
 				if ( $o_key !== false ) {
438 438
 					// Modify the original value so other key will be preserved.
439
-					$value[ $other_key ] = $value[ $o_key ];
439
+					$value[$other_key] = $value[$o_key];
440 440
 
441 441
 					// By default, the array keys will be numeric for multi-select dropdowns.
442 442
 					// If going backwards and forwards between pages, the array key will match the other key.
443 443
 					if ( $o_key !== $other_key ) {
444
-						unset( $value[ $o_key ] );
444
+						unset( $value[$o_key] );
445 445
 					}
446 446
 
447 447
 					$args['temp_value']  = $value;
448
-					$value[ $other_key ] = reset( $other_vals );
449
-					if ( FrmAppHelper::is_empty_value( $value[ $other_key ] ) ) {
450
-						unset( $value[ $other_key ] );
448
+					$value[$other_key] = reset( $other_vals );
449
+					if ( FrmAppHelper::is_empty_value( $value[$other_key] ) ) {
450
+						unset( $value[$other_key] );
451 451
 					}
452 452
 				}
453
-			} elseif ( $field->options[ $other_key ] == $value ) {
453
+			} elseif ( $field->options[$other_key] == $value ) {
454 454
 				$value = $other_vals;
455 455
 			}
456 456
 		}
Please login to merge, or discard this patch.