Completed
Push — master ( 423b35...e79207 )
by Md. Mozahidur
02:17
created
includes/acf/api/api-template.php 1 patch
Spacing   +255 added lines, -255 removed lines patch added patch discarded remove patch
@@ -15,13 +15,13 @@  discard block
 block discarded – undo
15 15
 *  @return	$reference (string)	a string containing the field_key
16 16
 */
17 17
 
18
-function acf_get_field_reference( $field_name, $post_id ) {
18
+function acf_get_field_reference($field_name, $post_id) {
19 19
 	
20 20
 	// try cache
21 21
 	$found = false;
22
-	$cache = wp_cache_get( "field_reference/post_id={$post_id}/name={$field_name}", 'acf', false, $found );
22
+	$cache = wp_cache_get("field_reference/post_id={$post_id}/name={$field_name}", 'acf', false, $found);
23 23
 	
24
-	if( $found ) {
24
+	if ($found) {
25 25
 		
26 26
 		return $cache;
27 27
 		
@@ -29,11 +29,11 @@  discard block
 block discarded – undo
29 29
 			
30 30
 	
31 31
 	// get reference
32
-	$reference = acf_get_metadata( $post_id, $field_name, true );
32
+	$reference = acf_get_metadata($post_id, $field_name, true);
33 33
 	
34 34
 	
35 35
 	//update cache
36
-	wp_cache_set( "field_reference/post_id={$post_id}/name={$field_name}", $reference, 'acf' );
36
+	wp_cache_set("field_reference/post_id={$post_id}/name={$field_name}", $reference, 'acf');
37 37
 	
38 38
 	
39 39
 	// return
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
 *  @return	n/a
57 57
 */
58 58
 
59
-function the_field( $selector, $post_id = false, $format_value = true ) {
59
+function the_field($selector, $post_id = false, $format_value = true) {
60 60
 	
61 61
 	$value = get_field($selector, $post_id, $format_value);
62 62
 	
63
-	if( is_array($value) ) {
63
+	if (is_array($value)) {
64 64
 		
65
-		$value = @implode( ', ', $value );
65
+		$value = @implode(', ', $value);
66 66
 		
67 67
 	}
68 68
 	
@@ -88,18 +88,18 @@  discard block
 block discarded – undo
88 88
 *  @return	(mixed)
89 89
 */
90 90
  
91
-function get_field( $selector, $post_id = false, $format_value = true ) {
91
+function get_field($selector, $post_id = false, $format_value = true) {
92 92
 	
93 93
 	// filter post_id
94
-	$post_id = acf_get_valid_post_id( $post_id );
94
+	$post_id = acf_get_valid_post_id($post_id);
95 95
 	
96 96
 	
97 97
 	// get field
98
-	$field = acf_maybe_get_field( $selector, $post_id );
98
+	$field = acf_maybe_get_field($selector, $post_id);
99 99
 	
100 100
 	
101 101
 	// create dummy field
102
-	if( !$field ) {
102
+	if ( ! $field) {
103 103
 		
104 104
 		$field = acf_get_valid_field(array(
105 105
 			'name'	=> $selector,
@@ -115,14 +115,14 @@  discard block
 block discarded – undo
115 115
 	
116 116
 	
117 117
 	// get value for field
118
-	$value = acf_get_value( $post_id, $field );
118
+	$value = acf_get_value($post_id, $field);
119 119
 	
120 120
 	
121 121
 	// format value
122
-	if( $format_value ) {
122
+	if ($format_value) {
123 123
 		
124 124
 		// get value for field
125
-		$value = acf_format_value( $value, $post_id, $field );
125
+		$value = acf_format_value($value, $post_id, $field);
126 126
 		
127 127
 	}
128 128
 	
@@ -149,26 +149,26 @@  discard block
 block discarded – undo
149 149
 *  @return	$field (array)
150 150
 */
151 151
 
152
-function get_field_object( $selector, $post_id = false, $format_value = true, $load_value = true ) {
152
+function get_field_object($selector, $post_id = false, $format_value = true, $load_value = true) {
153 153
 	
154 154
 	// compatibilty
155
-	if( is_array($format_value) ) {
155
+	if (is_array($format_value)) {
156 156
 		
157
-		extract( $format_value );
157
+		extract($format_value);
158 158
 		
159 159
 	}
160 160
 	
161 161
 	
162 162
 	// get valid post_id
163
-	$post_id = acf_get_valid_post_id( $post_id );
163
+	$post_id = acf_get_valid_post_id($post_id);
164 164
 	
165 165
 	
166 166
 	// get field key
167
-	$field = acf_maybe_get_field( $selector, $post_id );
167
+	$field = acf_maybe_get_field($selector, $post_id);
168 168
 	
169 169
 	
170 170
 	// bail early if no field found
171
-	if( !$field ) {
171
+	if ( ! $field) {
172 172
 		
173 173
 		return false;
174 174
 		
@@ -176,18 +176,18 @@  discard block
 block discarded – undo
176 176
 	
177 177
 	
178 178
 	// load value
179
-	if( $load_value ) {
179
+	if ($load_value) {
180 180
 	
181
-		$field['value'] = acf_get_value( $post_id, $field );
181
+		$field['value'] = acf_get_value($post_id, $field);
182 182
 		
183 183
 	}
184 184
 	
185 185
 	
186 186
 	// format value
187
-	if( $format_value ) {
187
+	if ($format_value) {
188 188
 		
189 189
 		// get value for field
190
-		$field['value'] = acf_format_value( $field['value'], $post_id, $field );
190
+		$field['value'] = acf_format_value($field['value'], $post_id, $field);
191 191
 		
192 192
 	}
193 193
 	
@@ -213,19 +213,19 @@  discard block
 block discarded – undo
213 213
 *  @return	(array)	associative array where field name => field value
214 214
 */
215 215
 
216
-function get_fields( $post_id = false, $format_value = true ) {
216
+function get_fields($post_id = false, $format_value = true) {
217 217
 	
218 218
 	// vars
219
-	$fields = get_field_objects( $post_id, $format_value );
219
+	$fields = get_field_objects($post_id, $format_value);
220 220
 	$return = array();
221 221
 	
222 222
 	
223 223
 	// populate
224
-	if( is_array($fields) ) {
224
+	if (is_array($fields)) {
225 225
 		
226
-		foreach( $fields as $k => $field ) {
226
+		foreach ($fields as $k => $field) {
227 227
 		
228
-			$return[ $k ] = $field['value'];
228
+			$return[$k] = $field['value'];
229 229
 			
230 230
 		}
231 231
 		
@@ -253,14 +253,14 @@  discard block
 block discarded – undo
253 253
 *  @return	(array)	associative array where field name => field
254 254
 */
255 255
 
256
-function get_field_objects( $post_id = false, $format_value = true, $load_value = true ) {
256
+function get_field_objects($post_id = false, $format_value = true, $load_value = true) {
257 257
 	
258 258
 	// global
259 259
 	global $wpdb;
260 260
 	
261 261
 	
262 262
 	// filter post_id
263
-	$post_id = acf_get_valid_post_id( $post_id );
263
+	$post_id = acf_get_valid_post_id($post_id);
264 264
 
265 265
 
266 266
 	// vars
@@ -269,35 +269,35 @@  discard block
 block discarded – undo
269 269
 	
270 270
 				
271 271
 	// get field_names
272
-	if( is_numeric($post_id) ) {
272
+	if (is_numeric($post_id)) {
273 273
 		
274
-		$meta = get_post_meta( $post_id );
274
+		$meta = get_post_meta($post_id);
275 275
 	
276
-	} elseif( strpos($post_id, 'user_') !== false ) {
276
+	} elseif (strpos($post_id, 'user_') !== false) {
277 277
 		
278 278
 		$user_id = (int) str_replace('user_', '', $post_id);
279 279
 		
280
-		$meta = get_user_meta( $user_id );
280
+		$meta = get_user_meta($user_id);
281 281
 		
282
-	} elseif( strpos($post_id, 'comment_') !== false ) {
282
+	} elseif (strpos($post_id, 'comment_') !== false) {
283 283
 		
284 284
 		$comment_id = (int) str_replace('comment_', '', $post_id);
285 285
 		
286
-		$meta = get_comment_meta( $comment_id );
286
+		$meta = get_comment_meta($comment_id);
287 287
 		
288 288
 	} else {
289 289
 		
290 290
 		$rows = $wpdb->get_results($wpdb->prepare(
291 291
 			"SELECT option_name, option_value FROM $wpdb->options WHERE option_name LIKE %s OR option_name LIKE %s",
292
-			$post_id . '_%' ,
293
-			'_' . $post_id . '_%' 
292
+			$post_id.'_%',
293
+			'_'.$post_id.'_%' 
294 294
 		), ARRAY_A);
295 295
 		
296
-		if( !empty($rows) ) {
296
+		if ( ! empty($rows)) {
297 297
 			
298
-			foreach( $rows as $row ) {
298
+			foreach ($rows as $row) {
299 299
 				
300
-				$meta[ $row['option_name'] ][] = $row['option_value'];
300
+				$meta[$row['option_name']][] = $row['option_value'];
301 301
 				
302 302
 			}
303 303
 			
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 	
308 308
 	
309 309
 	// bail early if no meta
310
-	if( empty($meta) ) {
310
+	if (empty($meta)) {
311 311
 		
312 312
 		return false;
313 313
 		
@@ -315,10 +315,10 @@  discard block
 block discarded – undo
315 315
 	
316 316
 	
317 317
 	// populate vars
318
-	foreach( $meta as $k => $v ) {
318
+	foreach ($meta as $k => $v) {
319 319
 		
320 320
 		// Hopefuly improve efficiency: bail early if $k does start with an '_'
321
-		if( $k[0] === '_' ) {
321
+		if ($k[0] === '_') {
322 322
 			
323 323
 			continue;
324 324
 			
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 		
327 327
 		
328 328
 		// does a field key exist for this value?
329
-		if( !array_key_exists("_{$k}", $meta) ) {
329
+		if ( ! array_key_exists("_{$k}", $meta)) {
330 330
 			
331 331
 			continue;
332 332
 			
@@ -335,11 +335,11 @@  discard block
 block discarded – undo
335 335
 		
336 336
 		// get field
337 337
 		$field_key = $meta["_{$k}"][0];
338
-		$field = acf_get_field( $field_key );
338
+		$field = acf_get_field($field_key);
339 339
 		
340 340
 		
341 341
 		// bail early if not a parent field
342
-		if( !$field || acf_is_sub_field($field) ) {
342
+		if ( ! $field || acf_is_sub_field($field)) {
343 343
 			
344 344
 			continue;
345 345
 			
@@ -347,30 +347,30 @@  discard block
 block discarded – undo
347 347
 		
348 348
 		
349 349
 		// load value
350
-		if( $load_value ) {
350
+		if ($load_value) {
351 351
 		
352
-			$field['value'] = acf_get_value( $post_id, $field );
352
+			$field['value'] = acf_get_value($post_id, $field);
353 353
 			
354 354
 		}
355 355
 		
356 356
 		
357 357
 		// format value
358
-		if( $format_value ) {
358
+		if ($format_value) {
359 359
 			
360 360
 			// get value for field
361
-			$field['value'] = acf_format_value( $field['value'], $post_id, $field );
361
+			$field['value'] = acf_format_value($field['value'], $post_id, $field);
362 362
 			
363 363
 		}
364 364
 		
365 365
 					
366 366
 		// append to $value
367
-		$fields[ $field['name'] ] = $field;
367
+		$fields[$field['name']] = $field;
368 368
 		
369 369
 	}
370 370
  	
371 371
  	 	
372 372
 	// no value
373
-	if( empty($fields) ) {
373
+	if (empty($fields)) {
374 374
 	
375 375
 		return false;
376 376
 	
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 *  @return	(boolean)
398 398
 */
399 399
 
400
-function have_rows( $selector, $post_id = false ) {
400
+function have_rows($selector, $post_id = false) {
401 401
 	
402 402
 	// vars
403 403
 	$row = array();
@@ -412,14 +412,14 @@  discard block
 block discarded – undo
412 412
 	
413 413
 	
414 414
 	// filter post_id
415
-	$post_id = acf_get_valid_post_id( $post_id );
415
+	$post_id = acf_get_valid_post_id($post_id);
416 416
 	
417 417
 	
418 418
 	// empty?
419
-	if( empty($GLOBALS['acf_field']) ) {
419
+	if (empty($GLOBALS['acf_field'])) {
420 420
 		
421 421
 		// reset
422
-		reset_rows( true );
422
+		reset_rows(true);
423 423
 		
424 424
 		
425 425
 		// create a new loop
@@ -428,17 +428,17 @@  discard block
 block discarded – undo
428 428
 	} else {
429 429
 		
430 430
 		// vars
431
-		$row = end( $GLOBALS['acf_field'] );
432
-		$prev = prev( $GLOBALS['acf_field'] );
431
+		$row = end($GLOBALS['acf_field']);
432
+		$prev = prev($GLOBALS['acf_field']);
433 433
 		$change = false;
434 434
 		
435 435
 		
436 436
 		// detect change
437
-		if( $post_id != $row['post_id'] ) {
437
+		if ($post_id != $row['post_id']) {
438 438
 			
439 439
 			$change = 'post_id';
440 440
 				
441
-		} elseif( $selector != $row['selector'] ) {
441
+		} elseif ($selector != $row['selector']) {
442 442
 			
443 443
 			$change = 'selector';
444 444
 				
@@ -446,13 +446,13 @@  discard block
 block discarded – undo
446 446
 		
447 447
 		
448 448
 		// attempt to find sub field
449
-		if( $change ) {
449
+		if ($change) {
450 450
 			
451 451
 			$sub_field = acf_get_sub_field($selector, $row['field']);
452 452
 			
453
-			if( $sub_field ) {
453
+			if ($sub_field) {
454 454
 				
455
-				$sub_exists = isset($row['value'][ $row['i'] ][ $sub_field['key'] ]);
455
+				$sub_exists = isset($row['value'][$row['i']][$sub_field['key']]);
456 456
 				
457 457
 			}
458 458
 			
@@ -460,15 +460,15 @@  discard block
 block discarded – undo
460 460
 		
461 461
 		
462 462
 		// If post_id has changed, this is most likely an archive loop
463
-		if( $change == 'post_id' ) {
463
+		if ($change == 'post_id') {
464 464
 			
465
-			if( empty($_post_id) && $sub_exists ) {
465
+			if (empty($_post_id) && $sub_exists) {
466 466
 				
467 467
 				// case: Change in $post_id was due to this being a nested loop and not specifying the $post_id
468 468
 				// action: move down one level into a new loop
469 469
 				$new_child_loop = true;
470 470
 			
471
-			} elseif( $prev && $prev['post_id'] == $post_id ) {
471
+			} elseif ($prev && $prev['post_id'] == $post_id) {
472 472
 				
473 473
 				// case: Change in $post_id was due to a nested loop ending
474 474
 				// action: move up one level through the loops
@@ -482,15 +482,15 @@  discard block
 block discarded – undo
482 482
 				
483 483
 			}
484 484
 			
485
-		} elseif( $change == 'selector' ) {
485
+		} elseif ($change == 'selector') {
486 486
 			
487
-			if( $prev && $prev['selector'] == $selector && $prev['post_id'] == $post_id ) {
487
+			if ($prev && $prev['selector'] == $selector && $prev['post_id'] == $post_id) {
488 488
 				
489 489
 				// case: Change in $field_name was due to a nested loop ending
490 490
 				// action: move up one level through the loops
491 491
 				reset_rows();
492 492
 				
493
-			} elseif( $sub_exists ) {
493
+			} elseif ($sub_exists) {
494 494
 				
495 495
 				// case: Change in $field_name was due to this being a nested loop
496 496
 				// action: move down one level into a new loop
@@ -509,11 +509,11 @@  discard block
 block discarded – undo
509 509
 	}
510 510
 	
511 511
 	
512
-	if( $new_parent_loop ) {
512
+	if ($new_parent_loop) {
513 513
 		
514 514
 		// vars
515
-		$field = get_field_object( $selector, $post_id, false );
516
-		$value = acf_extract_var( $field, 'value' );
515
+		$field = get_field_object($selector, $post_id, false);
516
+		$value = acf_extract_var($field, 'value');
517 517
 		
518 518
 		
519 519
 		// add row
@@ -526,14 +526,14 @@  discard block
 block discarded – undo
526 526
 			'post_id'	=> $post_id,
527 527
 		);
528 528
 		
529
-	} elseif( $new_child_loop ) {
529
+	} elseif ($new_child_loop) {
530 530
 		
531 531
 		// vars
532
-		$value = $row['value'][ $row['i'] ][ $sub_field['key'] ];
532
+		$value = $row['value'][$row['i']][$sub_field['key']];
533 533
 		
534 534
 		$GLOBALS['acf_field'][] = array(
535 535
 			'selector'	=> $selector,
536
-			'name'		=> $row['name'] . '_' . $row['i'], // used by update_sub_field
536
+			'name'		=> $row['name'].'_'.$row['i'], // used by update_sub_field
537 537
 			'value'		=> $value,
538 538
 			'field'		=> $sub_field,
539 539
 			'i'			=> -1,
@@ -544,12 +544,12 @@  discard block
 block discarded – undo
544 544
 	
545 545
 	
546 546
 	// update vars
547
-	$row = end( $GLOBALS['acf_field'] );
547
+	$row = end($GLOBALS['acf_field']);
548 548
 	
549 549
 	
550 550
 	
551 551
 	// return true if next row exists
552
-	if( is_array($row['value']) && array_key_exists($row['i']+1, $row['value']) ) {
552
+	if (is_array($row['value']) && array_key_exists($row['i'] + 1, $row['value'])) {
553 553
 		
554 554
 		return true;
555 555
 		
@@ -579,29 +579,29 @@  discard block
 block discarded – undo
579 579
 *  @return	(array) the current row data
580 580
 */
581 581
 
582
-function the_row( $format = false ) {
582
+function the_row($format = false) {
583 583
 	
584 584
 	// vars
585 585
 	$depth = count($GLOBALS['acf_field']) - 1;
586 586
 
587 587
 	
588 588
 	// increase i of current row
589
-	$GLOBALS['acf_field'][ $depth ]['i']++;
589
+	$GLOBALS['acf_field'][$depth]['i']++;
590 590
 	
591 591
 	
592 592
 	// return
593
-	return get_row( $format );
593
+	return get_row($format);
594 594
 	
595 595
 }
596 596
 
597
-function get_row( $format = false ) {
597
+function get_row($format = false) {
598 598
 	
599 599
 	// vars
600 600
 	$row = acf_get_row();
601 601
 	
602 602
 	
603 603
 	// bail early if no row
604
-	if( !$row ) {
604
+	if ( ! $row) {
605 605
 		
606 606
 		return false;
607 607
 		
@@ -609,17 +609,17 @@  discard block
 block discarded – undo
609 609
 	
610 610
 	
611 611
 	// get value
612
-	$value = $row['value'][ $row['i'] ];
612
+	$value = $row['value'][$row['i']];
613 613
 	
614 614
 	
615 615
 	// format
616
-	if( $format ) {
616
+	if ($format) {
617 617
 		
618 618
 		// temp wrap value in array
619
-		$value = array( $value );
619
+		$value = array($value);
620 620
 		
621 621
 		// format the value (1 row of data)
622
-		$value = acf_format_value( $value, $row['post_id'], $row['field'] );
622
+		$value = acf_format_value($value, $row['post_id'], $row['field']);
623 623
 		
624 624
 		// extract value from array
625 625
 		$value = $value[0];
@@ -635,9 +635,9 @@  discard block
 block discarded – undo
635 635
 function acf_get_row() {
636 636
 	
637 637
 	// check and return row
638
-	if( !empty($GLOBALS['acf_field']) ) {
638
+	if ( ! empty($GLOBALS['acf_field'])) {
639 639
 		
640
-		return end( $GLOBALS['acf_field'] );
640
+		return end($GLOBALS['acf_field']);
641 641
 		
642 642
 	}
643 643
 	
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
 	
655 655
 	
656 656
 	// bail early if no row
657
-	if( !$row ) return 0;
657
+	if ( ! $row) return 0;
658 658
 	
659 659
 	
660 660
 	// return
@@ -677,21 +677,21 @@  discard block
 block discarded – undo
677 677
 *  @return	(boolean)
678 678
 */
679 679
 
680
-function reset_rows( $hard_reset = false ) {
680
+function reset_rows($hard_reset = false) {
681 681
 	
682 682
 	// completely destroy?
683
-	if( $hard_reset )
683
+	if ($hard_reset)
684 684
 	{
685 685
 		$GLOBALS['acf_field'] = array();
686 686
 	}
687 687
 	else
688 688
 	{
689 689
 		// vars
690
-		$depth = count( $GLOBALS['acf_field'] ) - 1;
690
+		$depth = count($GLOBALS['acf_field']) - 1;
691 691
 		
692 692
 		
693 693
 		// remove
694
-		unset( $GLOBALS['acf_field'][$depth] );
694
+		unset($GLOBALS['acf_field'][$depth]);
695 695
 		
696 696
 		
697 697
 		// refresh index
@@ -722,14 +722,14 @@  discard block
 block discarded – undo
722 722
 *  @return	(boolean)
723 723
 */
724 724
 
725
-function has_sub_field( $field_name, $post_id = false ) {
725
+function has_sub_field($field_name, $post_id = false) {
726 726
 	
727 727
 	// vars
728
-	$r = have_rows( $field_name, $post_id );
728
+	$r = have_rows($field_name, $post_id);
729 729
 	
730 730
 	
731 731
 	// if has rows, progress through 1 row for the while loop to work
732
-	if( $r ) {
732
+	if ($r) {
733 733
 		
734 734
 		the_row();
735 735
 		
@@ -741,9 +741,9 @@  discard block
 block discarded – undo
741 741
 	
742 742
 }
743 743
 
744
-function has_sub_fields( $field_name, $post_id = false ) {
744
+function has_sub_fields($field_name, $post_id = false) {
745 745
 	
746
-	return has_sub_field( $field_name, $post_id );
746
+	return has_sub_field($field_name, $post_id);
747 747
 	
748 748
 }
749 749
 
@@ -761,14 +761,14 @@  discard block
 block discarded – undo
761 761
 *  @return	(mixed)
762 762
 */
763 763
 
764
-function get_sub_field( $selector, $format_value = true ) {
764
+function get_sub_field($selector, $format_value = true) {
765 765
 	
766 766
 	// vars
767 767
 	$row = acf_get_row();
768 768
 	
769 769
 	
770 770
 	// bail early if no row
771
-	if( !$row ) {
771
+	if ( ! $row) {
772 772
 		
773 773
 		return false;
774 774
 		
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
 	
781 781
 	
782 782
 	// update selector
783
-	if( $sub_field ) {
783
+	if ($sub_field) {
784 784
 		
785 785
 		$selector = $sub_field['key'];
786 786
 		
@@ -792,16 +792,16 @@  discard block
 block discarded – undo
792 792
 	
793 793
 	
794 794
 	// return value
795
-	if( isset($row['value'][ $row['i'] ][ $selector ]) ) {
795
+	if (isset($row['value'][$row['i']][$selector])) {
796 796
 		
797 797
 		// get
798
-		$value = $row['value'][ $row['i'] ][ $selector ];
798
+		$value = $row['value'][$row['i']][$selector];
799 799
 		
800 800
 		
801 801
 		// format
802
-		if( $format_value ) {
802
+		if ($format_value) {
803 803
 			
804
-			$value = acf_format_value( $value, $row['post_id'], $sub_field );
804
+			$value = acf_format_value($value, $row['post_id'], $sub_field);
805 805
 			
806 806
 		}
807 807
 		
@@ -830,13 +830,13 @@  discard block
 block discarded – undo
830 830
 *  @return	n/a
831 831
 */
832 832
 
833
-function the_sub_field( $field_name, $format_value = true ) {
833
+function the_sub_field($field_name, $format_value = true) {
834 834
 	
835
-	$value = get_sub_field( $field_name, $format_value );
835
+	$value = get_sub_field($field_name, $format_value);
836 836
 	
837
-	if( is_array($value) ) {
837
+	if (is_array($value)) {
838 838
 		
839
-		$value = implode(', ',$value);
839
+		$value = implode(', ', $value);
840 840
 		
841 841
 	}
842 842
 	
@@ -857,14 +857,14 @@  discard block
 block discarded – undo
857 857
 *  @return	(array)	
858 858
 */
859 859
 
860
-function get_sub_field_object( $selector, $format_value = true, $load_value = true ) {
860
+function get_sub_field_object($selector, $format_value = true, $load_value = true) {
861 861
 	
862 862
 	// vars
863 863
 	$row = acf_get_row();
864 864
 	
865 865
 	
866 866
 	// bail early if no row
867
-	if( !$row ) {
867
+	if ( ! $row) {
868 868
 		
869 869
 		return false;
870 870
 		
@@ -876,11 +876,11 @@  discard block
 block discarded – undo
876 876
 
877 877
 	
878 878
 	// get sub field
879
-	$sub_field = acf_get_sub_field( $selector, $parent );
879
+	$sub_field = acf_get_sub_field($selector, $parent);
880 880
 	
881 881
 	
882 882
 	// bail early if no sub field
883
-	if( !$sub_field ) {
883
+	if ( ! $sub_field) {
884 884
 		
885 885
 		return false;
886 886
 		
@@ -888,9 +888,9 @@  discard block
 block discarded – undo
888 888
 	
889 889
 	
890 890
 	// load value
891
-	if( $load_value ) {
891
+	if ($load_value) {
892 892
 	
893
-		$sub_field['value'] = get_sub_field( $sub_field['name'], $format_value );
893
+		$sub_field['value'] = get_sub_field($sub_field['name'], $format_value);
894 894
 		
895 895
 	}
896 896
 	
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
 	
922 922
 	
923 923
 	// return
924
-	if( isset($row['acf_fc_layout']) ) {
924
+	if (isset($row['acf_fc_layout'])) {
925 925
 		
926 926
 		return $row['acf_fc_layout'];
927 927
 		
@@ -950,29 +950,29 @@  discard block
 block discarded – undo
950 950
 *  @return	(string)
951 951
 */
952 952
 
953
-function acf_shortcode( $atts )
953
+function acf_shortcode($atts)
954 954
 {
955 955
 	// extract attributs
956
-	extract( shortcode_atts( array(
956
+	extract(shortcode_atts(array(
957 957
 		'field'			=> '',
958 958
 		'post_id'		=> false,
959 959
 		'format_value'	=> true
960
-	), $atts ) );
960
+	), $atts));
961 961
 	
962 962
 	
963 963
 	// get value and return it
964
-	$value = get_field( $field, $post_id, $format_value );
964
+	$value = get_field($field, $post_id, $format_value);
965 965
 	
966 966
 	
967
-	if( is_array($value) )
967
+	if (is_array($value))
968 968
 	{
969
-		$value = @implode( ', ', $value );
969
+		$value = @implode(', ', $value);
970 970
 	}
971 971
 	
972 972
 	
973 973
 	return $value;
974 974
 }
975
-add_shortcode( 'acf', 'acf_shortcode' );
975
+add_shortcode('acf', 'acf_shortcode');
976 976
 
977 977
 
978 978
 /*
@@ -991,10 +991,10 @@  discard block
 block discarded – undo
991 991
 function acf_form_head() {
992 992
 	
993 993
 	// verify nonce
994
-	if( acf_verify_nonce('acf_form') ) {
994
+	if (acf_verify_nonce('acf_form')) {
995 995
 		
996 996
 		// validate data
997
-	    if( acf_validate_save_post(true) ) {
997
+	    if (acf_validate_save_post(true)) {
998 998
 	    	
999 999
 	    	// form
1000 1000
 	    	$GLOBALS['acf_form'] = acf_extract_var($_POST, '_acf_form');
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
 	    	
1003 1003
 	    	
1004 1004
 	    	// validate
1005
-	    	if( empty($GLOBALS['acf_form']) ) {
1005
+	    	if (empty($GLOBALS['acf_form'])) {
1006 1006
 		    	
1007 1007
 		    	return;
1008 1008
 		    	
@@ -1010,7 +1010,7 @@  discard block
 block discarded – undo
1010 1010
 	    	
1011 1011
 	    	
1012 1012
 	    	// vars
1013
-	    	$post_id = acf_maybe_get( $GLOBALS['acf_form'], 'post_id', 0 );
1013
+	    	$post_id = acf_maybe_get($GLOBALS['acf_form'], 'post_id', 0);
1014 1014
 			
1015 1015
 			
1016 1016
 			// allow for custom save
@@ -1018,22 +1018,22 @@  discard block
 block discarded – undo
1018 1018
 			
1019 1019
 			
1020 1020
 			// save
1021
-			acf_save_post( $post_id );
1021
+			acf_save_post($post_id);
1022 1022
 			
1023 1023
 			
1024 1024
 			// vars
1025
-			$return = acf_maybe_get( $GLOBALS['acf_form'], 'return', '' );
1025
+			$return = acf_maybe_get($GLOBALS['acf_form'], 'return', '');
1026 1026
 			
1027 1027
 			
1028 1028
 			// redirect
1029
-			if( $return ) {
1029
+			if ($return) {
1030 1030
 				
1031 1031
 				// update %placeholders%
1032 1032
 				$return = str_replace('%post_url%', get_permalink($post_id), $return);
1033 1033
 				
1034 1034
 				
1035 1035
 				// redirect
1036
-				wp_redirect( $return );
1036
+				wp_redirect($return);
1037 1037
 				exit;
1038 1038
 			}
1039 1039
 			
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
 function _validate_save_post() {
1069 1069
 	
1070 1070
 	// save post_title
1071
-	if( isset($_POST['acf']['_post_title']) ) {
1071
+	if (isset($_POST['acf']['_post_title'])) {
1072 1072
 		
1073 1073
 		// get field
1074 1074
 		$field = acf_get_valid_field(array(
@@ -1080,7 +1080,7 @@  discard block
 block discarded – undo
1080 1080
 		
1081 1081
 		
1082 1082
 		// validate
1083
-		acf_validate_value( $_POST['acf']['_post_title'], $field, "acf[_post_title]" );
1083
+		acf_validate_value($_POST['acf']['_post_title'], $field, "acf[_post_title]");
1084 1084
 	
1085 1085
 	}
1086 1086
 	
@@ -1102,7 +1102,7 @@  discard block
 block discarded – undo
1102 1102
 
1103 1103
 add_filter('acf/pre_save_post', '_acf_pre_save_post', 0, 2);
1104 1104
 
1105
-function _acf_pre_save_post( $post_id, $form ) {
1105
+function _acf_pre_save_post($post_id, $form) {
1106 1106
 	
1107 1107
 	// vars
1108 1108
 	$save = array(
@@ -1111,15 +1111,15 @@  discard block
 block discarded – undo
1111 1111
 	
1112 1112
 	
1113 1113
 	// determine save data
1114
-	if( is_numeric($post_id) ) {
1114
+	if (is_numeric($post_id)) {
1115 1115
 		
1116 1116
 		// update post
1117 1117
 		$save['ID'] = $post_id;
1118 1118
 		
1119
-	} elseif( $post_id == 'new_post' ) {
1119
+	} elseif ($post_id == 'new_post') {
1120 1120
 		
1121 1121
 		// new post
1122
-		$form['new_post'] = acf_parse_args( $form['new_post'], array(
1122
+		$form['new_post'] = acf_parse_args($form['new_post'], array(
1123 1123
 			'post_type' 	=> 'post',
1124 1124
 			'post_status'	=> 'draft',
1125 1125
 		));
@@ -1137,7 +1137,7 @@  discard block
 block discarded – undo
1137 1137
 	
1138 1138
 	
1139 1139
 	// save post_title
1140
-	if( isset($_POST['acf']['_post_title']) ) {
1140
+	if (isset($_POST['acf']['_post_title'])) {
1141 1141
 		
1142 1142
 		$save['post_title'] = acf_extract_var($_POST['acf'], '_post_title');
1143 1143
 	
@@ -1145,7 +1145,7 @@  discard block
 block discarded – undo
1145 1145
 	
1146 1146
 	
1147 1147
 	// save post_content
1148
-	if( isset($_POST['acf']['_post_content']) ) {
1148
+	if (isset($_POST['acf']['_post_content'])) {
1149 1149
 		
1150 1150
 		$save['post_content'] = acf_extract_var($_POST['acf'], '_post_content');
1151 1151
 		
@@ -1153,20 +1153,20 @@  discard block
 block discarded – undo
1153 1153
 	
1154 1154
 	
1155 1155
 	// validate
1156
-	if( count($save) == 1 ) {
1156
+	if (count($save) == 1) {
1157 1157
 		
1158 1158
 		return $post_id;
1159 1159
 		
1160 1160
 	}
1161 1161
 	
1162 1162
 	
1163
-	if( $save['ID'] ) {
1163
+	if ($save['ID']) {
1164 1164
 		
1165
-		wp_update_post( $save );
1165
+		wp_update_post($save);
1166 1166
 		
1167 1167
 	} else {
1168 1168
 		
1169
-		$post_id = wp_insert_post( $save );
1169
+		$post_id = wp_insert_post($save);
1170 1170
 		
1171 1171
 	}
1172 1172
 		
@@ -1201,14 +1201,14 @@  discard block
 block discarded – undo
1201 1201
 *  @return	N/A
1202 1202
 */
1203 1203
 
1204
-function acf_form( $args = array() ) {
1204
+function acf_form($args = array()) {
1205 1205
 	
1206 1206
 	// vars
1207 1207
 	$url = acf_get_current_url();
1208 1208
 	
1209 1209
 	
1210 1210
 	// defaults
1211
-	$args = wp_parse_args( $args, array(
1211
+	$args = wp_parse_args($args, array(
1212 1212
 		'id'					=> 'acf-form',
1213 1213
 		'post_id'				=> false,
1214 1214
 		'new_post'				=> false,
@@ -1218,7 +1218,7 @@  discard block
 block discarded – undo
1218 1218
 		'post_content'			=> false,
1219 1219
 		'form'					=> true,
1220 1220
 		'form_attributes'		=> array(),
1221
-		'return'				=> add_query_arg( 'updated', 'true', $url ),
1221
+		'return'				=> add_query_arg('updated', 'true', $url),
1222 1222
 		'html_before_fields'	=> '',
1223 1223
 		'html_after_fields'		=> '',
1224 1224
 		'submit_value'			=> __("Update", 'acf'),
@@ -1229,7 +1229,7 @@  discard block
 block discarded – undo
1229 1229
 		'uploader'				=> 'wp'
1230 1230
 	));
1231 1231
 	
1232
-	$args['form_attributes'] = wp_parse_args( $args['form_attributes'], array(
1232
+	$args['form_attributes'] = wp_parse_args($args['form_attributes'], array(
1233 1233
 		'id'					=> 'post',
1234 1234
 		'class'					=> '',
1235 1235
 		'action'				=> '',
@@ -1238,7 +1238,7 @@  discard block
 block discarded – undo
1238 1238
 	
1239 1239
 	
1240 1240
 	// filter post_id
1241
-	$args['post_id'] = acf_get_valid_post_id( $args['post_id'] );
1241
+	$args['post_id'] = acf_get_valid_post_id($args['post_id']);
1242 1242
 	
1243 1243
 	
1244 1244
 	// load values from this post
@@ -1246,14 +1246,14 @@  discard block
 block discarded – undo
1246 1246
 	
1247 1247
 	
1248 1248
 	// new post?
1249
-	if( $post_id == 'new_post' ) {
1249
+	if ($post_id == 'new_post') {
1250 1250
 		
1251 1251
 		// dont load values
1252 1252
 		$post_id = false;
1253 1253
 		
1254 1254
 		
1255 1255
 		// new post defaults
1256
-		$args['new_post'] = acf_parse_args( $args['new_post'], array(
1256
+		$args['new_post'] = acf_parse_args($args['new_post'], array(
1257 1257
 			'post_type' 	=> 'post',
1258 1258
 			'post_status'	=> 'draft',
1259 1259
 		));
@@ -1271,7 +1271,7 @@  discard block
 block discarded – undo
1271 1271
 	
1272 1272
 	
1273 1273
 	// post_title
1274
-	if( $args['post_title'] ) {
1274
+	if ($args['post_title']) {
1275 1275
 		
1276 1276
 		$fields[] = acf_get_valid_field(array(
1277 1277
 			'name'		=> '_post_title',
@@ -1285,7 +1285,7 @@  discard block
 block discarded – undo
1285 1285
 	
1286 1286
 	
1287 1287
 	// post_content
1288
-	if( $args['post_content'] ) {
1288
+	if ($args['post_content']) {
1289 1289
 		
1290 1290
 		$fields[] = acf_get_valid_field(array(
1291 1291
 			'name'		=> '_post_content',
@@ -1298,24 +1298,24 @@  discard block
 block discarded – undo
1298 1298
 	
1299 1299
 	
1300 1300
 	// specific fields
1301
-	if( $args['fields'] ) {
1301
+	if ($args['fields']) {
1302 1302
 		
1303
-		foreach( $args['fields'] as $selector ) {
1303
+		foreach ($args['fields'] as $selector) {
1304 1304
 			
1305 1305
 			// append field ($strict = false to allow for better compatibility with field names)
1306
-			$fields[] = acf_maybe_get_field( $selector, $post_id, false );
1306
+			$fields[] = acf_maybe_get_field($selector, $post_id, false);
1307 1307
 			
1308 1308
 		}
1309 1309
 		
1310
-	} elseif( $args['field_groups'] ) {
1310
+	} elseif ($args['field_groups']) {
1311 1311
 		
1312
-		foreach( $args['field_groups'] as $selector ) {
1312
+		foreach ($args['field_groups'] as $selector) {
1313 1313
 		
1314
-			$field_groups[] = acf_get_field_group( $selector );
1314
+			$field_groups[] = acf_get_field_group($selector);
1315 1315
 			
1316 1316
 		}
1317 1317
 		
1318
-	} elseif( $args['post_id'] == 'new_post' ) {
1318
+	} elseif ($args['post_id'] == 'new_post') {
1319 1319
 		
1320 1320
 		$field_groups = acf_get_field_groups(array(
1321 1321
 			'post_type' => $args['new_post']['post_type']
@@ -1331,15 +1331,15 @@  discard block
 block discarded – undo
1331 1331
 	
1332 1332
 	
1333 1333
 	//load fields based on field groups
1334
-	if( !empty($field_groups) ) {
1334
+	if ( ! empty($field_groups)) {
1335 1335
 		
1336
-		foreach( $field_groups as $field_group ) {
1336
+		foreach ($field_groups as $field_group) {
1337 1337
 			
1338
-			$field_group_fields = acf_get_fields( $field_group );
1338
+			$field_group_fields = acf_get_fields($field_group);
1339 1339
 			
1340
-			if( !empty($field_group_fields) ) {
1340
+			if ( ! empty($field_group_fields)) {
1341 1341
 				
1342
-				foreach( array_keys($field_group_fields) as $i ) {
1342
+				foreach (array_keys($field_group_fields) as $i) {
1343 1343
 					
1344 1344
 					$fields[] = acf_extract_var($field_group_fields, $i);
1345 1345
 				}
@@ -1352,9 +1352,9 @@  discard block
 block discarded – undo
1352 1352
 	
1353 1353
 	
1354 1354
 	// updated message
1355
-	if( !empty($_GET['updated']) && $args['updated_message'] ) {
1355
+	if ( ! empty($_GET['updated']) && $args['updated_message']) {
1356 1356
 	
1357
-		echo '<div id="message" class="updated"><p>' . $args['updated_message'] . '</p></div>';
1357
+		echo '<div id="message" class="updated"><p>'.$args['updated_message'].'</p></div>';
1358 1358
 		
1359 1359
 	}
1360 1360
 	
@@ -1364,9 +1364,9 @@  discard block
 block discarded – undo
1364 1364
 	
1365 1365
 	
1366 1366
 	// display form
1367
-	if( $args['form'] ): ?>
1367
+	if ($args['form']): ?>
1368 1368
 	
1369
-	<form <?php acf_esc_attr_e( $args['form_attributes']); ?>>
1369
+	<form <?php acf_esc_attr_e($args['form_attributes']); ?>>
1370 1370
 	
1371 1371
 	<?php endif; 
1372 1372
 		
@@ -1379,7 +1379,7 @@  discard block
 block discarded – undo
1379 1379
 	
1380 1380
 	?>
1381 1381
 	<div class="acf-hidden">
1382
-		<?php acf_hidden_input(array( 'name' => '_acf_form', 'value' => base64_encode(json_encode($args)) )); ?>
1382
+		<?php acf_hidden_input(array('name' => '_acf_form', 'value' => base64_encode(json_encode($args)))); ?>
1383 1383
 	</div>
1384 1384
 	<div class="acf-fields acf-form-fields -<?php echo $args['label_placement']; ?>">
1385 1385
 	
@@ -1390,7 +1390,7 @@  discard block
 block discarded – undo
1390 1390
 		
1391 1391
 		
1392 1392
 		// render
1393
-		acf_render_fields( $post_id, $fields, $args['field_el'], $args['instruction_placement'] );
1393
+		acf_render_fields($post_id, $fields, $args['field_el'], $args['instruction_placement']);
1394 1394
 		
1395 1395
 		
1396 1396
 		// html after fields
@@ -1399,7 +1399,7 @@  discard block
 block discarded – undo
1399 1399
 		?>
1400 1400
 	
1401 1401
 	</div><!-- acf-form-fields -->
1402
-	<?php if( $args['form'] ): ?>
1402
+	<?php if ($args['form']): ?>
1403 1403
 	
1404 1404
 	<!-- Submit -->
1405 1405
 	<div class="acf-form-submit">
@@ -1430,18 +1430,18 @@  discard block
 block discarded – undo
1430 1430
 *  @return	(boolean)
1431 1431
 */
1432 1432
 
1433
-function update_field( $selector, $value, $post_id = false ) {
1433
+function update_field($selector, $value, $post_id = false) {
1434 1434
 	
1435 1435
 	// filter post_id
1436
-	$post_id = acf_get_valid_post_id( $post_id );
1436
+	$post_id = acf_get_valid_post_id($post_id);
1437 1437
 	
1438 1438
 	
1439 1439
 	// get field
1440
-	$field = acf_maybe_get_field( $selector, $post_id );
1440
+	$field = acf_maybe_get_field($selector, $post_id);
1441 1441
 	
1442 1442
 	
1443 1443
 	// create dummy field
1444
-	if( !$field )
1444
+	if ( ! $field)
1445 1445
 	{
1446 1446
 		$field = acf_get_valid_field(array(
1447 1447
 			'name'	=> $selector,
@@ -1452,7 +1452,7 @@  discard block
 block discarded – undo
1452 1452
 	
1453 1453
 	
1454 1454
 	// save
1455
-	return acf_update_value( $value, $post_id, $field );
1455
+	return acf_update_value($value, $post_id, $field);
1456 1456
 		
1457 1457
 }
1458 1458
 
@@ -1472,10 +1472,10 @@  discard block
 block discarded – undo
1472 1472
 *  @return	(boolean)
1473 1473
 */
1474 1474
 
1475
-function update_sub_field( $selector, $value, $post_id = false ) {
1475
+function update_sub_field($selector, $value, $post_id = false) {
1476 1476
 	
1477 1477
 	// filter post_id
1478
-	$post_id = acf_get_valid_post_id( $post_id );
1478
+	$post_id = acf_get_valid_post_id($post_id);
1479 1479
 	
1480 1480
 	
1481 1481
 	// vars
@@ -1483,7 +1483,7 @@  discard block
 block discarded – undo
1483 1483
 	
1484 1484
 	
1485 1485
 	// within a have_rows loop
1486
-	if( is_string($selector) ) {
1486
+	if (is_string($selector)) {
1487 1487
 		
1488 1488
 		// get current row
1489 1489
 		$row = acf_get_row();
@@ -1494,11 +1494,11 @@  discard block
 block discarded – undo
1494 1494
 		
1495 1495
 		
1496 1496
 		// get sub field
1497
-		$field = get_sub_field_object( $selector, false, false );
1497
+		$field = get_sub_field_object($selector, false, false);
1498 1498
 		
1499 1499
 		
1500 1500
 		// create dummy field
1501
-		if( !$field ) {
1501
+		if ( ! $field) {
1502 1502
 		
1503 1503
 			$field = acf_get_valid_field(array(
1504 1504
 				'name'	=> $selector,
@@ -1513,10 +1513,10 @@  discard block
 block discarded – undo
1513 1513
 		$field['name'] = "{$row['name']}_{$row['i']}_{$field['name']}";
1514 1514
 		
1515 1515
 		
1516
-	} elseif( is_array($selector) ) {
1516
+	} elseif (is_array($selector)) {
1517 1517
 		
1518 1518
 		// validate
1519
-		if( count($selector) < 3 ) {
1519
+		if (count($selector) < 3) {
1520 1520
 			
1521 1521
 			return false;
1522 1522
 			
@@ -1524,11 +1524,11 @@  discard block
 block discarded – undo
1524 1524
 		
1525 1525
 		
1526 1526
 		// vars
1527
-		$parent_name = acf_extract_var( $selector, 0 );
1527
+		$parent_name = acf_extract_var($selector, 0);
1528 1528
 		
1529 1529
 		
1530 1530
 		// load parent
1531
-		$field = acf_maybe_get_field( $parent_name, $post_id );
1531
+		$field = acf_maybe_get_field($parent_name, $post_id);
1532 1532
 		
1533 1533
 		
1534 1534
 		// add to name
@@ -1536,9 +1536,9 @@  discard block
 block discarded – undo
1536 1536
 		
1537 1537
 		
1538 1538
 		// sub fields
1539
-		foreach( $selector as $s ) {
1539
+		foreach ($selector as $s) {
1540 1540
 				
1541
-			if( is_numeric($s) ) {
1541
+			if (is_numeric($s)) {
1542 1542
 				
1543 1543
 				// get row index
1544 1544
 				$row_i = intval($s) - 1;
@@ -1549,11 +1549,11 @@  discard block
 block discarded – undo
1549 1549
 			} else {
1550 1550
 				
1551 1551
 				// update parent
1552
-				$field = acf_get_sub_field( $s, $field );
1552
+				$field = acf_get_sub_field($s, $field);
1553 1553
 				
1554 1554
 				
1555 1555
 				// create dummy field
1556
-				if( !$field ) {
1556
+				if ( ! $field) {
1557 1557
 				
1558 1558
 					$field = acf_get_valid_field(array(
1559 1559
 						'name'	=> $s,
@@ -1582,15 +1582,15 @@  discard block
 block discarded – undo
1582 1582
 	
1583 1583
 	
1584 1584
 	// delete
1585
-	if( $value === null ) {
1585
+	if ($value === null) {
1586 1586
 		
1587
-		return acf_delete_value( $post_id, $field );
1587
+		return acf_delete_value($post_id, $field);
1588 1588
 		
1589 1589
 	}
1590 1590
 	
1591 1591
 	
1592 1592
 	// update
1593
-	return acf_update_value( $value, $post_id, $field );
1593
+	return acf_update_value($value, $post_id, $field);
1594 1594
 		
1595 1595
 }
1596 1596
 
@@ -1609,18 +1609,18 @@  discard block
 block discarded – undo
1609 1609
 *  @return	(boolean)
1610 1610
 */
1611 1611
 
1612
-function delete_field( $selector, $post_id = false ) {
1612
+function delete_field($selector, $post_id = false) {
1613 1613
 	
1614 1614
 	// filter post_id
1615
-	$post_id = acf_get_valid_post_id( $post_id );
1615
+	$post_id = acf_get_valid_post_id($post_id);
1616 1616
 	
1617 1617
 	
1618 1618
 	// get field
1619
-	$field = acf_maybe_get_field( $selector, $post_id );
1619
+	$field = acf_maybe_get_field($selector, $post_id);
1620 1620
 	
1621 1621
 	
1622 1622
 	// delete
1623
-	return acf_delete_value( $post_id, $field );
1623
+	return acf_delete_value($post_id, $field);
1624 1624
 	
1625 1625
 }
1626 1626
 
@@ -1640,9 +1640,9 @@  discard block
 block discarded – undo
1640 1640
 *  @return	(boolean)
1641 1641
 */
1642 1642
 
1643
-function delete_sub_field( $selector, $post_id = false ) {
1643
+function delete_sub_field($selector, $post_id = false) {
1644 1644
 	
1645
-	return update_sub_field( $selector, null, $post_id );
1645
+	return update_sub_field($selector, null, $post_id);
1646 1646
 		
1647 1647
 }
1648 1648
 
@@ -1660,18 +1660,18 @@  discard block
 block discarded – undo
1660 1660
 *  @return	$post_id (int)
1661 1661
 */
1662 1662
 
1663
-function add_row( $selector, $value, $post_id = false ) {
1663
+function add_row($selector, $value, $post_id = false) {
1664 1664
 	
1665 1665
 	// filter post_id
1666
-	$post_id = acf_get_valid_post_id( $post_id );
1666
+	$post_id = acf_get_valid_post_id($post_id);
1667 1667
 	
1668 1668
 	
1669 1669
 	// get field
1670
-	$field = acf_maybe_get_field( $selector, $post_id );
1670
+	$field = acf_maybe_get_field($selector, $post_id);
1671 1671
 	
1672 1672
 	
1673 1673
 	// bail early if no field
1674
-	if( !$field ) {
1674
+	if ( ! $field) {
1675 1675
 		
1676 1676
 		return false;
1677 1677
 		
@@ -1679,14 +1679,14 @@  discard block
 block discarded – undo
1679 1679
 	
1680 1680
 	
1681 1681
 	// get row count
1682
-	$i = (int) acf_get_metadata( $post_id, $field['name'] );
1682
+	$i = (int) acf_get_metadata($post_id, $field['name']);
1683 1683
 	
1684 1684
 	
1685 1685
 	// if no rows, save this field via update_field() so that the reference field is created
1686
-	if( !$i ) {
1686
+	if ( ! $i) {
1687 1687
 		
1688 1688
 		// acf_update_value will return boolean, simply convert this to int for 1 | 0 (the number of rows!)
1689
-		return (int) acf_update_value( array( $value ), $post_id, $field );
1689
+		return (int) acf_update_value(array($value), $post_id, $field);
1690 1690
 		
1691 1691
 	}
1692 1692
 	
@@ -1696,15 +1696,15 @@  discard block
 block discarded – undo
1696 1696
 	
1697 1697
 	
1698 1698
 	// update meta
1699
-	$result = acf_update_metadata( $post_id, $field['name'], $i );
1699
+	$result = acf_update_metadata($post_id, $field['name'], $i);
1700 1700
 	
1701 1701
 	
1702 1702
 	// update sub fields
1703
-	if( $value ) {
1703
+	if ($value) {
1704 1704
 		
1705
-		foreach( $value as $k => $v ) {
1705
+		foreach ($value as $k => $v) {
1706 1706
 		
1707
-			update_sub_field( array( $field['key'], $i, $k ), $v, $post_id );
1707
+			update_sub_field(array($field['key'], $i, $k), $v, $post_id);
1708 1708
 			
1709 1709
 		}
1710 1710
 	
@@ -1730,10 +1730,10 @@  discard block
 block discarded – undo
1730 1730
 *  @return	$post_id (int)
1731 1731
 */
1732 1732
 
1733
-function update_row( $selector, $row = 1, $value = false, $post_id = false ) {
1733
+function update_row($selector, $row = 1, $value = false, $post_id = false) {
1734 1734
 	
1735 1735
 	// bail early if no value
1736
-	if( empty($value) ) {
1736
+	if (empty($value)) {
1737 1737
 		
1738 1738
 		return false;
1739 1739
 		
@@ -1741,21 +1741,21 @@  discard block
 block discarded – undo
1741 1741
 	
1742 1742
 	
1743 1743
 	// filter post_id
1744
-	$post_id = acf_get_valid_post_id( $post_id );
1744
+	$post_id = acf_get_valid_post_id($post_id);
1745 1745
 	
1746 1746
 	
1747 1747
 	// get field
1748
-	$field = acf_maybe_get_field( $selector, $post_id );
1748
+	$field = acf_maybe_get_field($selector, $post_id);
1749 1749
 	
1750 1750
 	
1751 1751
 	// bail early if no field
1752
-	if( !$field ) return false;
1752
+	if ( ! $field) return false;
1753 1753
 	
1754 1754
 	
1755 1755
 	// update sub fields
1756
-	foreach( $value as $k => $v ) {
1756
+	foreach ($value as $k => $v) {
1757 1757
 		
1758
-		update_sub_field( array( $field['key'], $row, $k ), $v, $post_id );
1758
+		update_sub_field(array($field['key'], $row, $k), $v, $post_id);
1759 1759
 		
1760 1760
 	}
1761 1761
 	
@@ -1779,18 +1779,18 @@  discard block
 block discarded – undo
1779 1779
 *  @return	$post_id (int)
1780 1780
 */
1781 1781
 
1782
-function delete_row( $selector, $row = 1, $post_id = false ) {
1782
+function delete_row($selector, $row = 1, $post_id = false) {
1783 1783
 	
1784 1784
 	// filter post_id
1785
-	$post_id = acf_get_valid_post_id( $post_id );
1785
+	$post_id = acf_get_valid_post_id($post_id);
1786 1786
 	
1787 1787
 	
1788 1788
 	// get field
1789
-	$field = acf_maybe_get_field( $selector, $post_id );
1789
+	$field = acf_maybe_get_field($selector, $post_id);
1790 1790
 	
1791 1791
 	
1792 1792
 	// bail early if no field
1793
-	if( !$field ) {
1793
+	if ( ! $field) {
1794 1794
 		
1795 1795
 		return false;
1796 1796
 		
@@ -1798,11 +1798,11 @@  discard block
 block discarded – undo
1798 1798
 	
1799 1799
 	
1800 1800
 	// get value
1801
-	$rows = acf_get_value( $post_id, $field );
1801
+	$rows = acf_get_value($post_id, $field);
1802 1802
 	
1803 1803
 	
1804 1804
 	// bail early if no value
1805
-	if( empty($rows) ) {
1805
+	if (empty($rows)) {
1806 1806
 		
1807 1807
 		return false;
1808 1808
 		
@@ -1810,17 +1810,17 @@  discard block
 block discarded – undo
1810 1810
 	
1811 1811
 	
1812 1812
 	// deincrement
1813
-	if( $row = count($rows) ) {
1813
+	if ($row = count($rows)) {
1814 1814
 		
1815
-		acf_update_metadata( $post_id, $field['name'], $row-1 );
1815
+		acf_update_metadata($post_id, $field['name'], $row - 1);
1816 1816
 		
1817 1817
 	}
1818 1818
 	
1819 1819
 	
1820 1820
 	// update sub field values
1821
-	foreach( $rows[0] as $k => $v ) {
1821
+	foreach ($rows[0] as $k => $v) {
1822 1822
 		
1823
-		update_sub_field( array( $field['key'], $row, $k ), null, $post_id );
1823
+		update_sub_field(array($field['key'], $row, $k), null, $post_id);
1824 1824
 		
1825 1825
 	}
1826 1826
 	
@@ -1845,14 +1845,14 @@  discard block
 block discarded – undo
1845 1845
 *  @return	N/A
1846 1846
 */
1847 1847
 
1848
-function create_field( $field ) {
1848
+function create_field($field) {
1849 1849
 
1850
-	acf_render_field( $field );
1850
+	acf_render_field($field);
1851 1851
 }
1852 1852
 
1853
-function render_field( $field ) {
1853
+function render_field($field) {
1854 1854
 
1855
-	acf_render_field( $field );
1855
+	acf_render_field($field);
1856 1856
 }
1857 1857
 
1858 1858
 
@@ -1871,10 +1871,10 @@  discard block
 block discarded – undo
1871 1871
 *  @return	N/A
1872 1872
 */
1873 1873
 
1874
-function acf_convert_field_names_to_keys( $value, $field ) {
1874
+function acf_convert_field_names_to_keys($value, $field) {
1875 1875
 	
1876 1876
 	// only if $field has sub fields
1877
-	if( !isset($field['sub_fields']) ) {
1877
+	if ( ! isset($field['sub_fields'])) {
1878 1878
 		
1879 1879
 		return $value;
1880 1880
 		
@@ -1883,11 +1883,11 @@  discard block
 block discarded – undo
1883 1883
 
1884 1884
 	// define sub field keys
1885 1885
 	$sub_fields = array();
1886
-	if( $field['sub_fields'] ) {
1886
+	if ($field['sub_fields']) {
1887 1887
 		
1888
-		foreach( $field['sub_fields'] as $sub_field ) {
1888
+		foreach ($field['sub_fields'] as $sub_field) {
1889 1889
 			
1890
-			$sub_fields[ $sub_field['name'] ] = $sub_field;
1890
+			$sub_fields[$sub_field['name']] = $sub_field;
1891 1891
 			
1892 1892
 		}
1893 1893
 		
@@ -1895,16 +1895,16 @@  discard block
 block discarded – undo
1895 1895
 	
1896 1896
 	
1897 1897
 	// loop through the values and format the array to use sub field keys
1898
-	if( is_array($value) ) {
1898
+	if (is_array($value)) {
1899 1899
 		
1900
-		foreach( $value as $row_i => $row) {
1900
+		foreach ($value as $row_i => $row) {
1901 1901
 			
1902
-			if( $row ) {
1902
+			if ($row) {
1903 1903
 				
1904
-				foreach( $row as $sub_field_name => $sub_field_value ) {
1904
+				foreach ($row as $sub_field_name => $sub_field_value) {
1905 1905
 					
1906 1906
 					// sub field must exist!
1907
-					if( !isset($sub_fields[ $sub_field_name ]) ) {
1907
+					if ( ! isset($sub_fields[$sub_field_name])) {
1908 1908
 						
1909 1909
 						continue;
1910 1910
 						
@@ -1912,16 +1912,16 @@  discard block
 block discarded – undo
1912 1912
 					
1913 1913
 					
1914 1914
 					// vars
1915
-					$sub_field = $sub_fields[ $sub_field_name ];
1916
-					$sub_field_value = acf_convert_field_names_to_keys( $sub_field_value, $sub_field );
1915
+					$sub_field = $sub_fields[$sub_field_name];
1916
+					$sub_field_value = acf_convert_field_names_to_keys($sub_field_value, $sub_field);
1917 1917
 					
1918 1918
 					
1919 1919
 					// set new value
1920
-					$value[$row_i][ $sub_field['key'] ] = $sub_field_value;
1920
+					$value[$row_i][$sub_field['key']] = $sub_field_value;
1921 1921
 					
1922 1922
 					
1923 1923
 					// unset old value
1924
-					unset( $value[$row_i][$sub_field_name] );
1924
+					unset($value[$row_i][$sub_field_name]);
1925 1925
 						
1926 1926
 					
1927 1927
 				}
@@ -1956,10 +1956,10 @@  discard block
 block discarded – undo
1956 1956
 *  @return	$post_id (int)
1957 1957
 */
1958 1958
 
1959
-function register_field_group( $field_group ) {
1959
+function register_field_group($field_group) {
1960 1960
 	
1961 1961
 	// add local
1962
-	acf_add_local_field_group( $field_group );
1962
+	acf_add_local_field_group($field_group);
1963 1963
 	
1964 1964
 }
1965 1965
 
@@ -1983,21 +1983,21 @@  discard block
 block discarded – undo
1983 1983
 	
1984 1984
 }
1985 1985
 
1986
-function the_repeater_field( $field_name, $post_id = false ) {
1986
+function the_repeater_field($field_name, $post_id = false) {
1987 1987
 	
1988
-	return has_sub_field( $field_name, $post_id );
1988
+	return has_sub_field($field_name, $post_id);
1989 1989
 	
1990 1990
 }
1991 1991
 
1992
-function the_flexible_field( $field_name, $post_id = false ) {
1992
+function the_flexible_field($field_name, $post_id = false) {
1993 1993
 	
1994
-	return has_sub_field( $field_name, $post_id );
1994
+	return has_sub_field($field_name, $post_id);
1995 1995
 	
1996 1996
 }
1997 1997
 
1998
-function acf_filter_post_id( $post_id ) {
1998
+function acf_filter_post_id($post_id) {
1999 1999
 	
2000
-	return acf_get_valid_post_id( $post_id );
2000
+	return acf_get_valid_post_id($post_id);
2001 2001
 	
2002 2002
 }
2003 2003
 
Please login to merge, or discard this patch.
includes/acf/api/api-value.php 1 patch
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -15,52 +15,52 @@  discard block
 block discarded – undo
15 15
 *  @return	$return (mixed)
16 16
 */
17 17
 
18
-function acf_get_metadata( $post_id = 0, $name = '', $hidden = false ) {
18
+function acf_get_metadata($post_id = 0, $name = '', $hidden = false) {
19 19
 	
20 20
 	// vars
21 21
 	$value = null;
22 22
 	
23 23
 	
24 24
 	// add prefix for hidden meta
25
-	if( $hidden ) {
25
+	if ($hidden) {
26 26
 		
27
-		$name = '_' . $name;
27
+		$name = '_'.$name;
28 28
 		
29 29
 	}
30 30
 	
31 31
 	
32 32
 	// post
33
-	if( is_numeric($post_id) ) {
33
+	if (is_numeric($post_id)) {
34 34
 		
35
-		$meta = get_metadata( 'post', $post_id, $name, false );
35
+		$meta = get_metadata('post', $post_id, $name, false);
36 36
 		
37
-		if( isset($meta[0]) ) {
37
+		if (isset($meta[0])) {
38 38
 		
39 39
 		 	$value = $meta[0];
40 40
 		 	
41 41
 	 	}
42 42
 	
43 43
 	// user
44
-	} elseif( substr($post_id, 0, 5) == 'user_' ) {
44
+	} elseif (substr($post_id, 0, 5) == 'user_') {
45 45
 		
46 46
 		$user_id = (int) substr($post_id, 5);
47 47
 		
48
-		$meta = get_metadata( 'user', $user_id, $name, false );
48
+		$meta = get_metadata('user', $user_id, $name, false);
49 49
 		
50
-		if( isset($meta[0]) ) {
50
+		if (isset($meta[0])) {
51 51
 		
52 52
 		 	$value = $meta[0];
53 53
 		 	
54 54
 	 	}
55 55
 	
56 56
 	// comment
57
-	} elseif( substr($post_id, 0, 8) == 'comment_' ) {
57
+	} elseif (substr($post_id, 0, 8) == 'comment_') {
58 58
 		
59 59
 		$comment_id = (int) substr($post_id, 8);
60 60
 		
61
-		$meta = get_metadata( 'comment', $comment_id, $name, false );
61
+		$meta = get_metadata('comment', $comment_id, $name, false);
62 62
 		
63
-		if( isset($meta[0]) ) {
63
+		if (isset($meta[0])) {
64 64
 		
65 65
 		 	$value = $meta[0];
66 66
 		 	
@@ -69,14 +69,14 @@  discard block
 block discarded – undo
69 69
 	} else {
70 70
 		
71 71
 		// modify prefix for hidden meta
72
-		if( $hidden ) {
72
+		if ($hidden) {
73 73
 			
74
-			$post_id = '_' . $post_id;
74
+			$post_id = '_'.$post_id;
75 75
 			$name = substr($name, 1);
76 76
 			
77 77
 		}
78 78
 		
79
-		$value = get_option( $post_id . '_' . $name, null );
79
+		$value = get_option($post_id.'_'.$name, null);
80 80
 		
81 81
 	}
82 82
 		
@@ -103,34 +103,34 @@  discard block
 block discarded – undo
103 103
 *  @return	$return (boolean)
104 104
 */
105 105
 
106
-function acf_update_metadata( $post_id = 0, $name = '', $value = '', $hidden = false ) {
106
+function acf_update_metadata($post_id = 0, $name = '', $value = '', $hidden = false) {
107 107
 	
108 108
 	// vars
109 109
 	$return = false;
110 110
 	
111 111
 	
112 112
 	// add prefix for hidden meta
113
-	if( $hidden ) {
113
+	if ($hidden) {
114 114
 		
115
-		$name = '_' . $name;
115
+		$name = '_'.$name;
116 116
 		
117 117
 	}
118 118
 	
119 119
 	
120 120
 	// postmeta
121
-	if( is_numeric($post_id) ) {
121
+	if (is_numeric($post_id)) {
122 122
 		
123
-		$return = update_metadata('post', $post_id, $name, $value );
123
+		$return = update_metadata('post', $post_id, $name, $value);
124 124
 	
125 125
 	// usermeta
126
-	} elseif( substr($post_id, 0, 5) == 'user_' ) {
126
+	} elseif (substr($post_id, 0, 5) == 'user_') {
127 127
 		
128 128
 		$user_id = (int) substr($post_id, 5);
129 129
 		
130 130
 		$return = update_metadata('user', $user_id, $name, $value);
131 131
 		
132 132
 	// commentmeta
133
-	} elseif( substr($post_id, 0, 8) == 'comment_' ) {
133
+	} elseif (substr($post_id, 0, 8) == 'comment_') {
134 134
 		
135 135
 		$comment_id = (int) substr($post_id, 8);
136 136
 		
@@ -140,14 +140,14 @@  discard block
 block discarded – undo
140 140
 	} else {
141 141
 		
142 142
 		// modify prefix for hidden meta
143
-		if( $hidden ) {
143
+		if ($hidden) {
144 144
 			
145
-			$post_id = '_' . $post_id;
145
+			$post_id = '_'.$post_id;
146 146
 			$name = substr($name, 1);
147 147
 			
148 148
 		}
149 149
 		
150
-		$return = acf_update_option( $post_id . '_' . $name, $value );
150
+		$return = acf_update_option($post_id.'_'.$name, $value);
151 151
 		
152 152
 	}
153 153
 	
@@ -173,34 +173,34 @@  discard block
 block discarded – undo
173 173
 *  @return	$return (boolean)
174 174
 */
175 175
 
176
-function acf_delete_metadata( $post_id = 0, $name = '', $hidden = false ) {
176
+function acf_delete_metadata($post_id = 0, $name = '', $hidden = false) {
177 177
 	
178 178
 	// vars
179 179
 	$return = false;
180 180
 	
181 181
 	
182 182
 	// add prefix for hidden meta
183
-	if( $hidden ) {
183
+	if ($hidden) {
184 184
 		
185
-		$name = '_' . $name;
185
+		$name = '_'.$name;
186 186
 		
187 187
 	}
188 188
 	
189 189
 	
190 190
 	// postmeta
191
-	if( is_numeric($post_id) ) {
191
+	if (is_numeric($post_id)) {
192 192
 		
193
-		$return = delete_metadata('post', $post_id, $name );
193
+		$return = delete_metadata('post', $post_id, $name);
194 194
 	
195 195
 	// usermeta
196
-	} elseif( substr($post_id, 0, 5) == 'user_' ) {
196
+	} elseif (substr($post_id, 0, 5) == 'user_') {
197 197
 		
198 198
 		$user_id = (int) substr($post_id, 5);
199 199
 		
200 200
 		$return = delete_metadata('user', $user_id, $name);
201 201
 		
202 202
 	// commentmeta
203
-	} elseif( substr($post_id, 0, 8) == 'comment_' ) {
203
+	} elseif (substr($post_id, 0, 8) == 'comment_') {
204 204
 		
205 205
 		$comment_id = (int) substr($post_id, 8);
206 206
 		
@@ -210,14 +210,14 @@  discard block
 block discarded – undo
210 210
 	} else {
211 211
 		
212 212
 		// modify prefix for hidden meta
213
-		if( $hidden ) {
213
+		if ($hidden) {
214 214
 			
215
-			$post_id = '_' . $post_id;
215
+			$post_id = '_'.$post_id;
216 216
 			$name = substr($name, 1);
217 217
 			
218 218
 		}
219 219
 		
220
-		$return = delete_option( $post_id . '_' . $name );
220
+		$return = delete_option($post_id.'_'.$name);
221 221
 		
222 222
 	}
223 223
 	
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 *  @return	(boolean)
244 244
 */
245 245
 
246
-function acf_update_option( $option = '', $value = '', $autoload = null ) {
246
+function acf_update_option($option = '', $value = '', $autoload = null) {
247 247
 	
248 248
 	// vars
249 249
 	$deprecated = '';
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	
252 252
 	
253 253
 	// autoload
254
-	if( $autoload === null ){
254
+	if ($autoload === null) {
255 255
 		
256 256
 		$autoload = acf_get_setting('autoload') ? 'yes' : 'no';
257 257
 		
@@ -265,13 +265,13 @@  discard block
 block discarded – undo
265 265
 		
266 266
 		
267 267
 	// add or update
268
-	if( get_option($option) !== false ) {
268
+	if (get_option($option) !== false) {
269 269
 	
270
-	    $return = update_option( $option, $value );
270
+	    $return = update_option($option, $value);
271 271
 	    
272 272
 	} else {
273 273
 		
274
-		$return = add_option( $option, $value, $deprecated, $autoload );
274
+		$return = add_option($option, $value, $deprecated, $autoload);
275 275
 		
276 276
 	}
277 277
 	
@@ -296,17 +296,17 @@  discard block
 block discarded – undo
296 296
 *  @return	(mixed)
297 297
 */
298 298
 
299
-function acf_get_value( $post_id = 0, $field ) {
299
+function acf_get_value($post_id = 0, $field) {
300 300
 	
301 301
 	// bail early if no $post_id (acf_form - new_post)
302
-	if( !$post_id ) return null;
302
+	if ( ! $post_id) return null;
303 303
 	
304 304
 	
305 305
 	// try cache
306 306
 	$found = false;
307
-	$cache = wp_cache_get( "load_value/post_id={$post_id}/name={$field['name']}", 'acf', false, $found );
307
+	$cache = wp_cache_get("load_value/post_id={$post_id}/name={$field['name']}", 'acf', false, $found);
308 308
 	
309
-	if( $found ) {
309
+	if ($found) {
310 310
 	
311 311
 		return $cache;
312 312
 		
@@ -314,15 +314,15 @@  discard block
 block discarded – undo
314 314
 	
315 315
 	
316 316
 	// load value
317
-	$value = acf_get_metadata( $post_id, $field['name'] );
317
+	$value = acf_get_metadata($post_id, $field['name']);
318 318
 	
319 319
 	
320 320
 	// if value was duplicated, it may now be a serialized string!
321
-	$value = maybe_unserialize( $value );
321
+	$value = maybe_unserialize($value);
322 322
 	
323 323
 	
324 324
 	// no value? try default_value
325
-	if( $value === null && isset($field['default_value']) ) {
325
+	if ($value === null && isset($field['default_value'])) {
326 326
 		
327 327
 		$value = $field['default_value'];
328 328
 		
@@ -330,14 +330,14 @@  discard block
 block discarded – undo
330 330
 	
331 331
 	
332 332
 	// filter for 3rd party customization
333
-	$value = apply_filters( "acf/load_value", $value, $post_id, $field );
334
-	$value = apply_filters( "acf/load_value/type={$field['type']}", $value, $post_id, $field );
335
-	$value = apply_filters( "acf/load_value/name={$field['name']}", $value, $post_id, $field );
336
-	$value = apply_filters( "acf/load_value/key={$field['key']}", $value, $post_id, $field );
333
+	$value = apply_filters("acf/load_value", $value, $post_id, $field);
334
+	$value = apply_filters("acf/load_value/type={$field['type']}", $value, $post_id, $field);
335
+	$value = apply_filters("acf/load_value/name={$field['name']}", $value, $post_id, $field);
336
+	$value = apply_filters("acf/load_value/key={$field['key']}", $value, $post_id, $field);
337 337
 	
338 338
 	
339 339
 	// update cache
340
-	wp_cache_set( "load_value/post_id={$post_id}/name={$field['name']}", $value, 'acf' );
340
+	wp_cache_set("load_value/post_id={$post_id}/name={$field['name']}", $value, 'acf');
341 341
 
342 342
 	
343 343
 	// return
@@ -361,13 +361,13 @@  discard block
 block discarded – undo
361 361
 *  @return	$value
362 362
 */
363 363
 
364
-function acf_format_value( $value, $post_id, $field ) {
364
+function acf_format_value($value, $post_id, $field) {
365 365
 	
366 366
 	// apply filters
367
-	$value = apply_filters( "acf/format_value", $value, $post_id, $field );
368
-	$value = apply_filters( "acf/format_value/type={$field['type']}", $value, $post_id, $field );
369
-	$value = apply_filters( "acf/format_value/name={$field['name']}", $value, $post_id, $field );
370
-	$value = apply_filters( "acf/format_value/key={$field['key']}", $value, $post_id, $field );
367
+	$value = apply_filters("acf/format_value", $value, $post_id, $field);
368
+	$value = apply_filters("acf/format_value/type={$field['type']}", $value, $post_id, $field);
369
+	$value = apply_filters("acf/format_value/name={$field['name']}", $value, $post_id, $field);
370
+	$value = apply_filters("acf/format_value/key={$field['key']}", $value, $post_id, $field);
371 371
 	
372 372
 	
373 373
 	// return
@@ -390,10 +390,10 @@  discard block
 block discarded – undo
390 390
 *  @return	(boolean)
391 391
 */
392 392
 
393
-function acf_update_value( $value = null, $post_id = 0, $field ) {
393
+function acf_update_value($value = null, $post_id = 0, $field) {
394 394
 	
395 395
 	// strip slashes
396
-	if( acf_get_setting('stripslashes') ) {
396
+	if (acf_get_setting('stripslashes')) {
397 397
 		
398 398
 		$value = stripslashes_deep($value);
399 399
 		
@@ -401,22 +401,22 @@  discard block
 block discarded – undo
401 401
 	
402 402
 	
403 403
 	// filter for 3rd party customization
404
-	$value = apply_filters( "acf/update_value", $value, $post_id, $field );
405
-	$value = apply_filters( "acf/update_value/type={$field['type']}", $value, $post_id, $field );
406
-	$value = apply_filters( "acf/update_value/name={$field['name']}", $value, $post_id, $field );
407
-	$value = apply_filters( "acf/update_value/key={$field['key']}", $value, $post_id, $field );
404
+	$value = apply_filters("acf/update_value", $value, $post_id, $field);
405
+	$value = apply_filters("acf/update_value/type={$field['type']}", $value, $post_id, $field);
406
+	$value = apply_filters("acf/update_value/name={$field['name']}", $value, $post_id, $field);
407
+	$value = apply_filters("acf/update_value/key={$field['key']}", $value, $post_id, $field);
408 408
 	
409 409
 
410 410
 	// update value
411
-	$return = acf_update_metadata( $post_id, $field['name'], $value );
411
+	$return = acf_update_metadata($post_id, $field['name'], $value);
412 412
 	
413 413
 	
414 414
 	// update reference
415
-	acf_update_metadata( $post_id, $field['name'], $field['key'], true );
415
+	acf_update_metadata($post_id, $field['name'], $field['key'], true);
416 416
 	
417 417
 	
418 418
 	// clear cache
419
-	wp_cache_delete( "load_value/post_id={$post_id}/name={$field['name']}", 'acf' );
419
+	wp_cache_delete("load_value/post_id={$post_id}/name={$field['name']}", 'acf');
420 420
 
421 421
 	
422 422
 	// return
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 *  @return	(boolean)
440 440
 */
441 441
 
442
-function acf_delete_value( $post_id = 0, $field ) {
442
+function acf_delete_value($post_id = 0, $field) {
443 443
 	
444 444
 	// action for 3rd party customization
445 445
 	do_action("acf/delete_value", $post_id, $field['name'], $field);
@@ -449,15 +449,15 @@  discard block
 block discarded – undo
449 449
 	
450 450
 	
451 451
 	// delete value
452
-	$return = acf_delete_metadata( $post_id, $field['name'] );
452
+	$return = acf_delete_metadata($post_id, $field['name']);
453 453
 	
454 454
 	
455 455
 	// delete reference
456
-	acf_delete_metadata( $post_id, $field['name'], true );
456
+	acf_delete_metadata($post_id, $field['name'], true);
457 457
 	
458 458
 	
459 459
 	// clear cache
460
-	wp_cache_delete( "load_value/post_id={$post_id}/name={$field['name']}", 'acf' );
460
+	wp_cache_delete("load_value/post_id={$post_id}/name={$field['name']}", 'acf');
461 461
 	
462 462
 	
463 463
 	// return
Please login to merge, or discard this patch.
includes/acf/core/ajax.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 *  @subpackage	Core
11 11
 */
12 12
 
13
-if( ! class_exists('acf_ajax') ) :
13
+if ( ! class_exists('acf_ajax')) :
14 14
 
15 15
 class acf_ajax {
16 16
 	
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
 	function __construct() {
32 32
 		
33 33
 		// acf/update_user_setting
34
-		add_action( 'wp_ajax_acf/update_user_setting',			array($this, 'update_user_setting') );
35
-		add_action( 'wp_ajax_nopriv_acf/update_user_setting',	array($this, 'update_user_setting') );
34
+		add_action('wp_ajax_acf/update_user_setting', array($this, 'update_user_setting'));
35
+		add_action('wp_ajax_nopriv_acf/update_user_setting', array($this, 'update_user_setting'));
36 36
 		
37 37
 	}
38 38
 	
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	function update_user_setting() {
54 54
 		
55 55
 		// options
56
-		$options = acf_parse_args( $_POST, array(
56
+		$options = acf_parse_args($_POST, array(
57 57
 			'name'		=> '',
58 58
 			'value'		=> '',
59 59
 			'nonce'		=> '',
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 		
62 62
 		
63 63
 		// validate
64
-		if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') || empty($options['name']) ) {
64
+		if ( ! wp_verify_nonce($options['nonce'], 'acf_nonce') || empty($options['name'])) {
65 65
 		
66 66
 			die('0');
67 67
 			
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		
70 70
 		
71 71
 		// upadte setting
72
-		acf_update_user_setting( $options['name'], $options['value'] );
72
+		acf_update_user_setting($options['name'], $options['value']);
73 73
 		
74 74
 		
75 75
 		// return
Please login to merge, or discard this patch.
includes/acf/core/compatibility.php 1 patch
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -18,27 +18,27 @@  discard block
 block discarded – undo
18 18
 	function __construct() {
19 19
 		
20 20
 		// fields
21
-		add_filter('acf/get_valid_field',					array($this, 'get_valid_field'), 20, 1);
22
-		add_filter('acf/get_valid_field/type=textarea',		array($this, 'get_valid_textarea_field'), 20, 1);
23
-		add_filter('acf/get_valid_field/type=relationship',	array($this, 'get_valid_relationship_field'), 20, 1);
24
-		add_filter('acf/get_valid_field/type=post_object',	array($this, 'get_valid_relationship_field'), 20, 1);
25
-		add_filter('acf/get_valid_field/type=page_link',	array($this, 'get_valid_relationship_field'), 20, 1);
26
-		add_filter('acf/get_valid_field/type=image',		array($this, 'get_valid_image_field'), 20, 1);
27
-		add_filter('acf/get_valid_field/type=file',			array($this, 'get_valid_image_field'), 20, 1);
28
-		add_filter('acf/get_valid_field/type=wysiwyg',		array($this, 'get_valid_wysiwyg_field'), 20, 1);
29
-		add_filter('acf/get_valid_field/type=date_picker',	array($this, 'get_valid_date_picker_field'), 20, 1);
30
-		add_filter('acf/get_valid_field/type=taxonomy',		array($this, 'get_valid_taxonomy_field'), 20, 1);
21
+		add_filter('acf/get_valid_field', array($this, 'get_valid_field'), 20, 1);
22
+		add_filter('acf/get_valid_field/type=textarea', array($this, 'get_valid_textarea_field'), 20, 1);
23
+		add_filter('acf/get_valid_field/type=relationship', array($this, 'get_valid_relationship_field'), 20, 1);
24
+		add_filter('acf/get_valid_field/type=post_object', array($this, 'get_valid_relationship_field'), 20, 1);
25
+		add_filter('acf/get_valid_field/type=page_link', array($this, 'get_valid_relationship_field'), 20, 1);
26
+		add_filter('acf/get_valid_field/type=image', array($this, 'get_valid_image_field'), 20, 1);
27
+		add_filter('acf/get_valid_field/type=file', array($this, 'get_valid_image_field'), 20, 1);
28
+		add_filter('acf/get_valid_field/type=wysiwyg', array($this, 'get_valid_wysiwyg_field'), 20, 1);
29
+		add_filter('acf/get_valid_field/type=date_picker', array($this, 'get_valid_date_picker_field'), 20, 1);
30
+		add_filter('acf/get_valid_field/type=taxonomy', array($this, 'get_valid_taxonomy_field'), 20, 1);
31 31
 		
32 32
 		
33 33
 		// field groups
34
-		add_filter('acf/get_valid_field_group',				array($this, 'get_valid_field_group'), 20, 1);
34
+		add_filter('acf/get_valid_field_group', array($this, 'get_valid_field_group'), 20, 1);
35 35
 		
36 36
 		
37 37
 		// settings
38
-		add_filter('acf/settings/show_admin',				array($this, 'settings_acf_lite'), 5, 1);
39
-		add_filter('acf/settings/l10n_textdomain',			array($this, 'settings_export_textdomain'), 5, 1);
40
-		add_filter('acf/settings/l10n_field',				array($this, 'settings_export_translate'), 5, 1);
41
-		add_filter('acf/settings/l10n_field_group',			array($this, 'settings_export_translate'), 5, 1);
38
+		add_filter('acf/settings/show_admin', array($this, 'settings_acf_lite'), 5, 1);
39
+		add_filter('acf/settings/l10n_textdomain', array($this, 'settings_export_textdomain'), 5, 1);
40
+		add_filter('acf/settings/l10n_field', array($this, 'settings_export_translate'), 5, 1);
41
+		add_filter('acf/settings/l10n_field_group', array($this, 'settings_export_translate'), 5, 1);
42 42
 		
43 43
 	}
44 44
 	
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
 	*  @return	$post_id (int)
57 57
 	*/
58 58
 	
59
-	function settings_acf_lite( $setting ) {
59
+	function settings_acf_lite($setting) {
60 60
 		
61 61
 		// 5.0.0 - removed ACF_LITE
62
-		if( defined('ACF_LITE') && ACF_LITE ) {
62
+		if (defined('ACF_LITE') && ACF_LITE) {
63 63
 			
64 64
 			$setting = false;
65 65
 			
@@ -71,17 +71,17 @@  discard block
 block discarded – undo
71 71
 		
72 72
 	}
73 73
 	
74
-	function settings_export_textdomain( $setting ) {
74
+	function settings_export_textdomain($setting) {
75 75
 		
76 76
 		// 5.3.3 - changed filter name
77
-		return acf_get_setting( 'export_textdomain', $setting );
77
+		return acf_get_setting('export_textdomain', $setting);
78 78
 		
79 79
 	}
80 80
 	
81
-	function settings_export_translate( $setting ) {
81
+	function settings_export_translate($setting) {
82 82
 		
83 83
 		// 5.3.3 - changed filter name
84
-		return acf_get_setting( 'export_translate', $setting );
84
+		return acf_get_setting('export_translate', $setting);
85 85
 		
86 86
 	}
87 87
 	
@@ -99,17 +99,17 @@  discard block
 block discarded – undo
99 99
 	*  @return	$field
100 100
 	*/
101 101
 	
102
-	function get_valid_field( $field ) {
102
+	function get_valid_field($field) {
103 103
 		
104 104
 		// conditional logic has changed
105
-		if( isset($field['conditional_logic']['status']) ) {
105
+		if (isset($field['conditional_logic']['status'])) {
106 106
 			
107 107
 			// extract logic
108
-			$logic = acf_extract_var( $field, 'conditional_logic' );
108
+			$logic = acf_extract_var($field, 'conditional_logic');
109 109
 			
110 110
 			
111 111
 			// disabled
112
-			if( !empty($logic['status']) ) {
112
+			if ( ! empty($logic['status'])) {
113 113
 				
114 114
 				// reset
115 115
 				$field['conditional_logic'] = array();
@@ -121,12 +121,12 @@  discard block
 block discarded – undo
121 121
 		 		
122 122
 		 		
123 123
 		 		// loop over rules
124
-		 		if( !empty($logic['rules']) ) {
124
+		 		if ( ! empty($logic['rules'])) {
125 125
 			 		
126
-			 		foreach( $logic['rules'] as $rule ) {
126
+			 		foreach ($logic['rules'] as $rule) {
127 127
 				 		
128 128
 					 	// sperate groups?
129
-					 	if( $all_or_any == 'any' ) {
129
+					 	if ($all_or_any == 'any') {
130 130
 					 	
131 131
 						 	$group++;
132 132
 						 	
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 					 	
135 135
 					 	
136 136
 					 	// add to group
137
-					 	$field['conditional_logic'][ $group ][] = $rule;
137
+					 	$field['conditional_logic'][$group][] = $rule;
138 138
 			 	
139 139
 				 	}
140 140
 				 	
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 	*  @return	$field
174 174
 	*/
175 175
 	
176
-	function get_valid_relationship_field( $field ) {
176
+	function get_valid_relationship_field($field) {
177 177
 		
178 178
 		// force array
179 179
 		$field['post_type'] = acf_get_array($field['post_type']);
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 		
182 182
 		
183 183
 		// remove 'all' from post_type
184
-		if( acf_in_array('all', $field['post_type']) ) {
184
+		if (acf_in_array('all', $field['post_type'])) {
185 185
 			
186 186
 			$field['post_type'] = array();
187 187
 			
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 		
190 190
 		
191 191
 		// remove 'all' from taxonomy
192
-		if( acf_in_array('all', $field['taxonomy']) ) {
192
+		if (acf_in_array('all', $field['taxonomy'])) {
193 193
 			
194 194
 			$field['taxonomy'] = array();
195 195
 			
@@ -197,9 +197,9 @@  discard block
 block discarded – undo
197 197
 		
198 198
 		
199 199
 		// save_format is now return_format
200
-		if( !empty($field['result_elements']) ) {
200
+		if ( ! empty($field['result_elements'])) {
201 201
 			
202
-			$field['elements'] = acf_extract_var( $field, 'result_elements' );
202
+			$field['elements'] = acf_extract_var($field, 'result_elements');
203 203
 			
204 204
 		}
205 205
 		
@@ -223,12 +223,12 @@  discard block
 block discarded – undo
223 223
 	*  @return	$field
224 224
 	*/
225 225
 	
226
-	function get_valid_textarea_field( $field ) {
226
+	function get_valid_textarea_field($field) {
227 227
 		
228 228
 		// formatting has been removed
229
-		$formatting = acf_extract_var( $field, 'formatting' );
229
+		$formatting = acf_extract_var($field, 'formatting');
230 230
 		
231
-		if( $formatting === 'br' ) {
231
+		if ($formatting === 'br') {
232 232
 			
233 233
 			$field['new_lines'] = 'br';
234 234
 			
@@ -253,18 +253,18 @@  discard block
 block discarded – undo
253 253
 	*  @return	$field
254 254
 	*/
255 255
 	
256
-	function get_valid_image_field( $field ) {
256
+	function get_valid_image_field($field) {
257 257
 		
258 258
 		// save_format is now return_format
259
-		if( !empty($field['save_format']) ) {
259
+		if ( ! empty($field['save_format'])) {
260 260
 			
261
-			$field['return_format'] = acf_extract_var( $field, 'save_format' );
261
+			$field['return_format'] = acf_extract_var($field, 'save_format');
262 262
 			
263 263
 		}
264 264
 		
265 265
 		
266 266
 		// object is now array
267
-		if( $field['return_format'] == 'object' ) {
267
+		if ($field['return_format'] == 'object') {
268 268
 			
269 269
 			$field['return_format'] = 'array';
270 270
 			
@@ -289,14 +289,14 @@  discard block
 block discarded – undo
289 289
 	*  @return	$field
290 290
 	*/
291 291
 	
292
-	function get_valid_wysiwyg_field( $field ) {
292
+	function get_valid_wysiwyg_field($field) {
293 293
 		
294 294
 		// media_upload is now numeric
295
-		if( $field['media_upload'] === 'yes' ) {
295
+		if ($field['media_upload'] === 'yes') {
296 296
 			
297 297
 			$field['media_upload'] = 1;
298 298
 			
299
-		} elseif( $field['media_upload'] === 'no' ) {
299
+		} elseif ($field['media_upload'] === 'no') {
300 300
 			
301 301
 			$field['media_upload'] = 0;
302 302
 			
@@ -321,19 +321,19 @@  discard block
 block discarded – undo
321 321
 	*  @return	$field
322 322
 	*/
323 323
 	
324
-	function get_valid_date_picker_field( $field ) {
324
+	function get_valid_date_picker_field($field) {
325 325
 		
326 326
 		// v4 used date_format
327
-		if( !empty($field['date_format']) ) {
327
+		if ( ! empty($field['date_format'])) {
328 328
 			
329 329
 			// extract vars
330
-			$date_format = acf_extract_var( $field, 'date_format' );
331
-			$display_format = acf_extract_var( $field, 'display_format' );
330
+			$date_format = acf_extract_var($field, 'date_format');
331
+			$display_format = acf_extract_var($field, 'display_format');
332 332
 			
333 333
 			
334 334
 			// convert from js to php
335
-			$date_format = acf_convert_date_to_php( $date_format );
336
-			$display_format = acf_convert_date_to_php( $display_format );
335
+			$date_format = acf_convert_date_to_php($date_format);
336
+			$display_format = acf_convert_date_to_php($display_format);
337 337
 			
338 338
 			
339 339
 			// append settings
@@ -362,10 +362,10 @@  discard block
 block discarded – undo
362 362
 	*  @return	$field
363 363
 	*/
364 364
 	
365
-	function get_valid_taxonomy_field( $field ) {
365
+	function get_valid_taxonomy_field($field) {
366 366
 		
367 367
 		// 5.2.7
368
-		if( isset($field['load_save_terms']) ) {
368
+		if (isset($field['load_save_terms'])) {
369 369
 			
370 370
 			$field['save_terms'] = $field['load_save_terms'];
371 371
 			
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 	*  @return	$field_group
392 392
 	*/
393 393
 	
394
-	function get_valid_field_group( $field_group ) {
394
+	function get_valid_field_group($field_group) {
395 395
 		
396 396
 		// global
397 397
 		global $wpdb;
@@ -402,20 +402,20 @@  discard block
 block discarded – undo
402 402
 		
403 403
 		
404 404
 		// add missing 'key' (v5.0.0)
405
-		if( empty($field_group['key']) ) {
405
+		if (empty($field_group['key'])) {
406 406
 			
407 407
 			// update version
408 408
 			$v = 4;
409 409
 			
410 410
 			
411 411
 			// add missing key
412
-			$field_group['key'] = empty($field_group['id']) ? uniqid('group_') : 'group_' . $field_group['id'];
412
+			$field_group['key'] = empty($field_group['id']) ? uniqid('group_') : 'group_'.$field_group['id'];
413 413
 			
414 414
 		}
415 415
 		
416 416
 		
417 417
 		// extract options (v5.0.0)
418
-		if( !empty($field_group['options']) ) {
418
+		if ( ! empty($field_group['options'])) {
419 419
 			
420 420
 			$options = acf_extract_var($field_group, 'options');
421 421
 			$field_group = array_merge($field_group, $options);
@@ -424,10 +424,10 @@  discard block
 block discarded – undo
424 424
 		
425 425
 		
426 426
 		// location rules changed to groups (v5.0.0)
427
-		if( !empty($field_group['location']['rules']) ) {
427
+		if ( ! empty($field_group['location']['rules'])) {
428 428
 			
429 429
 			// extract location
430
-			$location = acf_extract_var( $field_group, 'location' );
430
+			$location = acf_extract_var($field_group, 'location');
431 431
 			
432 432
 			
433 433
 			// reset location
@@ -440,12 +440,12 @@  discard block
 block discarded – undo
440 440
 	 		
441 441
 	 		
442 442
 	 		// loop over rules
443
-	 		if( !empty($location['rules']) ) {
443
+	 		if ( ! empty($location['rules'])) {
444 444
 		 		
445
-		 		foreach( $location['rules'] as $rule ) {
445
+		 		foreach ($location['rules'] as $rule) {
446 446
 			 		
447 447
 				 	// sperate groups?
448
-				 	if( $all_or_any == 'any' ) {
448
+				 	if ($all_or_any == 'any') {
449 449
 				 	
450 450
 					 	$group++;
451 451
 					 	
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 				 	
454 454
 				 	
455 455
 				 	// add to group
456
-				 	$field_group['location'][ $group ][] = $rule;
456
+				 	$field_group['location'][$group][] = $rule;
457 457
 		 	
458 458
 			 	}
459 459
 			 	
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 		
468 468
 		
469 469
 		// some location rules have changed (v5.0.0)
470
-		if( !empty($field_group['location']) ) {
470
+		if ( ! empty($field_group['location'])) {
471 471
 			
472 472
 			// param changes
473 473
 		 	$param_replace = array(
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
 		 	
481 481
 		 	
482 482
 		 	// remove conflicting param
483
-		 	if( $v == 5 ) {
483
+		 	if ($v == 5) {
484 484
 			 	
485 485
 			 	unset($param_replace['taxonomy']);
486 486
 			 	
@@ -488,14 +488,14 @@  discard block
 block discarded – undo
488 488
 		 	
489 489
 		 	
490 490
 			// loop over location groups
491
-			foreach( array_keys($field_group['location']) as $i ) {
491
+			foreach (array_keys($field_group['location']) as $i) {
492 492
 				
493 493
 				// extract group
494
-				$group = acf_extract_var( $field_group['location'], $i );
494
+				$group = acf_extract_var($field_group['location'], $i);
495 495
 				
496 496
 				
497 497
 				// bail early if group is empty
498
-				if( empty($group) ) {
498
+				if (empty($group)) {
499 499
 					
500 500
 					continue;
501 501
 					
@@ -503,28 +503,28 @@  discard block
 block discarded – undo
503 503
 				
504 504
 				
505 505
 				// loop over group rules
506
-				foreach( array_keys($group) as $j ) {
506
+				foreach (array_keys($group) as $j) {
507 507
 					
508 508
 					// extract rule
509
-					$rule = acf_extract_var( $group, $j );
509
+					$rule = acf_extract_var($group, $j);
510 510
 					
511 511
 					
512 512
 					// migrate param
513
-					if( isset($param_replace[ $rule['param'] ]) ) {
513
+					if (isset($param_replace[$rule['param']])) {
514 514
 						
515
-						$rule['param'] = $param_replace[ $rule['param'] ];
515
+						$rule['param'] = $param_replace[$rule['param']];
516 516
 						
517 517
 					}
518 518
 					
519 519
 					 	
520 520
 				 	// category / taxonomy terms are saved differently
521
-				 	if( $rule['param'] == 'post_category' || $rule['param'] == 'post_taxonomy' ) {
521
+				 	if ($rule['param'] == 'post_category' || $rule['param'] == 'post_taxonomy') {
522 522
 					 	
523
-					 	if( is_numeric($rule['value']) ) {
523
+					 	if (is_numeric($rule['value'])) {
524 524
 						 	
525 525
 						 	$term_id = $rule['value'];
526
-						 	$taxonomy = $wpdb->get_var( $wpdb->prepare( "SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d LIMIT 1", $term_id) );
527
-						 	$term = get_term( $term_id, $taxonomy );
526
+						 	$taxonomy = $wpdb->get_var($wpdb->prepare("SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d LIMIT 1", $term_id));
527
+						 	$term = get_term($term_id, $taxonomy);
528 528
 						 	
529 529
 						 	// update rule value
530 530
 						 	$rule['value'] = "{$term->taxonomy}:{$term->slug}";
@@ -535,14 +535,14 @@  discard block
 block discarded – undo
535 535
 				 	
536 536
 				 	
537 537
 				 	// append rule
538
-				 	$group[ $j ] = $rule;
538
+				 	$group[$j] = $rule;
539 539
 				 	
540 540
 				}
541 541
 				// foreach
542 542
 				
543 543
 				
544 544
 				// append group
545
-				$field_group['location'][ $i ] = $group;
545
+				$field_group['location'][$i] = $group;
546 546
 				
547 547
 			}
548 548
 			// foreach
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
 		
553 553
 		
554 554
 		// change layout to style (v5.0.0)
555
-		if( !empty($field_group['layout']) ) {
555
+		if ( ! empty($field_group['layout'])) {
556 556
 		
557 557
 			$field_group['style'] = acf_extract_var($field_group, 'layout');
558 558
 			
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
 		
561 561
 		
562 562
 		// change no_box to seamless (v5.0.0)
563
-		if( $field_group['style'] === 'no_box' ) {
563
+		if ($field_group['style'] === 'no_box') {
564 564
 		
565 565
 			$field_group['style'] = 'seamless';
566 566
 			
Please login to merge, or discard this patch.
includes/acf/core/field.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -25,40 +25,40 @@  discard block
 block discarded – undo
25 25
 	function __construct() {
26 26
 		
27 27
 		// register field
28
-		add_filter("acf/get_field_types",								array($this, 'get_field_types'), 10, 1);
29
-		add_filter("acf/get_valid_field/type={$this->name}",			array($this, 'get_valid_field'), 10, 1);
28
+		add_filter("acf/get_field_types", array($this, 'get_field_types'), 10, 1);
29
+		add_filter("acf/get_valid_field/type={$this->name}", array($this, 'get_valid_field'), 10, 1);
30 30
 		
31 31
 		
32 32
 		// value
33
-		$this->add_filter("acf/load_value/type={$this->name}",			array($this, 'load_value'), 10, 3);
34
-		$this->add_filter("acf/update_value/type={$this->name}",		array($this, 'update_value'), 10, 3);
35
-		$this->add_filter("acf/format_value/type={$this->name}",		array($this, 'format_value'), 10, 3);
36
-		$this->add_filter("acf/validate_value/type={$this->name}",		array($this, 'validate_value'), 10, 4);
37
-		$this->add_action("acf/delete_value/type={$this->name}",		array($this, 'delete_value'), 10, 3);
33
+		$this->add_filter("acf/load_value/type={$this->name}", array($this, 'load_value'), 10, 3);
34
+		$this->add_filter("acf/update_value/type={$this->name}", array($this, 'update_value'), 10, 3);
35
+		$this->add_filter("acf/format_value/type={$this->name}", array($this, 'format_value'), 10, 3);
36
+		$this->add_filter("acf/validate_value/type={$this->name}", array($this, 'validate_value'), 10, 4);
37
+		$this->add_action("acf/delete_value/type={$this->name}", array($this, 'delete_value'), 10, 3);
38 38
 		
39 39
 		
40 40
 		// field
41
-		$this->add_filter("acf/load_field/type={$this->name}",				array($this, 'load_field'), 10, 1);
42
-		$this->add_filter("acf/update_field/type={$this->name}",			array($this, 'update_field'), 10, 1);
43
-		$this->add_filter("acf/duplicate_field/type={$this->name}",			array($this, 'duplicate_field'), 10, 1);
44
-		$this->add_action("acf/delete_field/type={$this->name}",			array($this, 'delete_field'), 10, 1);
45
-		$this->add_action("acf/render_field/type={$this->name}",			array($this, 'render_field'), 10, 1);
46
-		$this->add_action("acf/render_field_settings/type={$this->name}",	array($this, 'render_field_settings'), 10, 1);
47
-		$this->add_action("acf/prepare_field/type={$this->name}",			array($this, 'prepare_field'), 10, 1);
41
+		$this->add_filter("acf/load_field/type={$this->name}", array($this, 'load_field'), 10, 1);
42
+		$this->add_filter("acf/update_field/type={$this->name}", array($this, 'update_field'), 10, 1);
43
+		$this->add_filter("acf/duplicate_field/type={$this->name}", array($this, 'duplicate_field'), 10, 1);
44
+		$this->add_action("acf/delete_field/type={$this->name}", array($this, 'delete_field'), 10, 1);
45
+		$this->add_action("acf/render_field/type={$this->name}", array($this, 'render_field'), 10, 1);
46
+		$this->add_action("acf/render_field_settings/type={$this->name}", array($this, 'render_field_settings'), 10, 1);
47
+		$this->add_action("acf/prepare_field/type={$this->name}", array($this, 'prepare_field'), 10, 1);
48 48
 		
49 49
 		
50 50
 		// input actions
51
-		$this->add_action("acf/input/admin_enqueue_scripts",			array($this, 'input_admin_enqueue_scripts'), 10, 0);
52
-		$this->add_action("acf/input/admin_head",						array($this, 'input_admin_head'), 10, 0);
53
-		$this->add_action("acf/input/form_data",						array($this, 'input_form_data'), 10, 1);
54
-		$this->add_filter("acf/input/admin_l10n",						array($this, 'input_admin_l10n'), 10, 1);
55
-		$this->add_action("acf/input/admin_footer",						array($this, 'input_admin_footer'), 10, 1);
51
+		$this->add_action("acf/input/admin_enqueue_scripts", array($this, 'input_admin_enqueue_scripts'), 10, 0);
52
+		$this->add_action("acf/input/admin_head", array($this, 'input_admin_head'), 10, 0);
53
+		$this->add_action("acf/input/form_data", array($this, 'input_form_data'), 10, 1);
54
+		$this->add_filter("acf/input/admin_l10n", array($this, 'input_admin_l10n'), 10, 1);
55
+		$this->add_action("acf/input/admin_footer", array($this, 'input_admin_footer'), 10, 1);
56 56
 		
57 57
 		
58 58
 		// field group actions
59
-		$this->add_action("acf/field_group/admin_enqueue_scripts", 		array($this, 'field_group_admin_enqueue_scripts'), 10, 0);
60
-		$this->add_action("acf/field_group/admin_head",					array($this, 'field_group_admin_head'), 10, 0);
61
-		$this->add_action("acf/field_group/admin_footer",				array($this, 'field_group_admin_footer'), 10, 0);
59
+		$this->add_action("acf/field_group/admin_enqueue_scripts", array($this, 'field_group_admin_enqueue_scripts'), 10, 0);
60
+		$this->add_action("acf/field_group/admin_head", array($this, 'field_group_admin_head'), 10, 0);
61
+		$this->add_action("acf/field_group/admin_footer", array($this, 'field_group_admin_footer'), 10, 0);
62 62
 	}
63 63
 	
64 64
 	
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	
81 81
 	function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
82 82
 		
83
-		if( is_callable($function_to_add) )
83
+		if (is_callable($function_to_add))
84 84
 		{
85 85
 			add_filter($tag, $function_to_add, $priority, $accepted_args);
86 86
 		}
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	
106 106
 	function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
107 107
 		
108
-		if( is_callable($function_to_add) )
108
+		if (is_callable($function_to_add))
109 109
 		{
110 110
 			add_action($tag, $function_to_add, $priority, $accepted_args);
111 111
 		}
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	*  @return	$fields
126 126
 	*/
127 127
 	
128
-	function get_field_types( $fields ) {
128
+	function get_field_types($fields) {
129 129
 		
130 130
 		$l10n = array(
131 131
 			'basic'			=> __('Basic', 'acf'),
@@ -138,16 +138,16 @@  discard block
 block discarded – undo
138 138
 		
139 139
 		
140 140
 		// defaults
141
-		if( !$this->category )
141
+		if ( ! $this->category)
142 142
 		{
143 143
 			$this->category = 'basic';
144 144
 		}
145 145
 		
146 146
 		
147 147
 		// cat
148
-		if( isset($l10n[ $this->category ]) )
148
+		if (isset($l10n[$this->category]))
149 149
 		{
150
-			$cat = $l10n[ $this->category ];
150
+			$cat = $l10n[$this->category];
151 151
 		}
152 152
 		else
153 153
 		{
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 		
157 157
 		
158 158
 		// add to array
159
-		$fields[ $cat ][ $this->name ] = $this->label;
159
+		$fields[$cat][$this->name] = $this->label;
160 160
 		
161 161
 		
162 162
 		// return array
@@ -177,15 +177,15 @@  discard block
 block discarded – undo
177 177
 	*  @return	$field (array)
178 178
 	*/
179 179
 	
180
-	function get_valid_field( $field ) {
180
+	function get_valid_field($field) {
181 181
 		
182
-		if( !empty($this->defaults) )
182
+		if ( ! empty($this->defaults))
183 183
 		{
184
-			foreach( $this->defaults as $k => $v )
184
+			foreach ($this->defaults as $k => $v)
185 185
 			{
186
-				if( !isset($field[ $k ]) )
186
+				if ( ! isset($field[$k]))
187 187
 				{
188
-					$field[ $k ] = $v;
188
+					$field[$k] = $v;
189 189
 				}
190 190
 			}
191 191
 		}
@@ -207,11 +207,11 @@  discard block
 block discarded – undo
207 207
 	*  @return	$l10n (array)
208 208
 	*/
209 209
 	
210
-	function input_admin_l10n( $l10n ) {
210
+	function input_admin_l10n($l10n) {
211 211
 		
212
-		if( !empty($this->l10n) )
212
+		if ( ! empty($this->l10n))
213 213
 		{
214
-			$l10n[ $this->name ] = $this->l10n;
214
+			$l10n[$this->name] = $this->l10n;
215 215
 		}
216 216
 		
217 217
 		return $l10n;
Please login to merge, or discard this patch.
includes/acf/core/input.php 1 patch
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 *  @subpackage	Core
11 11
 */
12 12
 
13
-if( ! class_exists('acf_input') ) :
13
+if ( ! class_exists('acf_input')) :
14 14
 
15 15
 class acf_input {
16 16
 	
@@ -36,14 +36,14 @@  discard block
 block discarded – undo
36 36
 		
37 37
 		
38 38
 		// actions
39
-		add_action('acf/save_post', 							array($this, 'save_post'), 10, 1);
40
-		add_action('acf/input/admin_enqueue_scripts', 			array($this, 'admin_enqueue_scripts'), 10, 0);
41
-		add_action('acf/input/admin_footer', 					array($this, 'admin_footer'), 10, 0);
39
+		add_action('acf/save_post', array($this, 'save_post'), 10, 1);
40
+		add_action('acf/input/admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'), 10, 0);
41
+		add_action('acf/input/admin_footer', array($this, 'admin_footer'), 10, 0);
42 42
 		
43 43
 		
44 44
 		// ajax
45
-		add_action( 'wp_ajax_acf/validate_save_post',			array($this, 'ajax_validate_save_post') );
46
-		add_action( 'wp_ajax_nopriv_acf/validate_save_post',	array($this, 'ajax_validate_save_post') );
45
+		add_action('wp_ajax_acf/validate_save_post', array($this, 'ajax_validate_save_post'));
46
+		add_action('wp_ajax_nopriv_acf/validate_save_post', array($this, 'ajax_validate_save_post'));
47 47
 		
48 48
 	}
49 49
 	
@@ -68,18 +68,18 @@  discard block
 block discarded – undo
68 68
 		
69 69
 		
70 70
 		// determine action hooks
71
-		if( $pagenow == 'customize.php' ) {
71
+		if ($pagenow == 'customize.php') {
72 72
 			
73 73
 			$this->admin_head = 'customize_controls_print_scripts';
74 74
 			$this->admin_footer = 'customize_controls_print_footer_scripts';
75 75
 			
76
-		} elseif( $pagenow == 'wp-login.php' ) { 
76
+		} elseif ($pagenow == 'wp-login.php') { 
77 77
 			
78 78
 			$this->admin_enqueue_scripts = 'login_enqueue_scripts';
79 79
 			$this->admin_head = 'login_head';
80 80
 			$this->admin_footer = 'login_footer';
81 81
 			
82
-		} elseif( !is_admin() ) {
82
+		} elseif ( ! is_admin()) {
83 83
 			
84 84
 			$this->admin_enqueue_scripts = 'wp_enqueue_scripts';
85 85
 			$this->admin_head = 'wp_head';
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
 		
90 90
 		
91 91
 		// actions
92
-		acf_maybe_add_action($this->admin_enqueue_scripts, 	array($this, 'do_admin_enqueue_scripts'), 20 );
93
-		acf_maybe_add_action($this->admin_head, 			array($this, 'do_admin_head'), 20 );
94
-		acf_maybe_add_action($this->admin_footer, 			array($this, 'do_admin_footer'), 20 );
92
+		acf_maybe_add_action($this->admin_enqueue_scripts, array($this, 'do_admin_enqueue_scripts'), 20);
93
+		acf_maybe_add_action($this->admin_head, array($this, 'do_admin_head'), 20);
94
+		acf_maybe_add_action($this->admin_footer, array($this, 'do_admin_footer'), 20);
95 95
 				
96 96
 	}
97 97
 	
@@ -127,25 +127,25 @@  discard block
 block discarded – undo
127 127
 	*  @return	$post_id (int)
128 128
 	*/
129 129
 	
130
-	function save_post( $post_id = 0 ) {
130
+	function save_post($post_id = 0) {
131 131
 		
132 132
 		// bai learly if empty
133
-		if( empty($_POST['acf']) ) return;
133
+		if (empty($_POST['acf'])) return;
134 134
 		
135 135
 		
136 136
 		// save $_POST data
137
-		foreach( $_POST['acf'] as $k => $v ) {
137
+		foreach ($_POST['acf'] as $k => $v) {
138 138
 			
139 139
 			// get field
140
-			$field = acf_get_field( $k );
140
+			$field = acf_get_field($k);
141 141
 			
142 142
 			
143 143
 			// continue if no field
144
-			if( !$field ) continue;
144
+			if ( ! $field) continue;
145 145
 			
146 146
 			
147 147
 			// update
148
-			acf_update_value( $v, $post_id, $field );
148
+			acf_update_value($v, $post_id, $field);
149 149
 			
150 150
 		}
151 151
 	
@@ -203,9 +203,9 @@  discard block
 block discarded – undo
203 203
 		// options
204 204
 		$o = array(
205 205
 			'post_id'		=> $args['post_id'],
206
-			'nonce'			=> wp_create_nonce( 'acf_nonce' ),
206
+			'nonce'			=> wp_create_nonce('acf_nonce'),
207 207
 			'admin_url'		=> admin_url(),
208
-			'ajaxurl'		=> admin_url( 'admin-ajax.php' ),
208
+			'ajaxurl'		=> admin_url('admin-ajax.php'),
209 209
 			'ajax'			=> $args['ajax'],
210 210
 			'validation'	=> $args['validation'],
211 211
 			'wp_version'	=> $wp_version
@@ -213,15 +213,15 @@  discard block
 block discarded – undo
213 213
 		
214 214
 		
215 215
 		// l10n
216
-		$l10n = apply_filters( 'acf/input/admin_l10n', array(
217
-			'unload'				=> __('The changes you made will be lost if you navigate away from this page','acf'),
218
-			'expand_details' 		=> __('Expand Details','acf'),
219
-			'collapse_details' 		=> __('Collapse Details','acf'),
216
+		$l10n = apply_filters('acf/input/admin_l10n', array(
217
+			'unload'				=> __('The changes you made will be lost if you navigate away from this page', 'acf'),
218
+			'expand_details' 		=> __('Expand Details', 'acf'),
219
+			'collapse_details' 		=> __('Collapse Details', 'acf'),
220 220
 			'validation_successful'	=> __('Validation successful', 'acf'),
221 221
 			'validation_failed'		=> __('Validation failed', 'acf'),
222 222
 			'validation_failed_1'	=> __('1 field requires attention', 'acf'),
223 223
 			'validation_failed_2'	=> __('%d fields require attention', 'acf'),
224
-			'restricted'			=> __('Restricted','acf')
224
+			'restricted'			=> __('Restricted', 'acf')
225 225
 		));
226 226
 		
227 227
 		
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	function ajax_validate_save_post() {
261 261
 		
262 262
 		// bail early if _acfnonce is missing
263
-		if( !isset($_POST['_acfnonce']) ) {
263
+		if ( ! isset($_POST['_acfnonce'])) {
264 264
 			
265 265
 			wp_send_json_error();
266 266
 			
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 		
276 276
 		
277 277
 		// success
278
-		if( acf_validate_save_post() ) {
278
+		if (acf_validate_save_post()) {
279 279
 			
280 280
 			wp_send_json_success($json);
281 281
 			
@@ -348,15 +348,15 @@  discard block
 block discarded – undo
348 348
 function acf_enqueue_uploader() {
349 349
 	
350 350
 	// bail early if doing ajax
351
-	if( defined('DOING_AJAX') && DOING_AJAX ) return;
351
+	if (defined('DOING_AJAX') && DOING_AJAX) return;
352 352
 	
353 353
 	
354 354
 	// bail ealry if already run
355
-	if( acf_has_done('enqueue_uploader') ) return;
355
+	if (acf_has_done('enqueue_uploader')) return;
356 356
 	
357 357
 	
358 358
 	// enqueue media if user can upload
359
-	if( current_user_can('upload_files') ) {
359
+	if (current_user_can('upload_files')) {
360 360
 		
361 361
 		wp_enqueue_media();
362 362
 		
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 	
365 365
 	
366 366
 	// create dummy editor
367
-	?><div class="acf-hidden"><?php wp_editor( '', 'acf_content' ); ?></div><?php
367
+	?><div class="acf-hidden"><?php wp_editor('', 'acf_content'); ?></div><?php
368 368
 	
369 369
 }
370 370
 
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 *  @return	$post_id (int)
383 383
 */
384 384
 
385
-function acf_form_data( $args = array() ) {
385
+function acf_form_data($args = array()) {
386 386
 	
387 387
 	// make sure scripts and styles have been included
388 388
 	// case: front end bbPress edit user
@@ -391,10 +391,10 @@  discard block
 block discarded – undo
391 391
 	
392 392
 	// defaults
393 393
 	$args = acf_parse_args($args, array(
394
-		'post_id'		=> 0,		// ID of current post
395
-		'nonce'			=> 'post',	// nonce used for $_POST validation
396
-		'validation'	=> 1,		// runs AJAX validation
397
-		'ajax'			=> 0,		// fetches new field groups via AJAX
394
+		'post_id'		=> 0, // ID of current post
395
+		'nonce'			=> 'post', // nonce used for $_POST validation
396
+		'validation'	=> 1, // runs AJAX validation
397
+		'ajax'			=> 0, // fetches new field groups via AJAX
398 398
 	));
399 399
 	
400 400
 	
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 	
404 404
 	
405 405
 	// enqueue uploader if page allows AJAX fields to appear
406
-	if( $args['ajax'] ) {
406
+	if ($args['ajax']) {
407 407
 		
408 408
 		add_action('admin_footer', 'acf_enqueue_uploader', 1);
409 409
 		
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 	
412 412
 	?>
413 413
 	<div id="acf-form-data" class="acf-hidden">
414
-		<input type="hidden" name="_acfnonce" value="<?php echo wp_create_nonce( $args['nonce'] ); ?>" />
414
+		<input type="hidden" name="_acfnonce" value="<?php echo wp_create_nonce($args['nonce']); ?>" />
415 415
 		<input type="hidden" name="_acfchanged" value="0" />
416 416
 		<?php do_action('acf/input/form_data', $args); ?>
417 417
 	</div>
@@ -433,10 +433,10 @@  discard block
 block discarded – undo
433 433
 *  @return	$post_id (int)
434 434
 */
435 435
 
436
-function acf_save_post( $post_id = 0 ) {
436
+function acf_save_post($post_id = 0) {
437 437
 	
438 438
 	// bail early if no acf values
439
-	if( empty($_POST['acf']) ) return false;
439
+	if (empty($_POST['acf'])) return false;
440 440
 	
441 441
 	
442 442
 	// hook for 3rd party customization
@@ -462,22 +462,22 @@  discard block
 block discarded – undo
462 462
 *  @return	(boolean)
463 463
 */
464 464
 
465
-function acf_validate_save_post( $show_errors = false ) {
465
+function acf_validate_save_post($show_errors = false) {
466 466
 	
467 467
 	// validate required fields
468
-	if( !empty($_POST['acf']) ) {
468
+	if ( ! empty($_POST['acf'])) {
469 469
 		
470 470
 		$keys = array_keys($_POST['acf']);
471 471
 		
472 472
 		// loop through and save $_POST data
473
-		foreach( $keys as $key ) {
473
+		foreach ($keys as $key) {
474 474
 			
475 475
 			// get field
476
-			$field = acf_get_field( $key );
476
+			$field = acf_get_field($key);
477 477
 			
478 478
 			
479 479
 			// validate
480
-			acf_validate_value( $_POST['acf'][ $key ], $field, "acf[{$key}]" );
480
+			acf_validate_value($_POST['acf'][$key], $field, "acf[{$key}]");
481 481
 			
482 482
 		}
483 483
 		// foreach($fields as $key => $value)
@@ -490,21 +490,21 @@  discard block
 block discarded – undo
490 490
 	
491 491
 	
492 492
 	// check errors
493
-	if( $errors = acf_get_validation_errors() ) {
493
+	if ($errors = acf_get_validation_errors()) {
494 494
 		
495
-		if( $show_errors ) {
495
+		if ($show_errors) {
496 496
 			
497 497
 			$message = '<h2>Validation failed</h2><ul>';
498 498
 			
499
-			foreach( $errors as $error ) {
499
+			foreach ($errors as $error) {
500 500
 				
501
-				$message .= '<li>' . $error['message'] . '</li>';
501
+				$message .= '<li>'.$error['message'].'</li>';
502 502
 				
503 503
 			}
504 504
 			
505 505
 			$message .= '</ul>';
506 506
 			
507
-			wp_die( $message, 'Validation failed' );
507
+			wp_die($message, 'Validation failed');
508 508
 			
509 509
 		}
510 510
 		
@@ -534,18 +534,18 @@  discard block
 block discarded – undo
534 534
 *  @return	(boolean)
535 535
 */
536 536
 
537
-function acf_validate_value( $value, $field, $input ) {
537
+function acf_validate_value($value, $field, $input) {
538 538
 	
539 539
 	// vars
540 540
 	$valid = true;
541
-	$message = sprintf( __( '%s value is required', 'acf' ), $field['label'] );
541
+	$message = sprintf(__('%s value is required', 'acf'), $field['label']);
542 542
 	
543 543
 	
544 544
 	// valid
545
-	if( $field['required'] ) {
545
+	if ($field['required']) {
546 546
 		
547 547
 		// valid is set to false if the value is empty, but allow 0 as a valid value
548
-		if( empty($value) && !is_numeric($value) ) {
548
+		if (empty($value) && ! is_numeric($value)) {
549 549
 			
550 550
 			$valid = false;
551 551
 			
@@ -555,14 +555,14 @@  discard block
 block discarded – undo
555 555
 	
556 556
 	
557 557
 	// filter for 3rd party customization
558
-	$valid = apply_filters( "acf/validate_value", $valid, $value, $field, $input );
559
-	$valid = apply_filters( "acf/validate_value/type={$field['type']}", $valid, $value, $field, $input );
560
-	$valid = apply_filters( "acf/validate_value/name={$field['name']}", $valid, $value, $field, $input );
561
-	$valid = apply_filters( "acf/validate_value/key={$field['key']}", $valid, $value, $field, $input );
558
+	$valid = apply_filters("acf/validate_value", $valid, $value, $field, $input);
559
+	$valid = apply_filters("acf/validate_value/type={$field['type']}", $valid, $value, $field, $input);
560
+	$valid = apply_filters("acf/validate_value/name={$field['name']}", $valid, $value, $field, $input);
561
+	$valid = apply_filters("acf/validate_value/key={$field['key']}", $valid, $value, $field, $input);
562 562
 	
563 563
 	
564 564
 	// allow $valid to be a custom error message
565
-	if( !empty($valid) && is_string($valid) ) {
565
+	if ( ! empty($valid) && is_string($valid)) {
566 566
 		
567 567
 		$message = $valid;
568 568
 		$valid = false;
@@ -570,9 +570,9 @@  discard block
 block discarded – undo
570 570
 	}
571 571
 	
572 572
 	
573
-	if( !$valid ) {
573
+	if ( ! $valid) {
574 574
 		
575
-		acf_add_validation_error( $input, $message );
575
+		acf_add_validation_error($input, $message);
576 576
 		return false;
577 577
 		
578 578
 	}
@@ -598,10 +598,10 @@  discard block
 block discarded – undo
598 598
 *  @return	$post_id (int)
599 599
 */
600 600
 
601
-function acf_add_validation_error( $input, $message = '' ) {
601
+function acf_add_validation_error($input, $message = '') {
602 602
 	
603 603
 	// instantiate array if empty
604
-	if( empty($GLOBALS['acf_validation_errors']) ) {
604
+	if (empty($GLOBALS['acf_validation_errors'])) {
605 605
 		
606 606
 		$GLOBALS['acf_validation_errors'] = array();
607 607
 		
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
 function acf_get_validation_errors() {
634 634
 	
635 635
 	// bail early if no errors
636
-	if( empty($GLOBALS['acf_validation_errors']) ) return false;
636
+	if (empty($GLOBALS['acf_validation_errors'])) return false;
637 637
 	
638 638
 	
639 639
 	// return
Please login to merge, or discard this patch.
includes/acf/core/json.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -5,17 +5,17 @@  discard block
 block discarded – undo
5 5
 	function __construct() {
6 6
 		
7 7
 		// update setting
8
-		acf_update_setting('save_json', get_stylesheet_directory() . '/acf-json');
9
-		acf_append_setting('load_json', get_stylesheet_directory() . '/acf-json');
8
+		acf_update_setting('save_json', get_stylesheet_directory().'/acf-json');
9
+		acf_append_setting('load_json', get_stylesheet_directory().'/acf-json');
10 10
 		
11 11
 		
12 12
 		// actions
13
-		add_action('acf/update_field_group',		array($this, 'update_field_group'), 10, 5);
14
-		add_action('acf/duplicate_field_group',		array($this, 'update_field_group'), 10, 5);
15
-		add_action('acf/untrash_field_group',		array($this, 'update_field_group'), 10, 5);
16
-		add_action('acf/trash_field_group',			array($this, 'delete_field_group'), 10, 5);
17
-		add_action('acf/delete_field_group',		array($this, 'delete_field_group'), 10, 5);
18
-		add_action('acf/include_fields', 			array($this, 'include_fields'), 10, 5);
13
+		add_action('acf/update_field_group', array($this, 'update_field_group'), 10, 5);
14
+		add_action('acf/duplicate_field_group', array($this, 'update_field_group'), 10, 5);
15
+		add_action('acf/untrash_field_group', array($this, 'update_field_group'), 10, 5);
16
+		add_action('acf/trash_field_group', array($this, 'delete_field_group'), 10, 5);
17
+		add_action('acf/delete_field_group', array($this, 'delete_field_group'), 10, 5);
18
+		add_action('acf/include_fields', array($this, 'include_fields'), 10, 5);
19 19
 		
20 20
 	}
21 21
 	
@@ -33,10 +33,10 @@  discard block
 block discarded – undo
33 33
 	*  @return	n/a
34 34
 	*/
35 35
 	
36
-	function update_field_group( $field_group ) {
36
+	function update_field_group($field_group) {
37 37
 		
38 38
 		// validate
39
-		if( !acf_get_setting('json') ) {
39
+		if ( ! acf_get_setting('json')) {
40 40
 		
41 41
 			return;
42 42
 			
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
 		
45 45
 		
46 46
 		// get fields
47
-		$field_group['fields'] = acf_get_fields( $field_group );
47
+		$field_group['fields'] = acf_get_fields($field_group);
48 48
 		
49 49
 		
50 50
 		// save file
51
-		acf_write_json_field_group( $field_group );
51
+		acf_write_json_field_group($field_group);
52 52
 			
53 53
 	}
54 54
 	
@@ -66,17 +66,17 @@  discard block
 block discarded – undo
66 66
 	*  @return	n/a
67 67
 	*/
68 68
 	
69
-	function delete_field_group( $field_group ) {
69
+	function delete_field_group($field_group) {
70 70
 		
71 71
 		// validate
72
-		if( !acf_get_setting('json') ) {
72
+		if ( ! acf_get_setting('json')) {
73 73
 		
74 74
 			return;
75 75
 			
76 76
 		}
77 77
 		
78 78
 		
79
-		acf_delete_json_field_group( $field_group['key'] );
79
+		acf_delete_json_field_group($field_group['key']);
80 80
 		
81 81
 	}
82 82
 		
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	function include_fields() {
98 98
 		
99 99
 		// validate
100
-		if( !acf_get_setting('json') ) {
100
+		if ( ! acf_get_setting('json')) {
101 101
 		
102 102
 			return;
103 103
 			
@@ -109,26 +109,26 @@  discard block
 block discarded – undo
109 109
 		
110 110
 		
111 111
 		// loop through and add to cache
112
-		foreach( $paths as $path ) {
112
+		foreach ($paths as $path) {
113 113
 			
114 114
 			// remove trailing slash
115
-			$path = untrailingslashit( $path );
115
+			$path = untrailingslashit($path);
116 116
 		
117 117
 		
118 118
 			// check that path exists
119
-			if( !file_exists( $path ) ) {
119
+			if ( ! file_exists($path)) {
120 120
 			
121 121
 				continue;
122 122
 				
123 123
 			}
124 124
 			
125 125
 			
126
-			$dir = opendir( $path );
126
+			$dir = opendir($path);
127 127
 	    
128
-		    while(false !== ( $file = readdir($dir)) ) {
128
+		    while (false !== ($file = readdir($dir))) {
129 129
 		    
130 130
 		    	// only json files
131
-		    	if( strpos($file, '.json') === false ) {
131
+		    	if (strpos($file, '.json') === false) {
132 132
 		    	
133 133
 			    	continue;
134 134
 			    	
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 		    	
141 141
 		    	
142 142
 		    	// validate json
143
-		    	if( empty($json) ) {
143
+		    	if (empty($json)) {
144 144
 			    	
145 145
 			    	continue;
146 146
 			    	
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 		    	
157 157
 		    	
158 158
 		    	// add field group
159
-		    	acf_add_local_field_group( $json );
159
+		    	acf_add_local_field_group($json);
160 160
 		        
161 161
 		    }
162 162
 		    
@@ -182,24 +182,24 @@  discard block
 block discarded – undo
182 182
 *  @return	(boolean)
183 183
 */
184 184
 
185
-function acf_write_json_field_group( $field_group ) {
185
+function acf_write_json_field_group($field_group) {
186 186
 	
187 187
 	// vars
188 188
 	$path = acf_get_setting('save_json');
189
-	$file = $field_group['key'] . '.json';
189
+	$file = $field_group['key'].'.json';
190 190
 	
191 191
 	
192 192
 	// remove trailing slash
193
-	$path = untrailingslashit( $path );
193
+	$path = untrailingslashit($path);
194 194
 	
195 195
 	
196 196
 	// bail early if dir does not exist
197
-	if( !is_writable($path) ) return false;
197
+	if ( ! is_writable($path)) return false;
198 198
 	
199 199
 	
200 200
 	// prepare for export
201
-	$id = acf_extract_var( $field_group, 'ID' );
202
-	$field_group = acf_prepare_field_group_for_export( $field_group );
201
+	$id = acf_extract_var($field_group, 'ID');
202
+	$field_group = acf_prepare_field_group_for_export($field_group);
203 203
 	
204 204
 
205 205
 	// add modified time
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	
209 209
 	// write file
210 210
 	$f = fopen("{$path}/{$file}", 'w');
211
-	fwrite($f, acf_json_encode( $field_group ));
211
+	fwrite($f, acf_json_encode($field_group));
212 212
 	fclose($f);
213 213
 	
214 214
 	
@@ -231,19 +231,19 @@  discard block
 block discarded – undo
231 231
 *  @return	(boolean)
232 232
 */
233 233
 
234
-function acf_delete_json_field_group( $key ) {
234
+function acf_delete_json_field_group($key) {
235 235
 	
236 236
 	// vars
237 237
 	$path = acf_get_setting('save_json');
238
-	$file = $key . '.json';
238
+	$file = $key.'.json';
239 239
 	
240 240
 	
241 241
 	// remove trailing slash
242
-	$path = untrailingslashit( $path );
242
+	$path = untrailingslashit($path);
243 243
 	
244 244
 	
245 245
 	// bail early if file does not exist
246
-	if( !is_readable("{$path}/{$file}") ) {
246
+	if ( ! is_readable("{$path}/{$file}")) {
247 247
 	
248 248
 		return false;
249 249
 		
Please login to merge, or discard this patch.
includes/acf/core/local.php 1 patch
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -3,16 +3,16 @@  discard block
 block discarded – undo
3 3
 class acf_local {
4 4
 	
5 5
 	// vars
6
-	var $enabled	= true,
6
+	var $enabled = true,
7 7
 		$groups 	= array(),
8 8
 		$fields 	= array(),
9
-		$parents 	= array();
9
+		$parents = array();
10 10
 		
11 11
 		
12 12
 	function __construct() {
13 13
 		
14 14
 		add_filter('acf/get_field_groups', array($this, 'get_field_groups'), 10, 1);
15
-		add_action('acf/delete_field', 	array($this, 'delete_field'), 10, 1);
15
+		add_action('acf/delete_field', array($this, 'delete_field'), 10, 1);
16 16
 		
17 17
 	}
18 18
 	
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
30 30
 	*  @return	$field_groups
31 31
 	*/
32 32
 	
33
-	function get_field_groups( $field_groups ) {
33
+	function get_field_groups($field_groups) {
34 34
 		
35 35
 		// validate
36
-		if( !acf_have_local_field_groups() ) {
36
+		if ( ! acf_have_local_field_groups()) {
37 37
 			
38 38
 			return $field_groups;
39 39
 			
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
 		
47 47
 		
48 48
 		// populate ignore list
49
-		if( !empty($field_groups) ) {
49
+		if ( ! empty($field_groups)) {
50 50
 			
51
-			foreach( $field_groups as $k => $group ) {
51
+			foreach ($field_groups as $k => $group) {
52 52
 
53 53
 				$ignore[] = $group['key'];
54 54
 				
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
60 60
 		// append field groups
61 61
 		$groups = acf_get_local_field_groups();
62 62
 		
63
-		foreach( $groups as $group ) {
63
+		foreach ($groups as $group) {
64 64
 			
65 65
 			// is ignore
66
-			if( in_array($group['key'], $ignore) ) {
66
+			if (in_array($group['key'], $ignore)) {
67 67
 				
68 68
 				continue;
69 69
 					
@@ -78,20 +78,20 @@  discard block
 block discarded – undo
78 78
 		
79 79
 		
80 80
 		// order field groups based on menu_order, title
81
-		if( $added ) {
81
+		if ($added) {
82 82
 			
83 83
 			$menu_order = array();
84 84
 			$title = array();
85 85
 			
86
-			foreach( $field_groups as $key => $row ) {
86
+			foreach ($field_groups as $key => $row) {
87 87
 				
88
-			    $menu_order[ $key ] = $row['menu_order'];
89
-			    $title[ $key ] = $row['title'];
88
+			    $menu_order[$key] = $row['menu_order'];
89
+			    $title[$key] = $row['title'];
90 90
 			}
91 91
 			
92 92
 			
93 93
 			// sort the array with menu_order ascending
94
-			array_multisort( $menu_order, SORT_ASC, $title, SORT_ASC, $field_groups );
94
+			array_multisort($menu_order, SORT_ASC, $title, SORT_ASC, $field_groups);
95 95
 				
96 96
 		}
97 97
 		
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
 	*  @return	$post_id (int)
116 116
 	*/
117 117
 	
118
-	function delete_field( $field ) {
118
+	function delete_field($field) {
119 119
 		
120
-		$this->remove_field( $field['key'] );
120
+		$this->remove_field($field['key']);
121 121
 		
122 122
 	}
123 123
 	
@@ -135,14 +135,14 @@  discard block
 block discarded – undo
135 135
 	*  @return	n/a
136 136
 	*/
137 137
 	
138
-	function add_field_group( $field_group ) {
138
+	function add_field_group($field_group) {
139 139
 		
140 140
 		// validate
141 141
 		$field_group = acf_get_valid_field_group($field_group);
142 142
 		
143 143
 		
144 144
 		// don't allow overrides
145
-		if( acf_is_local_field_group($field_group['key']) ) {
145
+		if (acf_is_local_field_group($field_group['key'])) {
146 146
 			
147 147
 			return;	
148 148
 			
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 		
151 151
 		
152 152
 		// add local
153
-		if( empty($field_group['local']) ) {
153
+		if (empty($field_group['local'])) {
154 154
 			
155 155
 			$field_group['local'] = 'php';
156 156
 			
@@ -162,18 +162,18 @@  discard block
 block discarded – undo
162 162
 		
163 163
 		
164 164
 		// format fields
165
-		$fields = acf_prepare_fields_for_import( $fields );
165
+		$fields = acf_prepare_fields_for_import($fields);
166 166
 		
167 167
 		
168 168
 		// add field group
169
-		$this->groups[ $field_group['key'] ] = $field_group;
169
+		$this->groups[$field_group['key']] = $field_group;
170 170
 		
171 171
 		
172 172
 		// add fields
173
-		foreach( $fields as $field ) {
173
+		foreach ($fields as $field) {
174 174
 			
175 175
 			// add parent
176
-			if( empty($field['parent']) ) {
176
+			if (empty($field['parent'])) {
177 177
 				
178 178
 				$field['parent'] = $field_group['key'];
179 179
 				
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 			
182 182
 			
183 183
 			// add field
184
-			$this->add_field( $field );
184
+			$this->add_field($field);
185 185
 			
186 186
 		}
187 187
 		
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	*  @return	n/a
202 202
 	*/
203 203
 	
204
-	function add_field( $field ) {
204
+	function add_field($field) {
205 205
 		
206 206
 		// vars
207 207
 		// - allow for the very unexpected case where no key or parent exist
@@ -210,20 +210,20 @@  discard block
 block discarded – undo
210 210
 		
211 211
 		
212 212
 		// add parent reference
213
-		$this->add_parent_reference( $parent, $key );
213
+		$this->add_parent_reference($parent, $key);
214 214
 		
215 215
 		
216 216
 		// add in menu order
217
-		$field['menu_order'] = count( $this->parents[ $parent ] ) - 1;
217
+		$field['menu_order'] = count($this->parents[$parent]) - 1;
218 218
 		
219 219
 		
220 220
 		// add field
221
-		$this->fields[ $key ] = $field;
221
+		$this->fields[$key] = $field;
222 222
 		
223 223
 		
224 224
 		// clear cache
225
-		wp_cache_delete( "get_field/key={$key}", 'acf' );
226
-		wp_cache_delete( "get_fields/parent={$parent}", 'acf' );
225
+		wp_cache_delete("get_field/key={$key}", 'acf');
226
+		wp_cache_delete("get_fields/parent={$parent}", 'acf');
227 227
 		
228 228
 	}
229 229
 	
@@ -241,38 +241,38 @@  discard block
 block discarded – undo
241 241
 	*  @return	n/a
242 242
 	*/
243 243
 	
244
-	function remove_field( $key ) {
244
+	function remove_field($key) {
245 245
 		
246 246
 		// get field
247
-		$field = acf_get_field( $key );
247
+		$field = acf_get_field($key);
248 248
 		
249 249
 		
250 250
 		// remove parent reference
251
-		$this->remove_parent_reference( $field['parent'], $field['key'] );
251
+		$this->remove_parent_reference($field['parent'], $field['key']);
252 252
 		
253 253
 		
254 254
 		// remove field
255
-		unset( $this->fields[ $key ] );
255
+		unset($this->fields[$key]);
256 256
 		
257 257
 		
258 258
 		// remove children
259
-		if( acf_have_local_fields( $key) ) {
259
+		if (acf_have_local_fields($key)) {
260 260
 			
261
-			acf_remove_local_fields( $key );
261
+			acf_remove_local_fields($key);
262 262
 			
263 263
 		}
264 264
 		
265 265
 	}
266 266
 	
267 267
 	
268
-	function add_parent_reference( $parent_key, $field_key ) {
268
+	function add_parent_reference($parent_key, $field_key) {
269 269
 		
270 270
 		// create array
271
-		if( !isset($this->parents[ $parent_key ]) ) {
271
+		if ( ! isset($this->parents[$parent_key])) {
272 272
 			
273
-			$this->parents[ $parent_key ] = array();
273
+			$this->parents[$parent_key] = array();
274 274
 			
275
-		} elseif( in_array($field_key, $this->parents[ $parent_key ]) ) {
275
+		} elseif (in_array($field_key, $this->parents[$parent_key])) {
276 276
 			
277 277
 			// bail early if already in array
278 278
 			return false;
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 		
282 282
 		
283 283
 		// append
284
-		$this->parents[ $parent_key ][] = $field_key;
284
+		$this->parents[$parent_key][] = $field_key;
285 285
 		
286 286
 		
287 287
 		// return
@@ -290,10 +290,10 @@  discard block
 block discarded – undo
290 290
 	}
291 291
 	
292 292
 	
293
-	function remove_parent_reference( $parent_key, $field_key ) {
293
+	function remove_parent_reference($parent_key, $field_key) {
294 294
 		
295 295
 		// bail early if no parent
296
-		if( !isset($this->parents[ $parent_key ]) ) {
296
+		if ( ! isset($this->parents[$parent_key])) {
297 297
 			
298 298
 			return false;
299 299
 			
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 		
302 302
 		
303 303
 		// remove
304
-		$this->parents[ $parent_key ] = array_diff($this->parents[ $parent_key ], array($field_key));
304
+		$this->parents[$parent_key] = array_diff($this->parents[$parent_key], array($field_key));
305 305
 		
306 306
 		
307 307
 		// return
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 	
333 333
 	
334 334
 	// instantiate
335
-	if( !isset($acf_local) )
335
+	if ( ! isset($acf_local))
336 336
 	{
337 337
 		$acf_local = new acf_local();
338 338
 	}
@@ -399,14 +399,14 @@  discard block
 block discarded – undo
399 399
 function acf_is_local_enabled() {
400 400
 	
401 401
 	// validate
402
-	if( !acf_get_setting('local') ) {
402
+	if ( ! acf_get_setting('local')) {
403 403
 		
404 404
 		return false;
405 405
 		
406 406
 	}
407 407
 	
408 408
 	
409
-	if( !acf_local()->enabled ) {
409
+	if ( ! acf_local()->enabled) {
410 410
 		
411 411
 		return false;
412 412
 		
@@ -432,20 +432,20 @@  discard block
 block discarded – undo
432 432
 *  @return	(int)
433 433
 */
434 434
 
435
-function acf_count_local_field_groups( $type = '' ) {
435
+function acf_count_local_field_groups($type = '') {
436 436
 	
437 437
 	// vars
438 438
 	$count = 0;
439 439
 	
440 440
 	
441 441
 	// check for groups
442
-	if( !empty(acf_local()->groups) ) {
442
+	if ( ! empty(acf_local()->groups)) {
443 443
 		
444 444
 		// acf_local
445
-		foreach( acf_local()->groups as $group ) {
445
+		foreach (acf_local()->groups as $group) {
446 446
 			
447 447
 			// ignore if not specific type
448
-			if( $type && $group['local'] != $type ) {
448
+			if ($type && $group['local'] != $type) {
449 449
 				
450 450
 				continue;
451 451
 				
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
 function acf_have_local_field_groups() {
481 481
 	
482 482
 	// validate
483
-	if( !acf_is_local_enabled() ) {
483
+	if ( ! acf_is_local_enabled()) {
484 484
 		
485 485
 		return false;
486 486
 		
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 	
489 489
 	
490 490
 	// check for groups
491
-	if( !empty(acf_local()->groups) ) {
491
+	if ( ! empty(acf_local()->groups)) {
492 492
 		
493 493
 		return true;
494 494
 		
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 function acf_get_local_field_groups() {
518 518
 	
519 519
 	// bail early if no groups
520
-	if( !acf_have_local_field_groups() ) {
520
+	if ( ! acf_have_local_field_groups()) {
521 521
 		
522 522
 		return false;
523 523
 		
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 	
530 530
 	
531 531
 	// acf_local
532
-	foreach( acf_local()->groups as $group ) {
532
+	foreach (acf_local()->groups as $group) {
533 533
 		
534 534
 		$groups[] = $group;
535 535
 		
@@ -555,9 +555,9 @@  discard block
 block discarded – undo
555 555
 *  @return	$post_id (int)
556 556
 */
557 557
 
558
-function acf_add_local_field_group( $field_group ) {
558
+function acf_add_local_field_group($field_group) {
559 559
 	
560
-	acf_local()->add_field_group( $field_group );
560
+	acf_local()->add_field_group($field_group);
561 561
 	
562 562
 }
563 563
 
@@ -575,10 +575,10 @@  discard block
 block discarded – undo
575 575
 *  @return	(bolean)
576 576
 */
577 577
 
578
-function acf_is_local_field_group( $key ) {
578
+function acf_is_local_field_group($key) {
579 579
 	
580 580
 	// validate
581
-	if( !acf_is_local_enabled() ) {
581
+	if ( ! acf_is_local_enabled()) {
582 582
 		
583 583
 		return false;
584 584
 		
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 	
587 587
 	
588 588
 	// check groups
589
-	if( isset( acf_local()->groups[ $key ] ) ) {
589
+	if (isset(acf_local()->groups[$key])) {
590 590
 		
591 591
 		return true;
592 592
 		
@@ -612,10 +612,10 @@  discard block
 block discarded – undo
612 612
 *  @return	(bolean)
613 613
 */
614 614
 
615
-function acf_get_local_field_group( $key ) {
615
+function acf_get_local_field_group($key) {
616 616
 	
617 617
 	// bail early if no group
618
-	if( !acf_is_local_field_group($key) ) {
618
+	if ( ! acf_is_local_field_group($key)) {
619 619
 		
620 620
 		return false;
621 621
 		
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
 	
624 624
 	
625 625
 	// return
626
-	return acf_local()->groups[ $key ];
626
+	return acf_local()->groups[$key];
627 627
 	
628 628
 }
629 629
 
@@ -641,9 +641,9 @@  discard block
 block discarded – undo
641 641
 *  @return	$post_id (int)
642 642
 */
643 643
 
644
-function acf_add_local_field( $field ) {
644
+function acf_add_local_field($field) {
645 645
 	
646
-	acf_local()->add_field( $field );
646
+	acf_local()->add_field($field);
647 647
 	
648 648
 }
649 649
 
@@ -661,9 +661,9 @@  discard block
 block discarded – undo
661 661
 *  @return	$post_id (int)
662 662
 */
663 663
 
664
-function acf_remove_local_field( $key ) {
664
+function acf_remove_local_field($key) {
665 665
 	
666
-	acf_local()->remove_field( $key );
666
+	acf_local()->remove_field($key);
667 667
 	
668 668
 }
669 669
 
@@ -681,10 +681,10 @@  discard block
 block discarded – undo
681 681
 *  @return	(bolean)
682 682
 */
683 683
 
684
-function acf_is_local_field( $key ) {
684
+function acf_is_local_field($key) {
685 685
 	
686 686
 	// validate
687
-	if( !acf_is_local_enabled() ) {
687
+	if ( ! acf_is_local_enabled()) {
688 688
 		
689 689
 		return false;
690 690
 		
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 	
693 693
 	
694 694
 	// check fields
695
-	if( isset( acf_local()->fields[ $key ] ) ) {
695
+	if (isset(acf_local()->fields[$key])) {
696 696
 		
697 697
 		return true;
698 698
 		
@@ -718,10 +718,10 @@  discard block
 block discarded – undo
718 718
 *  @return	(bolean)
719 719
 */
720 720
 
721
-function acf_get_local_field( $key ) {
721
+function acf_get_local_field($key) {
722 722
 	
723 723
 	// bail early if no field
724
-	if( !acf_is_local_field($key) ) {
724
+	if ( ! acf_is_local_field($key)) {
725 725
 		
726 726
 		return false;
727 727
 		
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
 	
730 730
 	
731 731
 	// return
732
-	return acf_local()->fields[ $key ];
732
+	return acf_local()->fields[$key];
733 733
 	
734 734
 }
735 735
 
@@ -747,12 +747,12 @@  discard block
 block discarded – undo
747 747
 *  @return	(int)
748 748
 */
749 749
 
750
-function acf_count_local_fields( $key ) {
750
+function acf_count_local_fields($key) {
751 751
 	
752 752
 	// check for fields
753
-	if( !empty(acf_local()->parents[ $key ]) ) {
753
+	if ( ! empty(acf_local()->parents[$key])) {
754 754
 		
755
-		return count( acf_local()->parents[ $key ] );
755
+		return count(acf_local()->parents[$key]);
756 756
 		
757 757
 	}
758 758
 	
@@ -776,10 +776,10 @@  discard block
 block discarded – undo
776 776
 *  @return	(bolean)
777 777
 */
778 778
 
779
-function acf_have_local_fields( $key ) {
779
+function acf_have_local_fields($key) {
780 780
 
781 781
 	// validate
782
-	if( !acf_is_local_enabled() ) {
782
+	if ( ! acf_is_local_enabled()) {
783 783
 		
784 784
 		return false;
785 785
 		
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 	
788 788
 	
789 789
 	// check parents
790
-	if( isset( acf_local()->parents[ $key ] ) ) {
790
+	if (isset(acf_local()->parents[$key])) {
791 791
 		
792 792
 		return true;
793 793
 		
@@ -813,10 +813,10 @@  discard block
 block discarded – undo
813 813
 *  @return	(bolean)
814 814
 */
815 815
 
816
-function acf_get_local_fields( $parent ) {
816
+function acf_get_local_fields($parent) {
817 817
 	
818 818
 	// bail early if no parent
819
-	if( !acf_have_local_fields($parent) ) {
819
+	if ( ! acf_have_local_fields($parent)) {
820 820
 		
821 821
 		return false;
822 822
 		
@@ -828,9 +828,9 @@  discard block
 block discarded – undo
828 828
 	
829 829
 	
830 830
 	// append
831
-	foreach( acf_local()->parents[ $parent ] as $key ) {
831
+	foreach (acf_local()->parents[$parent] as $key) {
832 832
 		
833
-		$fields[] = acf_get_field( $key );
833
+		$fields[] = acf_get_field($key);
834 834
 		
835 835
 	}
836 836
 	
@@ -854,19 +854,19 @@  discard block
 block discarded – undo
854 854
 *  @return	(bolean)
855 855
 */
856 856
 
857
-function acf_remove_local_fields( $parent ) {
857
+function acf_remove_local_fields($parent) {
858 858
 	
859 859
 	// bail early if no reference
860
-	if( empty( acf_local()->parents[ $parent ] ) ) {
860
+	if (empty(acf_local()->parents[$parent])) {
861 861
 		
862 862
 		return false;
863 863
 		
864 864
 	}
865 865
 	
866 866
 	
867
-	foreach( acf_local()->parents[ $parent ] as $key ) {
867
+	foreach (acf_local()->parents[$parent] as $key) {
868 868
 		
869
-		acf_remove_local_field( $key );
869
+		acf_remove_local_field($key);
870 870
 	
871 871
 	}
872 872
 	
Please login to merge, or discard this patch.
includes/acf/core/location.php 1 patch
Spacing   +210 added lines, -210 removed lines patch added patch discarded remove patch
@@ -18,33 +18,33 @@  discard block
 block discarded – undo
18 18
 	function __construct() {
19 19
 		
20 20
 		// Post
21
-		add_filter( 'acf/location/rule_match/post_type',		array($this, 'rule_match_post_type'), 10, 3 );
22
-		add_filter( 'acf/location/rule_match/post',				array($this, 'rule_match_post'), 10, 3 );
23
-		add_filter( 'acf/location/rule_match/post_category',	array($this, 'rule_match_post_taxonomy'), 10, 3 );
24
-		add_filter( 'acf/location/rule_match/post_format',		array($this, 'rule_match_post_format'), 10, 3 );
25
-		add_filter( 'acf/location/rule_match/post_status',		array($this, 'rule_match_post_status'), 10, 3 );
26
-		add_filter( 'acf/location/rule_match/post_taxonomy',	array($this, 'rule_match_post_taxonomy'), 10, 3 );
21
+		add_filter('acf/location/rule_match/post_type', array($this, 'rule_match_post_type'), 10, 3);
22
+		add_filter('acf/location/rule_match/post', array($this, 'rule_match_post'), 10, 3);
23
+		add_filter('acf/location/rule_match/post_category', array($this, 'rule_match_post_taxonomy'), 10, 3);
24
+		add_filter('acf/location/rule_match/post_format', array($this, 'rule_match_post_format'), 10, 3);
25
+		add_filter('acf/location/rule_match/post_status', array($this, 'rule_match_post_status'), 10, 3);
26
+		add_filter('acf/location/rule_match/post_taxonomy', array($this, 'rule_match_post_taxonomy'), 10, 3);
27 27
 		
28 28
 		
29 29
 		// Page
30
-		add_filter( 'acf/location/rule_match/page',				array($this, 'rule_match_post'), 10, 3 );
31
-		add_filter( 'acf/location/rule_match/page_type',		array($this, 'rule_match_page_type'), 10, 3 );
32
-		add_filter( 'acf/location/rule_match/page_parent',		array($this, 'rule_match_page_parent'), 10, 3 );
33
-		add_filter( 'acf/location/rule_match/page_template',	array($this, 'rule_match_page_template'), 10, 3 );
30
+		add_filter('acf/location/rule_match/page', array($this, 'rule_match_post'), 10, 3);
31
+		add_filter('acf/location/rule_match/page_type', array($this, 'rule_match_page_type'), 10, 3);
32
+		add_filter('acf/location/rule_match/page_parent', array($this, 'rule_match_page_parent'), 10, 3);
33
+		add_filter('acf/location/rule_match/page_template', array($this, 'rule_match_page_template'), 10, 3);
34 34
 		
35 35
 		
36 36
 		// User
37
-		add_filter( 'acf/location/rule_match/current_user',		array($this, 'rule_match_current_user'), 10, 3 );
38
-		add_filter( 'acf/location/rule_match/current_user_role',	array($this, 'rule_match_current_user_role'), 10, 3 );
39
-		add_filter( 'acf/location/rule_match/user_form',		array($this, 'rule_match_user_form'), 10, 3 );
40
-		add_filter( 'acf/location/rule_match/user_role',		array($this, 'rule_match_user_role'), 10, 3 );
37
+		add_filter('acf/location/rule_match/current_user', array($this, 'rule_match_current_user'), 10, 3);
38
+		add_filter('acf/location/rule_match/current_user_role', array($this, 'rule_match_current_user_role'), 10, 3);
39
+		add_filter('acf/location/rule_match/user_form', array($this, 'rule_match_user_form'), 10, 3);
40
+		add_filter('acf/location/rule_match/user_role', array($this, 'rule_match_user_role'), 10, 3);
41 41
 		
42 42
 		
43 43
 		// Form
44
-		add_filter( 'acf/location/rule_match/taxonomy',			array($this, 'rule_match_taxonomy'), 10, 3 );
45
-		add_filter( 'acf/location/rule_match/attachment',		array($this, 'rule_match_attachment'), 10, 3 );
46
-		add_filter( 'acf/location/rule_match/comment',			array($this, 'rule_match_comment'), 10, 3 );
47
-		add_filter( 'acf/location/rule_match/widget',			array($this, 'rule_match_widget'), 10, 3 );
44
+		add_filter('acf/location/rule_match/taxonomy', array($this, 'rule_match_taxonomy'), 10, 3);
45
+		add_filter('acf/location/rule_match/attachment', array($this, 'rule_match_attachment'), 10, 3);
46
+		add_filter('acf/location/rule_match/comment', array($this, 'rule_match_comment'), 10, 3);
47
+		add_filter('acf/location/rule_match/widget', array($this, 'rule_match_widget'), 10, 3);
48 48
 		
49 49
 	}
50 50
 		
@@ -63,33 +63,33 @@  discard block
 block discarded – undo
63 63
 	*  @return	$options (array)
64 64
 	*/
65 65
 	
66
-	function rule_match_post_type( $match, $rule, $options ) {
66
+	function rule_match_post_type($match, $rule, $options) {
67 67
 		
68 68
 		// vars
69 69
 		$post_type = $options['post_type'];
70 70
 		
71 71
 		
72 72
 		// find post type for current post
73
-		if( !$post_type ) {
73
+		if ( ! $post_type) {
74 74
 			
75
-			if( !$options['post_id'] ) {
75
+			if ( ! $options['post_id']) {
76 76
 				
77 77
 				return false;
78 78
 				
79 79
 			}
80 80
 			
81
-			$post_type = get_post_type( $options['post_id'] );
81
+			$post_type = get_post_type($options['post_id']);
82 82
 		}
83 83
 		
84 84
 		
85 85
 		// compare
86
-        if( $rule['operator'] == "==" ) {
86
+        if ($rule['operator'] == "==") {
87 87
         	
88
-        	$match = ( $post_type === $rule['value'] );
88
+        	$match = ($post_type === $rule['value']);
89 89
         	
90
-        } elseif( $rule['operator'] == "!=" ) {
90
+        } elseif ($rule['operator'] == "!=") {
91 91
         	
92
-        	$match = ( $post_type !== $rule['value'] );
92
+        	$match = ($post_type !== $rule['value']);
93 93
         	
94 94
         }
95 95
         
@@ -113,18 +113,18 @@  discard block
 block discarded – undo
113 113
 	*  @return	$options (array)
114 114
 	*/
115 115
 	
116
-	function rule_match_current_user( $match, $rule, $options ) {
116
+	function rule_match_current_user($match, $rule, $options) {
117 117
 		
118 118
 		// logged in
119
-		if( $rule['value'] == 'logged_in' ) {
119
+		if ($rule['value'] == 'logged_in') {
120 120
 			
121
-			if( $rule['operator'] == "==" ) {
121
+			if ($rule['operator'] == "==") {
122 122
 				
123 123
 				$match = is_user_logged_in();
124 124
 					
125
-			} elseif( $rule['operator'] == "!=" ) {
125
+			} elseif ($rule['operator'] == "!=") {
126 126
 				
127
-				$match = !is_user_logged_in();
127
+				$match = ! is_user_logged_in();
128 128
 					
129 129
 			}
130 130
 			
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
 		
135 135
 		
136 136
 		// front end
137
-		if( $rule['value'] == 'viewing_front' ) {
137
+		if ($rule['value'] == 'viewing_front') {
138 138
 			
139
-			if( $rule['operator'] == "==" ) {
139
+			if ($rule['operator'] == "==") {
140 140
 				
141
-				$match = !is_admin();
141
+				$match = ! is_admin();
142 142
 					
143
-			} elseif( $rule['operator'] == "!=" ) {
143
+			} elseif ($rule['operator'] == "!=") {
144 144
 				
145 145
 				$match = is_admin();
146 146
 					
@@ -152,15 +152,15 @@  discard block
 block discarded – undo
152 152
 		
153 153
 		
154 154
 		// back end
155
-		if( $rule['value'] == 'viewing_back' ) {
155
+		if ($rule['value'] == 'viewing_back') {
156 156
 			
157
-			if( $rule['operator'] == "==" ) {
157
+			if ($rule['operator'] == "==") {
158 158
 				
159 159
 				$match = is_admin();
160 160
 					
161
-			} elseif( $rule['operator'] == "!=" ) {
161
+			} elseif ($rule['operator'] == "!=") {
162 162
 				
163
-				$match = !is_admin();
163
+				$match = ! is_admin();
164 164
 					
165 165
 			}
166 166
 			
@@ -189,10 +189,10 @@  discard block
 block discarded – undo
189 189
 	*  @return	$options (array)
190 190
 	*/
191 191
 	
192
-	function rule_match_current_user_role( $match, $rule, $options ) {
192
+	function rule_match_current_user_role($match, $rule, $options) {
193 193
 		
194 194
 		// bail early if not logged in
195
-		if( !is_user_logged_in() ) {
195
+		if ( ! is_user_logged_in()) {
196 196
 			
197 197
 			return false;
198 198
 			
@@ -204,27 +204,27 @@  discard block
 block discarded – undo
204 204
 		
205 205
 		
206 206
 		// compare
207
-        if( $rule['operator'] == "==" ) {
207
+        if ($rule['operator'] == "==") {
208 208
         	
209
-			if( $rule['value'] == 'super_admin' ) {
209
+			if ($rule['value'] == 'super_admin') {
210 210
 				
211
-				$match = is_super_admin( $user->ID );
211
+				$match = is_super_admin($user->ID);
212 212
 				
213 213
 			} else {
214 214
 				
215
-				$match = in_array( $rule['value'], $user->roles );
215
+				$match = in_array($rule['value'], $user->roles);
216 216
 				
217 217
 			}
218 218
 			
219
-		} elseif( $rule['operator'] == "!=" ) {
219
+		} elseif ($rule['operator'] == "!=") {
220 220
 			
221
-			if( $rule['value'] == 'super_admin' ) {
221
+			if ($rule['value'] == 'super_admin') {
222 222
 				
223
-				$match = !is_super_admin( $user->ID );
223
+				$match = ! is_super_admin($user->ID);
224 224
 				
225 225
 			} else {
226 226
 				
227
-				$match = ( ! in_array( $rule['value'], $user->roles ) );
227
+				$match = ( ! in_array($rule['value'], $user->roles));
228 228
 				
229 229
 			}
230 230
 			
@@ -251,14 +251,14 @@  discard block
 block discarded – undo
251 251
 	*  @return	$options (array)
252 252
 	*/
253 253
 	
254
-	function rule_match_post( $match, $rule, $options ) {
254
+	function rule_match_post($match, $rule, $options) {
255 255
 		
256 256
 		// vars
257 257
 		$post_id = $options['post_id'];
258 258
 		
259 259
 		
260 260
 		// validation
261
-		if( !$post_id ) {
261
+		if ( ! $post_id) {
262 262
 		
263 263
 			return false;
264 264
 			
@@ -274,13 +274,13 @@  discard block
 block discarded – undo
274 274
 		
275 275
 		
276 276
 		// compare
277
-        if( $rule['operator'] == "==") {
277
+        if ($rule['operator'] == "==") {
278 278
         	
279
-        	$match = ( $options['post_id'] == $rule['value'] );
279
+        	$match = ($options['post_id'] == $rule['value']);
280 280
         
281
-        } elseif( $rule['operator'] == "!=") {
281
+        } elseif ($rule['operator'] == "!=") {
282 282
         	
283
-        	$match = ( $options['post_id'] != $rule['value'] );
283
+        	$match = ($options['post_id'] != $rule['value']);
284 284
         
285 285
         }
286 286
         
@@ -305,10 +305,10 @@  discard block
 block discarded – undo
305 305
 	*  @return	$options (array)
306 306
 	*/
307 307
 	
308
-	function rule_match_post_taxonomy( $match, $rule, $options ) {
308
+	function rule_match_post_taxonomy($match, $rule, $options) {
309 309
 		
310 310
 		// validate
311
-		if( !$options['post_id'] ) {
311
+		if ( ! $options['post_id']) {
312 312
 		
313 313
 			return false;
314 314
 			
@@ -321,20 +321,20 @@  discard block
 block discarded – undo
321 321
 			
322 322
 		// get term data
323 323
 		// - selected term may have a numeric slug '123' (user reported on forum), so always check slug first
324
-		$data = acf_decode_taxonomy_term( $rule['value'] );
325
-		$term = get_term_by( 'slug', $data['term'], $data['taxonomy'] );
324
+		$data = acf_decode_taxonomy_term($rule['value']);
325
+		$term = get_term_by('slug', $data['term'], $data['taxonomy']);
326 326
 		
327 327
 		
328 328
 		// attempt get term via ID (ACF4 uses ID)
329
-		if( !$term && is_numeric($data['term']) ) {
329
+		if ( ! $term && is_numeric($data['term'])) {
330 330
 			
331
-			$term = get_term_by( 'id', $data['term'], $data['taxonomy'] );
331
+			$term = get_term_by('id', $data['term'], $data['taxonomy']);
332 332
 			
333 333
 		}
334 334
 		
335 335
 		
336 336
 		// bail early if no term
337
-		if( !$term ) {
337
+		if ( ! $term) {
338 338
 			
339 339
 			return false;
340 340
 						
@@ -342,28 +342,28 @@  discard block
 block discarded – undo
342 342
 		
343 343
 		
344 344
 		// post type
345
-		if( !$options['post_type'] ) {
345
+		if ( ! $options['post_type']) {
346 346
 		
347
-			$options['post_type'] = get_post_type( $options['post_id'] );
347
+			$options['post_type'] = get_post_type($options['post_id']);
348 348
 			
349 349
 		}
350 350
 		
351 351
 		
352 352
 		// get terms
353 353
 		// - allow an empty array (sent via JS) to avoid loading the real post's terms
354
-		if( !is_array($terms) ) {
354
+		if ( ! is_array($terms)) {
355 355
 		
356
-			$terms = wp_get_post_terms( $options['post_id'], $term->taxonomy, array('fields' => 'ids') );
356
+			$terms = wp_get_post_terms($options['post_id'], $term->taxonomy, array('fields' => 'ids'));
357 357
 			
358 358
 		}
359 359
 		
360 360
 		
361 361
 		// If no terms, this is a new post and should be treated as if it has the "Uncategorized" (1) category ticked
362
-		if( empty($terms) ) {
362
+		if (empty($terms)) {
363 363
 			
364
-			if( is_object_in_taxonomy($options['post_type'], 'category') ) {
364
+			if (is_object_in_taxonomy($options['post_type'], 'category')) {
365 365
 			
366
-				$terms = array( 1 );
366
+				$terms = array(1);
367 367
 				
368 368
 			}
369 369
 			
@@ -371,13 +371,13 @@  discard block
 block discarded – undo
371 371
 		
372 372
 		
373 373
 		// compare
374
-        if( $rule['operator'] == "==") {
374
+        if ($rule['operator'] == "==") {
375 375
         	
376 376
         	$match = in_array($term->term_id, $terms);
377 377
         
378
-        } elseif( $rule['operator'] == "!=") {
378
+        } elseif ($rule['operator'] == "!=") {
379 379
         	
380
-        	$match = !in_array($term->term_id, $terms);
380
+        	$match = ! in_array($term->term_id, $terms);
381 381
         
382 382
         }		
383 383
             
@@ -402,17 +402,17 @@  discard block
 block discarded – undo
402 402
 	*  @return	$options (array)
403 403
 	*/
404 404
 	
405
-	function rule_match_post_format( $match, $rule, $options ) {
405
+	function rule_match_post_format($match, $rule, $options) {
406 406
 		
407 407
 		// vars
408 408
 		$post_format = $options['post_format'];
409 409
 		
410 410
 		
411 411
 		// new post format?
412
-		if( !$post_format ) {	
412
+		if ( ! $post_format) {	
413 413
 			
414 414
 			// validate
415
-			if( !$options['post_id'] ) {
415
+			if ( ! $options['post_id']) {
416 416
 			
417 417
 				return false;
418 418
 				
@@ -420,19 +420,19 @@  discard block
 block discarded – undo
420 420
 			
421 421
 			
422 422
 			// post type
423
-			if( !$options['post_type'] ) {
423
+			if ( ! $options['post_type']) {
424 424
 			
425
-				$options['post_type'] = get_post_type( $options['post_id'] );
425
+				$options['post_type'] = get_post_type($options['post_id']);
426 426
 				
427 427
 			}
428 428
 			
429 429
 		
430 430
 			// does post_type support 'post-format'
431
-			if( post_type_supports( $options['post_type'], 'post-formats' ) ) {
431
+			if (post_type_supports($options['post_type'], 'post-formats')) {
432 432
 				
433
-				$post_format = get_post_format( $options['post_id'] );
433
+				$post_format = get_post_format($options['post_id']);
434 434
 				
435
-				if( $post_format === false ) {
435
+				if ($post_format === false) {
436 436
 				
437 437
 					$post_format = 'standard';
438 438
 					
@@ -444,13 +444,13 @@  discard block
 block discarded – undo
444 444
 
445 445
        	
446 446
        	// compare
447
-        if( $rule['operator'] == "==") {
447
+        if ($rule['operator'] == "==") {
448 448
         	
449
-        	$match = ( $post_format === $rule['value'] );
449
+        	$match = ($post_format === $rule['value']);
450 450
         
451
-        } elseif( $rule['operator'] == "!=") {
451
+        } elseif ($rule['operator'] == "!=") {
452 452
         	
453
-        	$match = ( $post_format !== $rule['value'] );
453
+        	$match = ($post_format !== $rule['value']);
454 454
         
455 455
         }
456 456
         
@@ -475,10 +475,10 @@  discard block
 block discarded – undo
475 475
 	*  @return	$options (array)
476 476
 	*/
477 477
 	
478
-	function rule_match_post_status( $match, $rule, $options ) {
478
+	function rule_match_post_status($match, $rule, $options) {
479 479
 		
480 480
 		// validate
481
-		if( !$options['post_id'] ) {
481
+		if ( ! $options['post_id']) {
482 482
 		
483 483
 			return false;
484 484
 			
@@ -486,11 +486,11 @@  discard block
 block discarded – undo
486 486
 		
487 487
 					
488 488
 		// vars
489
-		$post_status = get_post_status( $options['post_id'] );
489
+		$post_status = get_post_status($options['post_id']);
490 490
 	    
491 491
 	    
492 492
 	    // auto-draft = draft
493
-	    if( $post_status == 'auto-draft' )  {
493
+	    if ($post_status == 'auto-draft') {
494 494
 	    
495 495
 		    $post_status = 'draft';
496 496
 		    
@@ -498,13 +498,13 @@  discard block
 block discarded – undo
498 498
 	    
499 499
 	    
500 500
 	    // compare
501
-        if( $rule['operator'] == "==") {
501
+        if ($rule['operator'] == "==") {
502 502
         	
503
-        	$match = ( $post_status === $rule['value'] );
503
+        	$match = ($post_status === $rule['value']);
504 504
         
505
-        } elseif( $rule['operator'] == "!=") {
505
+        } elseif ($rule['operator'] == "!=") {
506 506
         	
507
-        	$match = ( $post_status !== $rule['value'] );
507
+        	$match = ($post_status !== $rule['value']);
508 508
         
509 509
         }
510 510
         
@@ -529,10 +529,10 @@  discard block
 block discarded – undo
529 529
 	*  @return	$options (array)
530 530
 	*/
531 531
 		
532
-	function rule_match_page_type( $match, $rule, $options ) {
532
+	function rule_match_page_type($match, $rule, $options) {
533 533
 	
534 534
 		// validation
535
-		if( !$options['post_id'] ) {
535
+		if ( ! $options['post_id']) {
536 536
 		
537 537
 			return false;
538 538
 			
@@ -540,52 +540,52 @@  discard block
 block discarded – undo
540 540
 		
541 541
 		
542 542
 		// get post
543
-		$post = get_post( $options['post_id'] );
543
+		$post = get_post($options['post_id']);
544 544
 		
545 545
 		
546 546
 		// compare   
547
-        if( $rule['value'] == 'front_page') {
547
+        if ($rule['value'] == 'front_page') {
548 548
         	
549 549
         	// vars
550 550
 	        $front_page = (int) get_option('page_on_front');
551 551
 	        
552 552
 	        
553 553
 	         // compare
554
-	        if( $rule['operator'] == "==" ) {
554
+	        if ($rule['operator'] == "==") {
555 555
 	        	
556
-	        	$match = ( $front_page == $post->ID );
556
+	        	$match = ($front_page == $post->ID);
557 557
 	        	
558
-	        } elseif( $rule['operator'] == "!=" ) {
558
+	        } elseif ($rule['operator'] == "!=") {
559 559
 	        	
560
-	        	$match = ( $front_page != $post->ID );
560
+	        	$match = ($front_page != $post->ID);
561 561
 	        
562 562
 	        }
563 563
 	        
564
-        } elseif( $rule['value'] == 'posts_page') {
564
+        } elseif ($rule['value'] == 'posts_page') {
565 565
         	
566 566
         	// vars
567 567
 	        $posts_page = (int) get_option('page_for_posts');
568 568
 	        
569 569
 	        
570 570
 	        // compare
571
-	        if( $rule['operator'] == "==" ) {
571
+	        if ($rule['operator'] == "==") {
572 572
 	        
573
-	        	$match = ( $posts_page == $post->ID );
573
+	        	$match = ($posts_page == $post->ID);
574 574
 	        
575
-	        } elseif( $rule['operator'] == "!=" ) {
575
+	        } elseif ($rule['operator'] == "!=") {
576 576
 	        	
577
-	        	$match = ( $posts_page != $post->ID );
577
+	        	$match = ($posts_page != $post->ID);
578 578
 	        	
579 579
 	        }
580 580
 	        
581
-        } elseif( $rule['value'] == 'top_level') {
581
+        } elseif ($rule['value'] == 'top_level') {
582 582
         	
583 583
         	// vars
584 584
         	$post_parent = $post->post_parent;
585 585
         	
586 586
         	
587 587
         	// override
588
-        	if( $options['page_parent'] ) {
588
+        	if ($options['page_parent']) {
589 589
 	        	
590 590
 	        	$post_parent = $options['page_parent'];
591 591
 	        	
@@ -593,17 +593,17 @@  discard block
 block discarded – undo
593 593
         	
594 594
         	
595 595
         	// compare
596
-	        if( $rule['operator'] == "==" ) {
596
+	        if ($rule['operator'] == "==") {
597 597
 	        
598
-	        	$match = ( $post_parent == 0 );
598
+	        	$match = ($post_parent == 0);
599 599
 	        
600
-	        } elseif( $rule['operator'] == "!=" ) {
600
+	        } elseif ($rule['operator'] == "!=") {
601 601
 	        	
602
-	        	$match = ( $post_parent != 0 );
602
+	        	$match = ($post_parent != 0);
603 603
 	        	
604 604
 	        }
605 605
 	            
606
-        } elseif( $rule['value'] == 'parent' ) {
606
+        } elseif ($rule['value'] == 'parent') {
607 607
         	
608 608
         	// get children
609 609
         	$children = get_pages(array(
@@ -613,24 +613,24 @@  discard block
 block discarded – undo
613 613
         	
614 614
 	        
615 615
 	        // compare
616
-	        if( $rule['operator'] == "==" ) {
616
+	        if ($rule['operator'] == "==") {
617 617
 	        
618
-	        	$match = ( count($children) > 0 );
618
+	        	$match = (count($children) > 0);
619 619
 	        
620
-	        } elseif( $rule['operator'] == "!=" ) {
620
+	        } elseif ($rule['operator'] == "!=") {
621 621
 	        	
622
-	        	$match = ( count($children) == 0 );
622
+	        	$match = (count($children) == 0);
623 623
 	        	
624 624
 	        }
625 625
 	        
626
-        } elseif( $rule['value'] == 'child') {
626
+        } elseif ($rule['value'] == 'child') {
627 627
         	
628 628
         	// vars
629 629
         	$post_parent = $post->post_parent;
630 630
         	
631 631
         	
632 632
         	// override
633
-        	if( $options['page_parent'] ) {
633
+        	if ($options['page_parent']) {
634 634
         	
635 635
 	        	$post_parent = $options['page_parent'];
636 636
 	        	
@@ -638,13 +638,13 @@  discard block
 block discarded – undo
638 638
 	        
639 639
 	        
640 640
 	        // compare
641
-	        if( $rule['operator'] == "==" ) {
641
+	        if ($rule['operator'] == "==") {
642 642
 	        
643
-	        	$match = ( $post_parent != 0 );
643
+	        	$match = ($post_parent != 0);
644 644
 	        
645
-	        } elseif( $rule['operator'] == "!=" ) {
645
+	        } elseif ($rule['operator'] == "!=") {
646 646
 	        	
647
-	        	$match = ( $post_parent == 0 );
647
+	        	$match = ($post_parent == 0);
648 648
 	        	
649 649
 	        }
650 650
 	        
@@ -671,10 +671,10 @@  discard block
 block discarded – undo
671 671
 	*  @return	$options (array)
672 672
 	*/
673 673
 	
674
-	function rule_match_page_parent( $match, $rule, $options ) {
674
+	function rule_match_page_parent($match, $rule, $options) {
675 675
 		
676 676
 		// validation
677
-		if( !$options['post_id'] ) {
677
+		if ( ! $options['post_id']) {
678 678
 		
679 679
 			return false;
680 680
 			
@@ -682,12 +682,12 @@  discard block
 block discarded – undo
682 682
 		
683 683
 		
684 684
 		// vars
685
-		$post = get_post( $options['post_id'] );
685
+		$post = get_post($options['post_id']);
686 686
 		
687 687
 		
688 688
 		// post parent
689 689
 		$post_parent = $post->post_parent;
690
-    	if( $options['page_parent'] ) {
690
+    	if ($options['page_parent']) {
691 691
     	
692 692
         	$post_parent = $options['page_parent'];
693 693
         	
@@ -695,13 +695,13 @@  discard block
 block discarded – undo
695 695
         
696 696
         
697 697
         // compare
698
-        if( $rule['operator'] == "==" ) {
698
+        if ($rule['operator'] == "==") {
699 699
         
700
-        	$match = ( $post_parent == $rule['value'] );
700
+        	$match = ($post_parent == $rule['value']);
701 701
         
702
-        } elseif( $rule['operator'] == "!=" ) {
702
+        } elseif ($rule['operator'] == "!=") {
703 703
         	
704
-        	$match = ( $post_parent != $rule['value'] );
704
+        	$match = ($post_parent != $rule['value']);
705 705
         	
706 706
         }
707 707
         
@@ -726,32 +726,32 @@  discard block
 block discarded – undo
726 726
 	*  @return	$options (array)
727 727
 	*/
728 728
 		
729
-	function rule_match_page_template( $match, $rule, $options ) {
729
+	function rule_match_page_template($match, $rule, $options) {
730 730
 		
731 731
 		// vars
732 732
 		$page_template = $options['page_template'];
733 733
 		
734 734
 		
735 735
 		// get page template
736
-		if( !$page_template && $options['post_id'] ) {
736
+		if ( ! $page_template && $options['post_id']) {
737 737
 		
738
-			$page_template = get_post_meta( $options['post_id'], '_wp_page_template', true );
738
+			$page_template = get_post_meta($options['post_id'], '_wp_page_template', true);
739 739
 			
740 740
 		}
741 741
 		
742 742
 		
743 743
 		// get page template again
744
-		if( ! $page_template ) {
744
+		if ( ! $page_template) {
745 745
 			
746 746
 			$post_type = $options['post_type'];
747 747
 
748
-			if( !$post_type && $options['post_id'] ) {
748
+			if ( ! $post_type && $options['post_id']) {
749 749
 			
750
-				$post_type = get_post_type( $options['post_id'] );
750
+				$post_type = get_post_type($options['post_id']);
751 751
 				
752 752
 			}
753 753
 			
754
-			if( $post_type === 'page' ) {
754
+			if ($post_type === 'page') {
755 755
 			
756 756
 				$page_template = "default";
757 757
 				
@@ -760,13 +760,13 @@  discard block
 block discarded – undo
760 760
 		
761 761
 		
762 762
 		// compare
763
-        if( $rule['operator'] == "==" ) {
763
+        if ($rule['operator'] == "==") {
764 764
         
765
-        	$match = ( $page_template === $rule['value'] );
765
+        	$match = ($page_template === $rule['value']);
766 766
         
767
-        } elseif( $rule['operator'] == "!=" ) {
767
+        } elseif ($rule['operator'] == "!=") {
768 768
         	
769
-        	$match = ( $page_template !== $rule['value'] );
769
+        	$match = ($page_template !== $rule['value']);
770 770
         	
771 771
         }
772 772
         
@@ -791,14 +791,14 @@  discard block
 block discarded – undo
791 791
 	*  @return	$options (array)
792 792
 	*/
793 793
     
794
-    function rule_match_user_form( $match, $rule, $options ) {
794
+    function rule_match_user_form($match, $rule, $options) {
795 795
 		
796 796
 		// vars
797 797
 		$user_form = $options['user_form'];
798 798
 		
799 799
 		
800 800
 		// add is treated the same as edit
801
-		if( $user_form === 'add' ) {
801
+		if ($user_form === 'add') {
802 802
 		
803 803
 			$user_form = 'edit';
804 804
 			
@@ -806,27 +806,27 @@  discard block
 block discarded – undo
806 806
 		
807 807
 		
808 808
 		// compare
809
-		if( $user_form ) {
809
+		if ($user_form) {
810 810
 		
811
-			if( $rule['operator'] == "==" ) {
811
+			if ($rule['operator'] == "==") {
812 812
 				
813
-	        	$match = ( $user_form == $rule['value'] );
813
+	        	$match = ($user_form == $rule['value']);
814 814
 	        	
815 815
 	        	
816 816
 	        	// override for "all"
817
-		        if( $rule['value'] === 'all' ) {
817
+		        if ($rule['value'] === 'all') {
818 818
 					
819 819
 					$match = true;
820 820
 				
821 821
 				}
822 822
 	        
823
-	        } elseif( $rule['operator'] == "!=" ) {
823
+	        } elseif ($rule['operator'] == "!=") {
824 824
 	        	
825
-	        	$match = ( $user_form != $rule['value'] );
825
+	        	$match = ($user_form != $rule['value']);
826 826
 	        	
827 827
 	        	
828 828
 	        	// override for "all"
829
-		        if( $rule['value'] === 'all' ) {
829
+		        if ($rule['value'] === 'all') {
830 830
 		        
831 831
 					$match = false;
832 832
 					
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
 	*  @return	$options (array)
857 857
 	*/
858 858
 	
859
-	function rule_match_user_role( $match, $rule, $options ) {
859
+	function rule_match_user_role($match, $rule, $options) {
860 860
 		
861 861
 		// vars
862 862
 		$user_id = $options['user_id'];
@@ -864,11 +864,11 @@  discard block
 block discarded – undo
864 864
 		
865 865
 		
866 866
 		// user form AJAX will send through user_form
867
-		if( $user_role ) {
867
+		if ($user_role) {
868 868
 		
869
-			if( $rule['operator'] == "==" ) {
869
+			if ($rule['operator'] == "==") {
870 870
 			
871
-	        	if( $user_role === $rule['value'] ) {
871
+	        	if ($user_role === $rule['value']) {
872 872
 	        	
873 873
 	        		$match = true;
874 874
 	        		
@@ -876,15 +876,15 @@  discard block
 block discarded – undo
876 876
 	        	
877 877
 	        	
878 878
 	        	// override for "all"
879
-		        if( $rule['value'] === 'all' ) {
879
+		        if ($rule['value'] === 'all') {
880 880
 		        
881 881
 					$match = true;
882 882
 					
883 883
 				}
884 884
 	        
885
-	        } elseif( $rule['operator'] == "!=" ) {
885
+	        } elseif ($rule['operator'] == "!=") {
886 886
 	        	
887
-	        	if( $user_role !== $rule['value'] ) {
887
+	        	if ($user_role !== $rule['value']) {
888 888
 	        	
889 889
 	        		$match = true;
890 890
 	        		
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
 	        	
893 893
 	        	
894 894
 	        	// override for "all"
895
-		        if( $rule['value'] === 'all' ) {
895
+		        if ($rule['value'] === 'all') {
896 896
 		        
897 897
 					$match = false;
898 898
 					
@@ -900,47 +900,47 @@  discard block
 block discarded – undo
900 900
 				
901 901
 	        }
902 902
 	        
903
-		} elseif( $user_id ) {
903
+		} elseif ($user_id) {
904 904
 			
905
-			if( $rule['operator'] == "==" ) {
905
+			if ($rule['operator'] == "==") {
906 906
 				
907
-	        	if( $user_id === 'new' ) {
907
+	        	if ($user_id === 'new') {
908 908
 	        		
909 909
 	        		// case: add user
910
-		        	$match = ( $rule['value'] == get_option('default_role') );
910
+		        	$match = ($rule['value'] == get_option('default_role'));
911 911
 		        	
912 912
 	        	} else {
913 913
 	        		
914 914
 	        		// case: edit user
915
-		        	$match = ( user_can($user_id, $rule['value']) );
915
+		        	$match = (user_can($user_id, $rule['value']));
916 916
 		        	
917 917
 	        	}
918 918
 	        	
919 919
 	        	
920 920
 	        	// override for "all"
921
-		        if( $rule['value'] === 'all' ) {
921
+		        if ($rule['value'] === 'all') {
922 922
 		        	
923 923
 					$match = true;
924 924
 					
925 925
 				}
926 926
 				
927
-	        } elseif( $rule['operator'] == "!=" ) {
927
+	        } elseif ($rule['operator'] == "!=") {
928 928
 	        	
929
-	        	if( $user_id === 'new' ) {
929
+	        	if ($user_id === 'new') {
930 930
 	        		
931 931
 	        		// case: add user
932
-		        	$match = ( $rule['value'] != get_option('default_role') );
932
+		        	$match = ($rule['value'] != get_option('default_role'));
933 933
 		        	
934 934
 	        	} else {
935 935
 	        		
936 936
 	        		// case: edit user
937
-		        	$match = ( !user_can($user_id, $rule['value']) );
937
+		        	$match = ( ! user_can($user_id, $rule['value']));
938 938
 		        	
939 939
 	        	}
940 940
 	        	
941 941
 	        	
942 942
 	        	// override for "all"
943
-		        if( $rule['value'] === 'all' ) {
943
+		        if ($rule['value'] === 'all') {
944 944
 		        	
945 945
 					$match = false;
946 946
 					
@@ -972,14 +972,14 @@  discard block
 block discarded – undo
972 972
 	*  @return	$options (array)
973 973
 	*/
974 974
 	
975
-	function rule_match_taxonomy( $match, $rule, $options ) {
975
+	function rule_match_taxonomy($match, $rule, $options) {
976 976
 		
977 977
 		// vars
978 978
 		$taxonomy = $options['taxonomy'];
979 979
 		
980 980
 		
981 981
 		// validate
982
-		if( !$taxonomy ) {
982
+		if ( ! $taxonomy) {
983 983
 			
984 984
 			return false;
985 985
 			
@@ -987,23 +987,23 @@  discard block
 block discarded – undo
987 987
 		
988 988
 		
989 989
 		// compare
990
-		if( $rule['operator'] == "==" ) {
990
+		if ($rule['operator'] == "==") {
991 991
 			
992
-        	$match = ( $taxonomy == $rule['value'] );
992
+        	$match = ($taxonomy == $rule['value']);
993 993
         	
994 994
         	// override for "all"
995
-	        if( $rule['value'] == "all" ) {
995
+	        if ($rule['value'] == "all") {
996 996
 	        
997 997
 				$match = true;
998 998
 				
999 999
 			}
1000 1000
 			
1001
-        } elseif( $rule['operator'] == "!=" ) {
1001
+        } elseif ($rule['operator'] == "!=") {
1002 1002
         	
1003
-        	$match = ( $taxonomy != $rule['value'] );
1003
+        	$match = ($taxonomy != $rule['value']);
1004 1004
         		
1005 1005
         	// override for "all"
1006
-	        if( $rule['value'] == "all" ) {
1006
+	        if ($rule['value'] == "all") {
1007 1007
 	        	
1008 1008
 				$match = false;
1009 1009
 				
@@ -1032,14 +1032,14 @@  discard block
 block discarded – undo
1032 1032
 	*  @return	$options (array)
1033 1033
 	*/
1034 1034
 	
1035
-	function rule_match_attachment( $match, $rule, $options ) {
1035
+	function rule_match_attachment($match, $rule, $options) {
1036 1036
 		
1037 1037
 		// vars
1038 1038
 		$attachment = $options['attachment'];
1039 1039
 		
1040 1040
 		
1041 1041
 		// validate
1042
-		if( ! $attachment ) {
1042
+		if ( ! $attachment) {
1043 1043
 			
1044 1044
 			return false;
1045 1045
 			
@@ -1047,23 +1047,23 @@  discard block
 block discarded – undo
1047 1047
 		
1048 1048
 		
1049 1049
 		// compare
1050
-		if( $rule['operator'] == "==" ) {
1050
+		if ($rule['operator'] == "==") {
1051 1051
 			
1052
-        	$match = ( $attachment == $rule['value'] );
1052
+        	$match = ($attachment == $rule['value']);
1053 1053
         	
1054 1054
         	// override for "all"
1055
-	        if( $rule['value'] == "all" ) {
1055
+	        if ($rule['value'] == "all") {
1056 1056
 	        
1057 1057
 				$match = true;
1058 1058
 				
1059 1059
 			}
1060 1060
 			
1061
-        } elseif( $rule['operator'] == "!=" ) {
1061
+        } elseif ($rule['operator'] == "!=") {
1062 1062
         	
1063
-        	$match = ( $attachment != $rule['value'] );
1063
+        	$match = ($attachment != $rule['value']);
1064 1064
         		
1065 1065
         	// override for "all"
1066
-	        if( $rule['value'] == "all" ) {
1066
+	        if ($rule['value'] == "all") {
1067 1067
 	        
1068 1068
 				$match = false;
1069 1069
 				
@@ -1093,14 +1093,14 @@  discard block
 block discarded – undo
1093 1093
 	*  @return	$options (array)
1094 1094
 	*/
1095 1095
 	
1096
-	function rule_match_comment( $match, $rule, $options ) {
1096
+	function rule_match_comment($match, $rule, $options) {
1097 1097
 		
1098 1098
 		// vars
1099 1099
 		$comment = $options['comment'];
1100 1100
 		
1101 1101
 		
1102 1102
 		// validate
1103
-		if( ! $comment ) {
1103
+		if ( ! $comment) {
1104 1104
 			
1105 1105
 			return false;
1106 1106
 			
@@ -1108,23 +1108,23 @@  discard block
 block discarded – undo
1108 1108
 		
1109 1109
 		
1110 1110
 		// compare
1111
-		if( $rule['operator'] == "==" ) {
1111
+		if ($rule['operator'] == "==") {
1112 1112
 			
1113
-        	$match = ( $comment == $rule['value'] );
1113
+        	$match = ($comment == $rule['value']);
1114 1114
         	
1115 1115
         	// override for "all"
1116
-	        if( $rule['value'] == "all" ) {
1116
+	        if ($rule['value'] == "all") {
1117 1117
 	        
1118 1118
 				$match = true;
1119 1119
 				
1120 1120
 			}
1121 1121
 			
1122
-        } elseif( $rule['operator'] == "!=" ) {
1122
+        } elseif ($rule['operator'] == "!=") {
1123 1123
         	
1124
-        	$match = ( $comment != $rule['value'] );
1124
+        	$match = ($comment != $rule['value']);
1125 1125
         		
1126 1126
         	// override for "all"
1127
-	        if( $rule['value'] == "all" ) {
1127
+	        if ($rule['value'] == "all") {
1128 1128
 	        
1129 1129
 				$match = false;
1130 1130
 				
@@ -1153,14 +1153,14 @@  discard block
 block discarded – undo
1153 1153
 	*  @return	$options (array)
1154 1154
 	*/
1155 1155
     
1156
-    function rule_match_widget( $match, $rule, $options ) {
1156
+    function rule_match_widget($match, $rule, $options) {
1157 1157
 		
1158 1158
 		// vars
1159 1159
 		$widget = $options['widget'];
1160 1160
 		
1161 1161
 		
1162 1162
 		// validate
1163
-		if( ! $widget ) {
1163
+		if ( ! $widget) {
1164 1164
 			
1165 1165
 			return false;
1166 1166
 			
@@ -1168,23 +1168,23 @@  discard block
 block discarded – undo
1168 1168
 		
1169 1169
 		
1170 1170
 		// compare
1171
-		if( $rule['operator'] == "==" ) {
1171
+		if ($rule['operator'] == "==") {
1172 1172
 			
1173
-        	$match = ( $widget == $rule['value'] );
1173
+        	$match = ($widget == $rule['value']);
1174 1174
         	
1175 1175
         	// override for "all"
1176
-	        if( $rule['value'] == "all" ) {
1176
+	        if ($rule['value'] == "all") {
1177 1177
 	        
1178 1178
 				$match = true;
1179 1179
 				
1180 1180
 			}
1181 1181
 			
1182
-        } elseif( $rule['operator'] == "!=" ) {
1182
+        } elseif ($rule['operator'] == "!=") {
1183 1183
         	
1184
-        	$match = ( $widget != $rule['value'] );
1184
+        	$match = ($widget != $rule['value']);
1185 1185
         		
1186 1186
         	// override for "all"
1187
-	        if( $rule['value'] == "all" ) {
1187
+	        if ($rule['value'] == "all") {
1188 1188
 	        
1189 1189
 				$match = false;
1190 1190
 				
@@ -1217,7 +1217,7 @@  discard block
 block discarded – undo
1217 1217
 *  @return	(boolean)
1218 1218
 */
1219 1219
 
1220
-function acf_get_field_group_visibility( $field_group, $args = array() ) {
1220
+function acf_get_field_group_visibility($field_group, $args = array()) {
1221 1221
 	
1222 1222
 	// vars
1223 1223
 	$args = acf_parse_args($args, array(
@@ -1241,7 +1241,7 @@  discard block
 block discarded – undo
1241 1241
 	
1242 1242
 	
1243 1243
 	// bail early if not active
1244
-	if( !$field_group['active'] ) {
1244
+	if ( ! $field_group['active']) {
1245 1245
 		
1246 1246
 		return false;
1247 1247
 		
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
 	
1250 1250
 	
1251 1251
 	// WPML
1252
-	if( defined('ICL_LANGUAGE_CODE') ) {
1252
+	if (defined('ICL_LANGUAGE_CODE')) {
1253 1253
 		
1254 1254
 		$args['lang'] = ICL_LANGUAGE_CODE;
1255 1255
 		
@@ -1261,20 +1261,20 @@  discard block
 block discarded – undo
1261 1261
 	
1262 1262
 	
1263 1263
 	// loop through location rules
1264
-	foreach( $field_group['location'] as $group_id => $group ) {
1264
+	foreach ($field_group['location'] as $group_id => $group) {
1265 1265
 		
1266 1266
 		// start of as true, this way, any rule that doesn't match will cause this varaible to false
1267 1267
 		$match_group = true;
1268 1268
 		
1269 1269
 		
1270 1270
 		// loop over group rules
1271
-		if( !empty($group) ) {
1271
+		if ( ! empty($group)) {
1272 1272
 		
1273
-			foreach( $group as $rule_id => $rule ) {
1273
+			foreach ($group as $rule_id => $rule) {
1274 1274
 				
1275
-				$match = apply_filters( 'acf/location/rule_match/' . $rule['param'] , false, $rule, $args );
1275
+				$match = apply_filters('acf/location/rule_match/'.$rule['param'], false, $rule, $args);
1276 1276
 				
1277
-				if( !$match ) {
1277
+				if ( ! $match) {
1278 1278
 					
1279 1279
 					$match_group = false;
1280 1280
 					break;
@@ -1287,7 +1287,7 @@  discard block
 block discarded – undo
1287 1287
 		
1288 1288
 		
1289 1289
 		// all rules must havematched!
1290
-		if( $match_group ) {
1290
+		if ($match_group) {
1291 1291
 			
1292 1292
 			$visibility = true;
1293 1293
 			
Please login to merge, or discard this patch.