Completed
Pull Request — master (#120)
by
unknown
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 ) );
@@ -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,20 +310,20 @@  discard block
 block discarded – undo
310 310
 	 * @since 4.01
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 ) {
@@ -341,9 +341,9 @@  discard block
 block discarded – undo
341 341
 		}
342 342
 
343 343
 		if ( empty( $args['parent_field_id'] ) ) {
344
-			$value = isset( $_POST['item_meta'][ $field_id ] ) ? wp_unslash( $_POST['item_meta'][ $field_id ] ) : '';
344
+			$value = isset( $_POST['item_meta'][$field_id] ) ? wp_unslash( $_POST['item_meta'][$field_id] ) : '';
345 345
 		} else {
346
-			$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 ] ) : '';
346
+			$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] ) : '';
347 347
 		}
348 348
 
349 349
 		$field_obj->sanitize_value( $value );
@@ -375,12 +375,12 @@  discard block
 block discarded – undo
375 375
 		self::set_other_repeating_vals( $field, $value, $args );
376 376
 
377 377
 		// Check if there are any posted "Other" values.
378
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
378
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][$field->id] ) ) {
379 379
 
380 380
 			// Save original value.
381 381
 			$args['temp_value'] = $value;
382 382
 			$args['other']      = true;
383
-			$other_vals         = wp_unslash( $_POST['item_meta']['other'][ $field->id ] );
383
+			$other_vals         = wp_unslash( $_POST['item_meta']['other'][$field->id] );
384 384
 
385 385
 			// Set the validation value now
386 386
 			self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -402,12 +402,12 @@  discard block
 block discarded – undo
402 402
 		}
403 403
 
404 404
 		// Check if there are any other posted "other" values for this field.
405
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
405
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ) ) {
406 406
 			// Save original value
407 407
 			$args['temp_value'] = $value;
408 408
 			$args['other']      = true;
409 409
 
410
-			$other_vals = wp_unslash( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] );
410
+			$other_vals = wp_unslash( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] );
411 411
 
412 412
 			// Set the validation value now.
413 413
 			self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -444,25 +444,25 @@  discard block
 block discarded – undo
444 444
 
445 445
 			// Multi-select dropdown.
446 446
 			if ( is_array( $value ) ) {
447
-				$o_key = array_search( $field->options[ $other_key ], $value );
447
+				$o_key = array_search( $field->options[$other_key], $value );
448 448
 
449 449
 				if ( $o_key !== false ) {
450 450
 					// Modify the original value so other key will be preserved.
451
-					$value[ $other_key ] = $value[ $o_key ];
451
+					$value[$other_key] = $value[$o_key];
452 452
 
453 453
 					// By default, the array keys will be numeric for multi-select dropdowns.
454 454
 					// If going backwards and forwards between pages, the array key will match the other key.
455 455
 					if ( $o_key !== $other_key ) {
456
-						unset( $value[ $o_key ] );
456
+						unset( $value[$o_key] );
457 457
 					}
458 458
 
459 459
 					$args['temp_value']  = $value;
460
-					$value[ $other_key ] = reset( $other_vals );
461
-					if ( FrmAppHelper::is_empty_value( $value[ $other_key ] ) ) {
462
-						unset( $value[ $other_key ] );
460
+					$value[$other_key] = reset( $other_vals );
461
+					if ( FrmAppHelper::is_empty_value( $value[$other_key] ) ) {
462
+						unset( $value[$other_key] );
463 463
 					}
464 464
 				}
465
-			} elseif ( $field->options[ $other_key ] == $value ) {
465
+			} elseif ( $field->options[$other_key] == $value ) {
466 466
 				$value = $other_vals;
467 467
 			}
468 468
 		}
Please login to merge, or discard this patch.