Completed
Pull Request — trunk (#541)
by Justin
06:40
created
includes/types/CMB2_Type_Text.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -50,12 +50,12 @@
 block discarded – undo
50 50
 			'js_dependencies' => array(),
51 51
 		), $args );
52 52
 
53
-		if ( ! empty( $a['js_dependencies'] ) ) {
54
-			$this->field->add_js_dependencies( $a['js_dependencies'] );
53
+		if ( ! empty( $a[ 'js_dependencies' ] ) ) {
54
+			$this->field->add_js_dependencies( $a[ 'js_dependencies' ] );
55 55
 		}
56 56
 
57 57
 		return $this->rendered(
58
-			sprintf( '<input%s/>%s', $this->concat_attrs( $a, array( 'desc', 'js_dependencies' ) ), $a['desc'] )
58
+			sprintf( '<input%s/>%s', $this->concat_attrs( $a, array( 'desc', 'js_dependencies' ) ), $a[ 'desc' ] )
59 59
 		);
60 60
 	}
61 61
 }
Please login to merge, or discard this patch.
includes/types/CMB2_Type_File.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 		$output     = '';
22 22
 
23 23
 		// if options array and 'url' => false, then hide the url field
24
-		$input_type = array_key_exists( 'url', $options ) && false === $options['url'] ? 'hidden' : 'text';
24
+		$input_type = array_key_exists( 'url', $options ) && false === $options[ 'url' ] ? 'hidden' : 'text';
25 25
 
26 26
 		$output .= parent::render( array(
27 27
 			'type'  => $input_type,
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 				if ( $_id_value ) {
72 72
 					$image = wp_get_attachment_image( $_id_value, $img_size, null, array( 'class' => 'cmb-file-field-image' ) );
73 73
 				} else {
74
-					$size = is_array( $img_size ) ? $img_size[0] : 350;
74
+					$size = is_array( $img_size ) ? $img_size[ 0 ] : 350;
75 75
 					$image = '<img style="max-width: ' . absint( $size ) . 'px; width: 100%; height: auto;" src="' . $meta_value . '" alt="" />';
76 76
 				}
77 77
 
Please login to merge, or discard this patch.
includes/helper-functions.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -317,8 +317,8 @@
 block discarded – undo
317 317
 	 * Reimplementation of DateTime::createFromFormat for PHP < 5.3. :(
318 318
 	 * Borrowed from http://stackoverflow.com/questions/5399075/php-datetimecreatefromformat-in-5-2
319 319
 	 *
320
-	 * @param $date_format
321
-	 * @param $date_value
320
+	 * @param string $date_format
321
+	 * @param string $date_value
322 322
 	 *
323 323
 	 * @return DateTime
324 324
 	 */
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -86,13 +86,13 @@  discard block
 block discarded – undo
86 86
 	$oembed = cmb2_ajax()->get_oembed_no_edit( $args );
87 87
 
88 88
 	// Send back our embed
89
-	if ( $oembed['embed'] && $oembed['embed'] != $oembed['fallback'] ) {
90
-		return '<div class="cmb2-oembed">' . $oembed['embed'] . '</div>';
89
+	if ( $oembed[ 'embed' ] && $oembed[ 'embed' ] != $oembed[ 'fallback' ] ) {
90
+		return '<div class="cmb2-oembed">' . $oembed[ 'embed' ] . '</div>';
91 91
 	}
92 92
 
93
-	$error = sprintf( __( 'No oEmbed Results Found for %s. View more info at %s', 'cmb2' ), $oembed['fallback'], ' <a href="http://codex.wordpress.org/Embeds" target="_blank">codex.wordpress.org/Embeds</a>.' );
93
+	$error = sprintf( __( 'No oEmbed Results Found for %s. View more info at %s', 'cmb2' ), $oembed[ 'fallback' ], ' <a href="http://codex.wordpress.org/Embeds" target="_blank">codex.wordpress.org/Embeds</a>.' );
94 94
 
95
-	if ( isset( $args['wp_error'] ) && $args['wp_error'] ) {
95
+	if ( isset( $args[ 'wp_error' ] ) && $args[ 'wp_error' ] ) {
96 96
 		return new WP_Error( 'cmb2_get_oembed_result', $wp_error, compact( 'oembed', 'args' ) );
97 97
 	}
98 98
 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 		$cmb = CMB2_Boxes::get( $meta_box );
208 208
 	} else {
209 209
 		// See if we already have an instance of this metabox
210
-		$cmb = CMB2_Boxes::get( $meta_box['id'] );
210
+		$cmb = CMB2_Boxes::get( $meta_box[ 'id' ] );
211 211
 		// If not, we'll initate a new metabox
212 212
 		$cmb = $cmb ? $cmb : new CMB2( $meta_box, $object_id );
213 213
 	}
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 	) );
284 284
 
285 285
 	// Set object type explicitly (rather than trying to guess from context)
286
-	$cmb->object_type( $args['object_type'] );
286
+	$cmb->object_type( $args[ 'object_type' ] );
287 287
 
288 288
 	// Save the metabox if it's been submitted
289 289
 	// check permissions
@@ -291,32 +291,32 @@  discard block
 block discarded – undo
291 291
 	if (
292 292
 		$cmb->prop( 'save_fields' )
293 293
 		// check nonce
294
-		&& isset( $_POST['submit-cmb'], $_POST['object_id'], $_POST[ $cmb->nonce() ] )
294
+		&& isset( $_POST[ 'submit-cmb' ], $_POST[ 'object_id' ], $_POST[ $cmb->nonce() ] )
295 295
 		&& wp_verify_nonce( $_POST[ $cmb->nonce() ], $cmb->nonce() )
296
-		&& $object_id && $_POST['object_id'] == $object_id
296
+		&& $object_id && $_POST[ 'object_id' ] == $object_id
297 297
 	) {
298 298
 		$cmb->save_fields( $object_id, $cmb->object_type(), $_POST );
299 299
 	}
300 300
 
301 301
 	// Enqueue JS/CSS
302
-	if ( $args['cmb_styles'] ) {
302
+	if ( $args[ 'cmb_styles' ] ) {
303 303
 		CMB2_hookup::enqueue_cmb_css();
304 304
 	}
305 305
 
306
-	if ( $args['enqueue_js'] ) {
306
+	if ( $args[ 'enqueue_js' ] ) {
307 307
 		CMB2_hookup::enqueue_cmb_js();
308 308
 	}
309 309
 
310
-	$form_format = apply_filters( 'cmb2_get_metabox_form_format', $args['form_format'], $object_id, $cmb );
310
+	$form_format = apply_filters( 'cmb2_get_metabox_form_format', $args[ 'form_format' ], $object_id, $cmb );
311 311
 
312 312
 	$format_parts = explode( '%3$s', $form_format );
313 313
 
314 314
 	// Show cmb form
315
-	printf( $format_parts[0], $cmb->cmb_id, $object_id );
315
+	printf( $format_parts[ 0 ], $cmb->cmb_id, $object_id );
316 316
 	$cmb->show_form();
317 317
 
318
-	if ( isset( $format_parts[1] ) && $format_parts[1] ) {
319
-		printf( str_ireplace( '%4$s', '%1$s', $format_parts[1] ), $args['save_button'] );
318
+	if ( isset( $format_parts[ 1 ] ) && $format_parts[ 1 ] ) {
319
+		printf( str_ireplace( '%4$s', '%1$s', $format_parts[ 1 ] ), $args[ 'save_button' ] );
320 320
 	}
321 321
 
322 322
 }
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
  * @param  array   $args      Optional arguments array
330 330
  */
331 331
 function cmb2_metabox_form( $meta_box, $object_id = 0, $args = array() ) {
332
-	if ( ! isset( $args['echo'] ) || $args['echo'] ) {
332
+	if ( ! isset( $args[ 'echo' ] ) || $args[ 'echo' ] ) {
333 333
 		cmb2_print_metabox_form( $meta_box, $object_id, $args );
334 334
 	} else {
335 335
 		return cmb2_get_metabox_form( $meta_box, $object_id, $args );
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 
352 352
 		$schedule_format = str_replace(
353 353
 			array( 'M', 'Y', 'm', 'd', 'H', 'i', 'a' ),
354
-			array('%b', '%Y', '%m', '%d', '%H', '%M', '%p' ),
354
+			array( '%b', '%Y', '%m', '%d', '%H', '%M', '%p' ),
355 355
 			$date_format
356 356
 		);
357 357
 
@@ -368,14 +368,14 @@  discard block
 block discarded – undo
368 368
 			 * 4 or 2 characters, as needed
369 369
 			 */
370 370
 			'%04d-%02d-%02d %02d:%02d:%02d',
371
-			$parsed_time['tm_year'] + 1900,  // This will be "111", so we need to add 1900.
372
-			$parsed_time['tm_mon'] + 1,      // This will be the month minus one, so we add one.
373
-			$parsed_time['tm_mday'],
374
-			$parsed_time['tm_hour'],
375
-			$parsed_time['tm_min'],
376
-			$parsed_time['tm_sec']
371
+			$parsed_time[ 'tm_year' ] + 1900, // This will be "111", so we need to add 1900.
372
+			$parsed_time[ 'tm_mon' ] + 1, // This will be the month minus one, so we add one.
373
+			$parsed_time[ 'tm_mday' ],
374
+			$parsed_time[ 'tm_hour' ],
375
+			$parsed_time[ 'tm_min' ],
376
+			$parsed_time[ 'tm_sec' ]
377 377
 		);
378 378
 
379
-		return new DateTime($ymd);
379
+		return new DateTime( $ymd );
380 380
 	}
381 381
 }
Please login to merge, or discard this patch.
includes/CMB2.php 2 patches
Doc Comments   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -409,6 +409,7 @@  discard block
 block discarded – undo
409 409
 	 * Add a hidden field to the list of hidden fields to be rendered later
410 410
 	 * @since 2.0.0
411 411
 	 * @param array  $field_args Array of field arguments to be passed to CMB2_Field
412
+	 * @param CMB2_Field $field_group
412 413
 	 */
413 414
 	public function add_hidden_field( $field_args, $field_group = null ) {
414 415
 		if ( isset( $field_args['field_args'] ) ) {
@@ -610,7 +611,7 @@  discard block
 block discarded – undo
610 611
 	/**
611 612
 	 * Save a repeatable group
612 613
 	 * @since  1.x.x
613
-	 * @param  array $field_group CMB2_Field group field object
614
+	 * @param  CMB2_Field $field_group CMB2_Field group field object
614 615
 	 * @return mixed              Return of CMB2_Field::update_data()
615 616
 	 */
616 617
 	public function save_group_field( $field_group ) {
@@ -910,7 +911,7 @@  discard block
 block discarded – undo
910 911
 	 * @param  mixed  $field_id     Field (or group field) ID
911 912
 	 * @param  mixed  $field_args   Array of field arguments
912 913
 	 * @param  mixed  $sub_field_id Sub field ID (if field_group exists)
913
-	 * @param  mixed  $field_group  If a sub-field, will be the parent group CMB2_Field object
914
+	 * @param  CMB2_Field|null  $field_group  If a sub-field, will be the parent group CMB2_Field object
914 915
 	 * @return array                Array of CMB2_Field arguments
915 916
 	 */
916 917
 	public function get_field_args( $field_id, $field_args, $sub_field_id, $field_group ) {
@@ -997,7 +998,7 @@  discard block
 block discarded – undo
997 998
 	 * @since  2.0.0
998 999
 	 * @param  array  $field           Metabox field config array
999 1000
 	 * @param  int    $position        (optional) Position of metabox. 1 for first, etc
1000
-	 * @return mixed                   Field id or false
1001
+	 * @return string                   Field id or false
1001 1002
 	 */
1002 1003
 	public function add_field( array $field, $position = 0 ) {
1003 1004
 		if ( ! is_array( $field ) || ! array_key_exists( 'id', $field ) ) {
Please login to merge, or discard this patch.
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -125,19 +125,19 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	public function __construct( $meta_box, $object_id = 0 ) {
127 127
 
128
-		if ( empty( $meta_box['id'] ) ) {
128
+		if ( empty( $meta_box[ 'id' ] ) ) {
129 129
 			wp_die( __( 'Metabox configuration is required to have an ID parameter', 'cmb2' ) );
130 130
 		}
131 131
 
132 132
 		$this->meta_box = wp_parse_args( $meta_box, $this->mb_defaults );
133
-		$this->meta_box['fields'] = array();
133
+		$this->meta_box[ 'fields' ] = array();
134 134
 
135 135
 		$this->object_id( $object_id );
136 136
 		$this->mb_object_type();
137
-		$this->cmb_id = $meta_box['id'];
137
+		$this->cmb_id = $meta_box[ 'id' ];
138 138
 
139
-		if ( ! empty( $meta_box['fields'] ) && is_array( $meta_box['fields'] ) ) {
140
-			$this->add_fields( $meta_box['fields'] );
139
+		if ( ! empty( $meta_box[ 'fields' ] ) && is_array( $meta_box[ 'fields' ] ) ) {
140
+			$this->add_fields( $meta_box[ 'fields' ] );
141 141
 		}
142 142
 
143 143
 		CMB2_Boxes::add( $this );
@@ -308,22 +308,22 @@  discard block
 block discarded – undo
308 308
 	 * @return mixed CMB2_Field object if successful.
309 309
 	 */
310 310
 	public function render_field( $field_args ) {
311
-		$field_args['context'] = $this->prop( 'context' );
311
+		$field_args[ 'context' ] = $this->prop( 'context' );
312 312
 
313
-		if ( 'group' == $field_args['type'] ) {
313
+		if ( 'group' == $field_args[ 'type' ] ) {
314 314
 
315
-			if ( ! isset( $field_args['show_names'] ) ) {
316
-				$field_args['show_names'] = $this->prop( 'show_names' );
315
+			if ( ! isset( $field_args[ 'show_names' ] ) ) {
316
+				$field_args[ 'show_names' ] = $this->prop( 'show_names' );
317 317
 			}
318 318
 			$field = $this->render_group( $field_args );
319 319
 
320
-		} elseif ( 'hidden' == $field_args['type'] && $this->get_field( $field_args )->should_show() ) {
320
+		} elseif ( 'hidden' == $field_args[ 'type' ] && $this->get_field( $field_args )->should_show() ) {
321 321
 			// Save rendering for after the metabox
322 322
 			$field = $this->add_hidden_field( $field_args );
323 323
 
324 324
 		} else {
325 325
 
326
-			$field_args['show_names'] = $this->prop( 'show_names' );
326
+			$field_args[ 'show_names' ] = $this->prop( 'show_names' );
327 327
 
328 328
 			// Render default fields
329 329
 			$field = $this->get_field( $field_args )->render_field();
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 	 */
340 340
 	public function render_group( $args ) {
341 341
 
342
-		if ( ! isset( $args['id'], $args['fields'] ) || ! is_array( $args['fields'] ) ) {
342
+		if ( ! isset( $args[ 'id' ], $args[ 'fields' ] ) || ! is_array( $args[ 'fields' ] ) ) {
343 343
 			return;
344 344
 		}
345 345
 
@@ -421,15 +421,15 @@  discard block
 block discarded – undo
421 421
 			<div class="inside cmb-td cmb-nested cmb-field-list">';
422 422
 				// Loop and render repeatable group fields
423 423
 				foreach ( array_values( $field_group->args( 'fields' ) ) as $field_args ) {
424
-					if ( 'hidden' == $field_args['type'] ) {
424
+					if ( 'hidden' == $field_args[ 'type' ] ) {
425 425
 
426 426
 						// Save rendering for after the metabox
427 427
 						$this->add_hidden_field( $field_args, $field_group );
428 428
 
429 429
 					} else {
430 430
 
431
-						$field_args['show_names'] = $field_group->args( 'show_names' );
432
-						$field_args['context']    = $field_group->args( 'context' );
431
+						$field_args[ 'show_names' ] = $field_group->args( 'show_names' );
432
+						$field_args[ 'context' ]    = $field_group->args( 'context' );
433 433
 
434 434
 						$field = $this->get_field( $field_args, $field_group )->render_field();
435 435
 					}
@@ -457,14 +457,14 @@  discard block
 block discarded – undo
457 457
 	 * @param array  $field_args Array of field arguments to be passed to CMB2_Field
458 458
 	 */
459 459
 	public function add_hidden_field( $field_args, $field_group = null ) {
460
-		if ( isset( $field_args['field_args'] ) ) {
460
+		if ( isset( $field_args[ 'field_args' ] ) ) {
461 461
 			// For back-compatibility.
462 462
 			$field = new CMB2_Field( $field_args );
463 463
 		} else {
464 464
 			$field = $this->get_new_field( $field_args, $field_group );
465 465
 		}
466 466
 
467
-		$this->hidden_fields[] = new CMB2_Types( $field );
467
+		$this->hidden_fields[ ] = new CMB2_Types( $field );
468 468
 
469 469
 		return $field;
470 470
 	}
@@ -561,11 +561,11 @@  discard block
 block discarded – undo
561 561
 	 */
562 562
 	public function process_field( $field_args ) {
563 563
 
564
-		switch ( $field_args['type'] ) {
564
+		switch ( $field_args[ 'type' ] ) {
565 565
 
566 566
 			case 'group':
567 567
 				if ( $this->save_group( $field_args ) ) {
568
-					$this->updated[] = $field_args['id'];
568
+					$this->updated[ ] = $field_args[ 'id' ];
569 569
 				}
570 570
 
571 571
 				break;
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
 				$field = $this->get_new_field( $field_args );
580 580
 
581 581
 				if ( $field->save_field_from_data( $this->data_to_save ) ) {
582
-					$this->updated[] = $field->id();
582
+					$this->updated[ ] = $field->id();
583 583
 				}
584 584
 
585 585
 				break;
@@ -646,7 +646,7 @@  discard block
 block discarded – undo
646 646
 	 * @return mixed        Return of CMB2_Field::update_data()
647 647
 	 */
648 648
 	public function save_group( $args ) {
649
-		if ( ! isset( $args['id'], $args['fields'] ) || ! is_array( $args['fields'] ) ) {
649
+		if ( ! isset( $args[ 'id' ], $args[ 'fields' ] ) || ! is_array( $args[ 'fields' ] ) ) {
650 650
 			return;
651 651
 		}
652 652
 
@@ -694,16 +694,16 @@  discard block
 block discarded – undo
694 694
 						$_new_val = array();
695 695
 						foreach ( $new_val as $group_index => $grouped_data ) {
696 696
 							// Add the supporting data to the $saved array stack
697
-							$saved[ $field_group->index ][ $grouped_data['supporting_field_id'] ][] = $grouped_data['supporting_field_value'];
697
+							$saved[ $field_group->index ][ $grouped_data[ 'supporting_field_id' ] ][ ] = $grouped_data[ 'supporting_field_value' ];
698 698
 							// Reset var to the actual value
699
-							$_new_val[ $group_index ] = $grouped_data['value'];
699
+							$_new_val[ $group_index ] = $grouped_data[ 'value' ];
700 700
 						}
701 701
 						$new_val = $_new_val;
702 702
 					} else {
703 703
 						// Add the supporting data to the $saved array stack
704
-						$saved[ $field_group->index ][ $new_val['supporting_field_id'] ] = $new_val['supporting_field_value'];
704
+						$saved[ $field_group->index ][ $new_val[ 'supporting_field_id' ] ] = $new_val[ 'supporting_field_value' ];
705 705
 						// Reset var to the actual value
706
-						$new_val = $new_val['value'];
706
+						$new_val = $new_val[ 'value' ];
707 707
 					}
708 708
 				}
709 709
 
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
 
718 718
 				// Compare values and add to `$updated` array
719 719
 				if ( $is_updated || $is_removed ) {
720
-					$this->updated[] = $base_id . '::' . $field_group->index . '::' . $sub_id;
720
+					$this->updated[ ] = $base_id . '::' . $field_group->index . '::' . $sub_id;
721 721
 				}
722 722
 
723 723
 				// Add to `$saved` array
@@ -754,22 +754,22 @@  discard block
 block discarded – undo
754 754
 		// Try to get our object ID from the global space
755 755
 		switch ( $this->object_type() ) {
756 756
 			case 'user':
757
-				$object_id = isset( $_REQUEST['user_id'] ) ? $_REQUEST['user_id'] : $object_id;
758
-				$object_id = ! $object_id && 'user-new.php' != $pagenow && isset( $GLOBALS['user_ID'] ) ? $GLOBALS['user_ID'] : $object_id;
757
+				$object_id = isset( $_REQUEST[ 'user_id' ] ) ? $_REQUEST[ 'user_id' ] : $object_id;
758
+				$object_id = ! $object_id && 'user-new.php' != $pagenow && isset( $GLOBALS[ 'user_ID' ] ) ? $GLOBALS[ 'user_ID' ] : $object_id;
759 759
 				break;
760 760
 
761 761
 			case 'comment':
762
-				$object_id = isset( $_REQUEST['c'] ) ? $_REQUEST['c'] : $object_id;
763
-				$object_id = ! $object_id && isset( $GLOBALS['comments']->comment_ID ) ? $GLOBALS['comments']->comment_ID : $object_id;
762
+				$object_id = isset( $_REQUEST[ 'c' ] ) ? $_REQUEST[ 'c' ] : $object_id;
763
+				$object_id = ! $object_id && isset( $GLOBALS[ 'comments' ]->comment_ID ) ? $GLOBALS[ 'comments' ]->comment_ID : $object_id;
764 764
 				break;
765 765
 
766 766
 			case 'term':
767
-				$object_id = isset( $_REQUEST['tag_ID'] ) ? $_REQUEST['tag_ID'] : $object_id;
767
+				$object_id = isset( $_REQUEST[ 'tag_ID' ] ) ? $_REQUEST[ 'tag_ID' ] : $object_id;
768 768
 				break;
769 769
 
770 770
 			default:
771
-				$object_id = isset( $GLOBALS['post']->ID ) ? $GLOBALS['post']->ID : $object_id;
772
-				$object_id = isset( $_REQUEST['post'] ) ? $_REQUEST['post'] : $object_id;
771
+				$object_id = isset( $GLOBALS[ 'post' ]->ID ) ? $GLOBALS[ 'post' ]->ID : $object_id;
772
+				$object_id = isset( $_REQUEST[ 'post' ] ) ? $_REQUEST[ 'post' ] : $object_id;
773 773
 				break;
774 774
 		}
775 775
 
@@ -845,7 +845,7 @@  discard block
 block discarded – undo
845 845
 	 * @return boolean True/False
846 846
 	 */
847 847
 	public function is_options_page_mb() {
848
-		return ( isset( $this->meta_box['show_on']['key'] ) && 'options-page' === $this->meta_box['show_on']['key'] || array_key_exists( 'options-page', $this->meta_box['show_on'] ) );
848
+		return ( isset( $this->meta_box[ 'show_on' ][ 'key' ] ) && 'options-page' === $this->meta_box[ 'show_on' ][ 'key' ] || array_key_exists( 'options-page', $this->meta_box[ 'show_on' ] ) );
849 849
 	}
850 850
 
851 851
 	/**
@@ -932,7 +932,7 @@  discard block
 block discarded – undo
932 932
 			return $field;
933 933
 		}
934 934
 
935
-		$field_id = is_string( $field ) ? $field : $field['id'];
935
+		$field_id = is_string( $field ) ? $field : $field[ 'id' ];
936 936
 
937 937
 		$parent_field_id = ! empty( $field_group ) ? $field_group->id() : '';
938 938
 		$ids = $this->get_field_ids( $field_id, $parent_field_id, true );
@@ -968,16 +968,16 @@  discard block
 block discarded – undo
968 968
 		if ( $field_group && ( $sub_field_id || 0 === $sub_field_id ) ) {
969 969
 
970 970
 			// Update the fields array w/ any modified properties inherited from the group field
971
-			$this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] = $field_args;
971
+			$this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] = $field_args;
972 972
 
973 973
 			return $this->get_default_args( $field_args, $field_group );
974 974
 		}
975 975
 
976 976
 		if ( is_array( $field_args ) ) {
977
-			$this->meta_box['fields'][ $field_id ] = array_merge( $field_args, $this->meta_box['fields'][ $field_id ] );
977
+			$this->meta_box[ 'fields' ][ $field_id ] = array_merge( $field_args, $this->meta_box[ 'fields' ][ $field_id ] );
978 978
 		}
979 979
 
980
-		return $this->get_default_args( $this->meta_box['fields'][ $field_id ] );
980
+		return $this->get_default_args( $this->meta_box[ 'fields' ][ $field_id ] );
981 981
 	}
982 982
 
983 983
 	/**
@@ -1027,8 +1027,8 @@  discard block
 block discarded – undo
1027 1027
 
1028 1028
 			$sub_fields = false;
1029 1029
 			if ( array_key_exists( 'fields', $field ) ) {
1030
-				$sub_fields = $field['fields'];
1031
-				unset( $field['fields'] );
1030
+				$sub_fields = $field[ 'fields' ];
1031
+				unset( $field[ 'fields' ] );
1032 1032
 			}
1033 1033
 
1034 1034
 			$field_id = $parent_field_id
@@ -1053,29 +1053,29 @@  discard block
 block discarded – undo
1053 1053
 			return false;
1054 1054
 		}
1055 1055
 
1056
-		if ( 'oembed' === $field['type'] ) {
1056
+		if ( 'oembed' === $field[ 'type' ] ) {
1057 1057
 			// Initiate oembed Ajax hooks
1058 1058
 			cmb2_ajax();
1059 1059
 		}
1060 1060
 
1061
-		if ( isset( $field['column'] ) && false !== $field['column'] ) {
1061
+		if ( isset( $field[ 'column' ] ) && false !== $field[ 'column' ] ) {
1062 1062
 			$this->has_columns = true;
1063 1063
 
1064
-			$column = is_array( $field['column'] ) ? $field['column'] : array();
1064
+			$column = is_array( $field[ 'column' ] ) ? $field[ 'column' ] : array();
1065 1065
 
1066
-			$field['column'] = wp_parse_args( $column, array(
1067
-				'name'     => isset( $field['name'] ) ? $field['name'] : '',
1066
+			$field[ 'column' ] = wp_parse_args( $column, array(
1067
+				'name'     => isset( $field[ 'name' ] ) ? $field[ 'name' ] : '',
1068 1068
 				'position' => false,
1069 1069
 			) );
1070 1070
 		}
1071 1071
 
1072 1072
 		$this->_add_field_to_array(
1073 1073
 			$field,
1074
-			$this->meta_box['fields'],
1074
+			$this->meta_box[ 'fields' ],
1075 1075
 			$position
1076 1076
 		);
1077 1077
 
1078
-		return $field['id'];
1078
+		return $field[ 'id' ];
1079 1079
 	}
1080 1080
 
1081 1081
 	/**
@@ -1087,27 +1087,27 @@  discard block
 block discarded – undo
1087 1087
 	 * @return mixed                   Array of parent/field ids or false
1088 1088
 	 */
1089 1089
 	public function add_group_field( $parent_field_id, array $field, $position = 0 ) {
1090
-		if ( ! array_key_exists( $parent_field_id, $this->meta_box['fields'] ) ) {
1090
+		if ( ! array_key_exists( $parent_field_id, $this->meta_box[ 'fields' ] ) ) {
1091 1091
 			return false;
1092 1092
 		}
1093 1093
 
1094
-		$parent_field = $this->meta_box['fields'][ $parent_field_id ];
1094
+		$parent_field = $this->meta_box[ 'fields' ][ $parent_field_id ];
1095 1095
 
1096
-		if ( 'group' !== $parent_field['type'] ) {
1096
+		if ( 'group' !== $parent_field[ 'type' ] ) {
1097 1097
 			return false;
1098 1098
 		}
1099 1099
 
1100
-		if ( ! isset( $parent_field['fields'] ) ) {
1101
-			$this->meta_box['fields'][ $parent_field_id ]['fields'] = array();
1100
+		if ( ! isset( $parent_field[ 'fields' ] ) ) {
1101
+			$this->meta_box[ 'fields' ][ $parent_field_id ][ 'fields' ] = array();
1102 1102
 		}
1103 1103
 
1104 1104
 		$this->_add_field_to_array(
1105 1105
 			$field,
1106
-			$this->meta_box['fields'][ $parent_field_id ]['fields'],
1106
+			$this->meta_box[ 'fields' ][ $parent_field_id ][ 'fields' ],
1107 1107
 			$position
1108 1108
 		);
1109 1109
 
1110
-		return array( $parent_field_id, $field['id'] );
1110
+		return array( $parent_field_id, $field[ 'id' ] );
1111 1111
 	}
1112 1112
 
1113 1113
 	/**
@@ -1119,9 +1119,9 @@  discard block
 block discarded – undo
1119 1119
 	 */
1120 1120
 	protected function _add_field_to_array( $field, &$fields, $position = 0 ) {
1121 1121
 		if ( $position ) {
1122
-			cmb2_utils()->array_insert( $fields, array( $field['id'] => $field ), $position );
1122
+			cmb2_utils()->array_insert( $fields, array( $field[ 'id' ] => $field ), $position );
1123 1123
 		} else {
1124
-			$fields[ $field['id'] ] = $field;
1124
+			$fields[ $field[ 'id' ] ] = $field;
1125 1125
 		}
1126 1126
 	}
1127 1127
 
@@ -1144,15 +1144,15 @@  discard block
 block discarded – undo
1144 1144
 		unset( $this->fields[ implode( '', $ids ) ] );
1145 1145
 
1146 1146
 		if ( ! $sub_field_id ) {
1147
-			unset( $this->meta_box['fields'][ $field_id ] );
1147
+			unset( $this->meta_box[ 'fields' ][ $field_id ] );
1148 1148
 			return true;
1149 1149
 		}
1150 1150
 
1151
-		if ( isset( $this->fields[ $field_id ]->args['fields'][ $sub_field_id ] ) ) {
1152
-			unset( $this->fields[ $field_id ]->args['fields'][ $sub_field_id ] );
1151
+		if ( isset( $this->fields[ $field_id ]->args[ 'fields' ][ $sub_field_id ] ) ) {
1152
+			unset( $this->fields[ $field_id ]->args[ 'fields' ][ $sub_field_id ] );
1153 1153
 		}
1154
-		if ( isset( $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] ) ) {
1155
-			unset( $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] );
1154
+		if ( isset( $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] ) ) {
1155
+			unset( $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] );
1156 1156
 		}
1157 1157
 		return true;
1158 1158
 	}
@@ -1176,11 +1176,11 @@  discard block
 block discarded – undo
1176 1176
 		list( $field_id, $sub_field_id ) = $ids;
1177 1177
 
1178 1178
 		if ( ! $sub_field_id ) {
1179
-			$this->meta_box['fields'][ $field_id ][ $property ] = $value;
1179
+			$this->meta_box[ 'fields' ][ $field_id ][ $property ] = $value;
1180 1180
 			return $field_id;
1181 1181
 		}
1182 1182
 
1183
-		$this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ][ $property ] = $value;
1183
+		$this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ][ $property ] = $value;
1184 1184
 		return $field_id;
1185 1185
 	}
1186 1186
 
@@ -1194,7 +1194,7 @@  discard block
 block discarded – undo
1194 1194
 	public function get_field_ids( $field_id, $parent_field_id = '' ) {
1195 1195
 		$sub_field_id = $parent_field_id ? $field_id : '';
1196 1196
 		$field_id     = $parent_field_id ? $parent_field_id : $field_id;
1197
-		$fields       =& $this->meta_box['fields'];
1197
+		$fields       = & $this->meta_box[ 'fields' ];
1198 1198
 
1199 1199
 		if ( ! array_key_exists( $field_id, $fields ) ) {
1200 1200
 			$field_id = $this->search_old_school_array( $field_id, $fields );
@@ -1208,12 +1208,12 @@  discard block
 block discarded – undo
1208 1208
 			return array( $field_id, $sub_field_id );
1209 1209
 		}
1210 1210
 
1211
-		if ( 'group' !== $fields[ $field_id ]['type'] ) {
1211
+		if ( 'group' !== $fields[ $field_id ][ 'type' ] ) {
1212 1212
 			return false;
1213 1213
 		}
1214 1214
 
1215
-		if ( ! array_key_exists( $sub_field_id, $fields[ $field_id ]['fields'] ) ) {
1216
-			$sub_field_id = $this->search_old_school_array( $sub_field_id, $fields[ $field_id ]['fields'] );
1215
+		if ( ! array_key_exists( $sub_field_id, $fields[ $field_id ][ 'fields' ] ) ) {
1216
+			$sub_field_id = $this->search_old_school_array( $sub_field_id, $fields[ $field_id ][ 'fields' ] );
1217 1217
 		}
1218 1218
 
1219 1219
 		return false === $sub_field_id ? false : array( $field_id, $sub_field_id );
Please login to merge, or discard this patch.
includes/CMB2_Field.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
 	 * Return a formatted timestamp for a field
736 736
 	 * @since  2.0.0
737 737
 	 * @param  string $format     Either date_format or time_format
738
-	 * @param  string $meta_value Optional meta value to check
738
+	 * @param  integer $meta_value Optional meta value to check
739 739
 	 * @return string             Formatted date
740 740
 	 */
741 741
 	public function get_timestamp_format( $format = 'date_format', $meta_value = 0 ) {
@@ -1007,7 +1007,7 @@  discard block
 block discarded – undo
1007 1007
 	 * Retrieve options args. Calls options_cb if it exists.
1008 1008
 	 * @since  2.0.0
1009 1009
 	 * @param  string  $key Specific option to retrieve
1010
-	 * @return array        Array of options
1010
+	 * @return string        Array of options
1011 1011
 	 */
1012 1012
 	public function options( $key = '' ) {
1013 1013
 		if ( ! empty( $this->field_options ) ) {
Please login to merge, or discard this patch.
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -131,21 +131,21 @@  discard block
 block discarded – undo
131 131
 	 */
132 132
 	public function __construct( $args ) {
133 133
 
134
-		if ( ! empty( $args['group_field'] ) ) {
135
-			$this->group       = $args['group_field'];
134
+		if ( ! empty( $args[ 'group_field' ] ) ) {
135
+			$this->group       = $args[ 'group_field' ];
136 136
 			$this->object_id   = $this->group->object_id;
137 137
 			$this->object_type = $this->group->object_type;
138 138
 			$this->cmb_id      = $this->group->cmb_id;
139 139
 		} else {
140
-			$this->object_id   = isset( $args['object_id'] ) && '_' !== $args['object_id'] ? $args['object_id'] : 0;
141
-			$this->object_type = isset( $args['object_type'] ) ? $args['object_type'] : 'post';
140
+			$this->object_id   = isset( $args[ 'object_id' ] ) && '_' !== $args[ 'object_id' ] ? $args[ 'object_id' ] : 0;
141
+			$this->object_type = isset( $args[ 'object_type' ] ) ? $args[ 'object_type' ] : 'post';
142 142
 
143
-			if ( isset( $args['cmb_id'] ) ) {
144
-				$this->cmb_id = $args['cmb_id'];
143
+			if ( isset( $args[ 'cmb_id' ] ) ) {
144
+				$this->cmb_id = $args[ 'cmb_id' ];
145 145
 			}
146 146
 		}
147 147
 
148
-		$this->args = $this->_set_field_defaults( $args['field_args'] );
148
+		$this->args = $this->_set_field_defaults( $args[ 'field_args' ] );
149 149
 
150 150
 		if ( $this->object_id ) {
151 151
 			$this->value = $this->get_data();
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	 * @return mixed             Value of field argument
161 161
 	 */
162 162
 	public function __call( $name, $arguments ) {
163
-		$key = isset( $arguments[0] ) ? $arguments[0] : false;
163
+		$key = isset( $arguments[ 0 ] ) ? $arguments[ 0 ] : false;
164 164
 		return $this->args( $name, $key );
165 165
 	}
166 166
 
@@ -231,9 +231,9 @@  discard block
 block discarded – undo
231 231
 	 */
232 232
 	public function get_data( $field_id = '', $args = array() ) {
233 233
 		if ( $field_id ) {
234
-			$args['field_id'] = $field_id;
234
+			$args[ 'field_id' ] = $field_id;
235 235
 		} else if ( $this->group ) {
236
-			$args['field_id'] = $this->group->id();
236
+			$args[ 'field_id' ] = $this->group->id();
237 237
 		}
238 238
 
239 239
 		$a = $this->data_args( $args );
@@ -274,13 +274,13 @@  discard block
 block discarded – undo
274 274
 		 *
275 275
 		 * @since 2.0.0
276 276
 		 */
277
-		$data = apply_filters( "cmb2_override_{$a['field_id']}_meta_value", $data, $this->object_id, $a, $this );
277
+		$data = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_value", $data, $this->object_id, $a, $this );
278 278
 
279 279
 		// If no override, get value normally
280 280
 		if ( 'cmb2_field_no_override_val' === $data ) {
281
-			$data = 'options-page' === $a['type']
282
-				? cmb2_options( $a['id'] )->get( $a['field_id'] )
283
-				: get_metadata( $a['type'], $a['id'], $a['field_id'], ( $a['single'] || $a['repeat'] ) );
281
+			$data = 'options-page' === $a[ 'type' ]
282
+				? cmb2_options( $a[ 'id' ] )->get( $a[ 'field_id' ] )
283
+				: get_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], ( $a[ 'single' ] || $a[ 'repeat' ] ) );
284 284
 		}
285 285
 
286 286
 		if ( $this->group ) {
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 	public function update_data( $new_value, $single = true ) {
303 303
 		$a = $this->data_args( array( 'single' => $single ) );
304 304
 
305
-		$a['value'] = $a['repeat'] ? array_values( $new_value ) : $new_value;
305
+		$a[ 'value' ] = $a[ 'repeat' ] ? array_values( $new_value ) : $new_value;
306 306
 
307 307
 		/**
308 308
 		 * Filter whether to override saving of meta value.
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 		 *
339 339
 		 * @since 2.0.0
340 340
 		 */
341
-		$override = apply_filters( "cmb2_override_{$a['field_id']}_meta_save", $override, $a, $this->args(), $this );
341
+		$override = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_save", $override, $a, $this->args(), $this );
342 342
 
343 343
 		// If override, return that
344 344
 		if ( null !== $override ) {
@@ -346,22 +346,22 @@  discard block
 block discarded – undo
346 346
 		}
347 347
 
348 348
 		// Options page handling (or temp data store)
349
-		if ( 'options-page' === $a['type'] || empty( $a['id'] ) ) {
350
-			return cmb2_options( $a['id'] )->update( $a['field_id'], $a['value'], false, $a['single'] );
349
+		if ( 'options-page' === $a[ 'type' ] || empty( $a[ 'id' ] ) ) {
350
+			return cmb2_options( $a[ 'id' ] )->update( $a[ 'field_id' ], $a[ 'value' ], false, $a[ 'single' ] );
351 351
 		}
352 352
 
353 353
 		// Add metadata if not single
354
-		if ( ! $a['single'] ) {
355
-			return add_metadata( $a['type'], $a['id'], $a['field_id'], $a['value'], false );
354
+		if ( ! $a[ 'single' ] ) {
355
+			return add_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $a[ 'value' ], false );
356 356
 		}
357 357
 
358 358
 		// Delete meta if we have an empty array
359
-		if ( is_array( $a['value'] ) && empty( $a['value'] ) ) {
360
-			return delete_metadata( $a['type'], $a['id'], $a['field_id'], $this->value );
359
+		if ( is_array( $a[ 'value' ] ) && empty( $a[ 'value' ] ) ) {
360
+			return delete_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $this->value );
361 361
 		}
362 362
 
363 363
 		// Update metadata
364
-		return update_metadata( $a['type'], $a['id'], $a['field_id'], $a['value'] );
364
+		return update_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $a[ 'value' ] );
365 365
 	}
366 366
 
367 367
 	/**
@@ -411,19 +411,19 @@  discard block
 block discarded – undo
411 411
 		 * @param array $field_args All field arguments
412 412
 		 * @param CMB2_Field object $field This field object
413 413
 		 */
414
-		$override = apply_filters( "cmb2_override_{$a['field_id']}_meta_remove", $override, $a, $this->args(), $this );
414
+		$override = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_remove", $override, $a, $this->args(), $this );
415 415
 
416 416
 		// If no override, remove as usual
417 417
 		if ( null !== $override ) {
418 418
 			return $override;
419 419
 		}
420 420
 		// Option page handling
421
-		elseif ( 'options-page' === $a['type'] || empty( $a['id'] ) ) {
422
-			return cmb2_options( $a['id'] )->remove( $a['field_id'] );
421
+		elseif ( 'options-page' === $a[ 'type' ] || empty( $a[ 'id' ] ) ) {
422
+			return cmb2_options( $a[ 'id' ] )->remove( $a[ 'field_id' ] );
423 423
 		}
424 424
 
425 425
 		// Remove metadata
426
-		return delete_metadata( $a['type'], $a['id'], $a['field_id'], $old );
426
+		return delete_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $old );
427 427
 	}
428 428
 
429 429
 	/**
@@ -895,7 +895,7 @@  discard block
 block discarded – undo
895 895
 
896 896
 		foreach ( $conditional_classes as $class => $condition ) {
897 897
 			if ( $condition ) {
898
-				$classes[] = $class;
898
+				$classes[ ] = $class;
899 899
 			}
900 900
 		}
901 901
 
@@ -904,7 +904,7 @@  discard block
 block discarded – undo
904 904
 		}
905 905
 
906 906
 		if ( $added_classes ) {
907
-			$classes[] = esc_attr( $added_classes );
907
+			$classes[ ] = esc_attr( $added_classes );
908 908
 		}
909 909
 
910 910
 		/**
@@ -1006,10 +1006,10 @@  discard block
 block discarded – undo
1006 1006
 	public function string( $text_key, $fallback ) {
1007 1007
 		// If null, populate with our field strings values.
1008 1008
 		if ( null === $this->strings ) {
1009
-			$this->strings = (array) $this->args['text'];
1009
+			$this->strings = (array) $this->args[ 'text' ];
1010 1010
 
1011
-			if ( is_callable( $this->args['text_cb'] ) ) {
1012
-				$strings = call_user_func( $this->args['text_cb'], $this );
1011
+			if ( is_callable( $this->args[ 'text_cb' ] ) ) {
1012
+				$strings = call_user_func( $this->args[ 'text_cb' ], $this );
1013 1013
 
1014 1014
 				if ( $strings && is_array( $strings ) ) {
1015 1015
 					$this->strings += $strings;
@@ -1043,10 +1043,10 @@  discard block
 block discarded – undo
1043 1043
 			return $this->field_options;
1044 1044
 		}
1045 1045
 
1046
-		$this->field_options = (array) $this->args['options'];
1046
+		$this->field_options = (array) $this->args[ 'options' ];
1047 1047
 
1048
-		if ( is_callable( $this->args['options_cb'] ) ) {
1049
-			$options = call_user_func( $this->args['options_cb'], $this );
1048
+		if ( is_callable( $this->args[ 'options_cb' ] ) ) {
1049
+			$options = call_user_func( $this->args[ 'options_cb' ], $this );
1050 1050
 
1051 1051
 			if ( $options && is_array( $options ) ) {
1052 1052
 				$this->field_options += $options;
@@ -1067,7 +1067,7 @@  discard block
 block discarded – undo
1067 1067
 	 */
1068 1068
 	public function add_js_dependencies( $dependencies = array() ) {
1069 1069
 		foreach ( (array) $dependencies as $dependency ) {
1070
-			$this->args['js_dependencies'][ $dependency ] = $dependency;
1070
+			$this->args[ 'js_dependencies' ][ $dependency ] = $dependency;
1071 1071
 		}
1072 1072
 
1073 1073
 		CMB2_JS::add_dependencies( $dependencies );
@@ -1081,17 +1081,17 @@  discard block
 block discarded – undo
1081 1081
 	 * @return mixed  Default field value
1082 1082
 	 */
1083 1083
 	public function get_default() {
1084
-		if ( null !== $this->args['default'] ) {
1085
-			return $this->args['default'];
1084
+		if ( null !== $this->args[ 'default' ] ) {
1085
+			return $this->args[ 'default' ];
1086 1086
 		}
1087 1087
 
1088
-		$param = is_callable( $this->args['default_cb'] ) ? 'default_cb' : 'default';
1088
+		$param = is_callable( $this->args[ 'default_cb' ] ) ? 'default_cb' : 'default';
1089 1089
 		$default = $this->get_param_callback_result( $param, false );
1090 1090
 
1091 1091
 		// Allow a filter override of the default value
1092
-		$this->args['default'] = apply_filters( 'cmb2_default_filter', $default, $this );
1092
+		$this->args[ 'default' ] = apply_filters( 'cmb2_default_filter', $default, $this );
1093 1093
 
1094
-		return $this->args['default'];
1094
+		return $this->args[ 'default' ];
1095 1095
 	}
1096 1096
 
1097 1097
 	/**
@@ -1118,70 +1118,70 @@  discard block
 block discarded – undo
1118 1118
 			'default_cb'        => '',
1119 1119
 			'select_all_button' => true,
1120 1120
 			'multiple'          => false,
1121
-			'repeatable'        => isset( $args['type'] ) && 'group' == $args['type'],
1121
+			'repeatable'        => isset( $args[ 'type' ] ) && 'group' == $args[ 'type' ],
1122 1122
 			'inline'            => false,
1123 1123
 			'on_front'          => true,
1124 1124
 			'show_names'        => true,
1125 1125
 			'date_format'       => 'm\/d\/Y',
1126 1126
 			'time_format'       => 'h:i A',
1127
-			'description'       => isset( $args['desc'] ) ? $args['desc'] : '',
1128
-			'preview_size'      => 'file' == $args['type'] ? array( 350, 350 ) : array( 50, 50 ),
1127
+			'description'       => isset( $args[ 'desc' ] ) ? $args[ 'desc' ] : '',
1128
+			'preview_size'      => 'file' == $args[ 'type' ] ? array( 350, 350 ) : array( 50, 50 ),
1129 1129
 			'render_row_cb'     => array( $this, 'render_field_callback' ),
1130
-			'label_cb'          => 'title' != $args['type'] ? array( $this, 'label' ) : '',
1130
+			'label_cb'          => 'title' != $args[ 'type' ] ? array( $this, 'label' ) : '',
1131 1131
 			'show_in_rest'      => null,
1132 1132
 			'js_dependencies'   => array(),
1133 1133
 		) );
1134 1134
 
1135 1135
 		// default param can be passed a callback as well
1136
-		if ( is_callable( $args['default'] ) ) {
1137
-			$args['default_cb'] = $args['default'];
1138
-			$args['default'] = null;
1136
+		if ( is_callable( $args[ 'default' ] ) ) {
1137
+			$args[ 'default_cb' ] = $args[ 'default' ];
1138
+			$args[ 'default' ] = null;
1139 1139
 		}
1140 1140
 
1141
-		$args['repeatable'] = $args['repeatable'] && ! $this->repeatable_exception( $args['type'] );
1142
-		$args['inline']     = $args['inline'] || false !== stripos( $args['type'], '_inline' );
1141
+		$args[ 'repeatable' ] = $args[ 'repeatable' ] && ! $this->repeatable_exception( $args[ 'type' ] );
1142
+		$args[ 'inline' ]     = $args[ 'inline' ] || false !== stripos( $args[ 'type' ], '_inline' );
1143 1143
 
1144 1144
 		// options param can be passed a callback as well
1145
-		if ( is_callable( $args['options'] ) ) {
1146
-			$args['options_cb'] = $args['options'];
1147
-			$args['options'] = array();
1145
+		if ( is_callable( $args[ 'options' ] ) ) {
1146
+			$args[ 'options_cb' ] = $args[ 'options' ];
1147
+			$args[ 'options' ] = array();
1148 1148
 		}
1149 1149
 
1150
-		$args['options']    = 'group' == $args['type'] ? wp_parse_args( $args['options'], array(
1150
+		$args[ 'options' ] = 'group' == $args[ 'type' ] ? wp_parse_args( $args[ 'options' ], array(
1151 1151
 			'add_button'    => __( 'Add Group', 'cmb2' ),
1152 1152
 			'remove_button' => __( 'Remove Group', 'cmb2' ),
1153
-		) ) : $args['options'];
1153
+		) ) : $args[ 'options' ];
1154 1154
 
1155
-		$args['_id']        = $args['id'];
1156
-		$args['_name']      = $args['id'];
1155
+		$args[ '_id' ]        = $args[ 'id' ];
1156
+		$args[ '_name' ]      = $args[ 'id' ];
1157 1157
 
1158 1158
 		if ( $this->group ) {
1159 1159
 
1160
-			$args['id']    = $this->group->args( 'id' ) . '_' . $this->group->index . '_' . $args['id'];
1161
-			$args['_name'] = $this->group->args( 'id' ) . '[' . $this->group->index . '][' . $args['_name'] . ']';
1160
+			$args[ 'id' ]    = $this->group->args( 'id' ) . '_' . $this->group->index . '_' . $args[ 'id' ];
1161
+			$args[ '_name' ] = $this->group->args( 'id' ) . '[' . $this->group->index . '][' . $args[ '_name' ] . ']';
1162 1162
 		}
1163 1163
 
1164
-		if ( 'wysiwyg' == $args['type'] ) {
1165
-			$args['id'] = strtolower( str_ireplace( '-', '_', $args['id'] ) );
1166
-			$args['options']['textarea_name'] = $args['_name'];
1164
+		if ( 'wysiwyg' == $args[ 'type' ] ) {
1165
+			$args[ 'id' ] = strtolower( str_ireplace( '-', '_', $args[ 'id' ] ) );
1166
+			$args[ 'options' ][ 'textarea_name' ] = $args[ '_name' ];
1167 1167
 		}
1168 1168
 
1169 1169
 		$option_types = apply_filters( 'cmb2_all_or_nothing_types', array( 'select', 'radio', 'radio_inline', 'taxonomy_select', 'taxonomy_radio', 'taxonomy_radio_inline' ), $this );
1170 1170
 
1171
-		if ( in_array( $args['type'], $option_types, true ) ) {
1171
+		if ( in_array( $args[ 'type' ], $option_types, true ) ) {
1172 1172
 
1173
-			$args['show_option_none'] = isset( $args['show_option_none'] ) ? $args['show_option_none'] : null;
1174
-			$args['show_option_none'] = true === $args['show_option_none'] ? __( 'None', 'cmb2' ) : $args['show_option_none'];
1173
+			$args[ 'show_option_none' ] = isset( $args[ 'show_option_none' ] ) ? $args[ 'show_option_none' ] : null;
1174
+			$args[ 'show_option_none' ] = true === $args[ 'show_option_none' ] ? __( 'None', 'cmb2' ) : $args[ 'show_option_none' ];
1175 1175
 
1176
-			if ( null === $args['show_option_none'] ) {
1177
-				$off_by_default = in_array( $args['type'], array( 'select', 'radio', 'radio_inline' ), true );
1178
-				$args['show_option_none'] = $off_by_default ? false : __( 'None', 'cmb2' );
1176
+			if ( null === $args[ 'show_option_none' ] ) {
1177
+				$off_by_default = in_array( $args[ 'type' ], array( 'select', 'radio', 'radio_inline' ), true );
1178
+				$args[ 'show_option_none' ] = $off_by_default ? false : __( 'None', 'cmb2' );
1179 1179
 			}
1180 1180
 
1181 1181
 		}
1182 1182
 
1183
-		$args['has_supporting_data'] = in_array(
1184
-			$args['type'],
1183
+		$args[ 'has_supporting_data' ] = in_array(
1184
+			$args[ 'type' ],
1185 1185
 			array(
1186 1186
 				// CMB2_Sanitize::_save_file_id_value()/CMB2_Sanitize::_get_group_file_value_array()
1187 1187
 				'file',
@@ -1213,10 +1213,10 @@  discard block
 block discarded – undo
1213 1213
 			'cmb_id'      => $this->cmb_id,
1214 1214
 		);
1215 1215
 
1216
-		if ( isset( $field_args['field_args'] ) ) {
1216
+		if ( isset( $field_args[ 'field_args' ] ) ) {
1217 1217
 			$args = wp_parse_args( $field_args, $args );
1218 1218
 		} else {
1219
-			$args['field_args'] = wp_parse_args( $field_args, $this->args );
1219
+			$args[ 'field_args' ] = wp_parse_args( $field_args, $this->args );
1220 1220
 		}
1221 1221
 
1222 1222
 		return new CMB2_Field( $args );
Please login to merge, or discard this patch.
includes/CMB2_Utils.php 2 patches
Spacing   +20 added lines, -21 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 		$dir = wp_upload_dir();
31 31
 
32 32
 		// Is URL in uploads directory?
33
-		if ( false === strpos( $img_url, $dir['baseurl'] . '/' ) ) {
33
+		if ( false === strpos( $img_url, $dir[ 'baseurl' ] . '/' ) ) {
34 34
 			return false;
35 35
 		}
36 36
 
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
 
56 56
 			foreach ( $query->posts as $post_id ) {
57 57
 				$meta = wp_get_attachment_metadata( $post_id );
58
-				$original_file       = basename( $meta['file'] );
59
-				$cropped_image_files = isset( $meta['sizes'] ) ? wp_list_pluck( $meta['sizes'], 'file' ) : array();
58
+				$original_file       = basename( $meta[ 'file' ] );
59
+				$cropped_image_files = isset( $meta[ 'sizes' ] ) ? wp_list_pluck( $meta[ 'sizes' ], 'file' ) : array();
60 60
 				if ( $original_file === $file || in_array( $file, $cropped_image_files ) ) {
61 61
 					$attachment_id = $post_id;
62 62
 					break;
@@ -140,8 +140,7 @@  discard block
 block discarded – undo
140 140
 		}
141 141
 
142 142
 		return $this->is_valid_time_stamp( $string )
143
-			? (int) $string :
144
-			strtotime( (string) $string );
143
+			? (int) $string : strtotime( (string) $string );
145 144
 	}
146 145
 
147 146
 	/**
@@ -172,7 +171,7 @@  discard block
 block discarded – undo
172 171
 	 * @param  mixed $value Value to check
173 172
 	 * @return bool         True or false
174 173
 	 */
175
-	public function notempty( $value ){
174
+	public function notempty( $value ) {
176 175
 		return null !== $value && '' !== $value && false !== $value;
177 176
 	}
178 177
 
@@ -322,24 +321,24 @@  discard block
 block discarded – undo
322 321
 
323 322
 		// order is relevant here, since the replacement will be done sequentially.
324 323
 		$supported_options = array(
325
-			'd' => 'dd',  // Day, leading 0
326
-			'j' => 'd',   // Day, no 0
327
-			'z' => 'o',   // Day of the year, no leading zeroes,
324
+			'd' => 'dd', // Day, leading 0
325
+			'j' => 'd', // Day, no 0
326
+			'z' => 'o', // Day of the year, no leading zeroes,
328 327
 			// 'D' => 'D',   // Day name short, not sure how it'll work with translations
329 328
 			// 'l' => 'DD',  // Day name full, idem before
330
-			'm' => 'mm',  // Month of the year, leading 0
331
-			'n' => 'm',   // Month of the year, no leading 0
329
+			'm' => 'mm', // Month of the year, leading 0
330
+			'n' => 'm', // Month of the year, no leading 0
332 331
 			// 'M' => 'M',   // Month, Short name
333 332
 			// 'F' => 'MM',  // Month, full name,
334
-			'y' => 'y',   // Year, two digit
335
-			'Y' => 'yy',  // Year, full
336
-			'H' => 'HH',  // Hour with leading 0 (24 hour)
337
-			'G' => 'H',   // Hour with no leading 0 (24 hour)
338
-			'h' => 'hh',  // Hour with leading 0 (12 hour)
339
-			'g' => 'h',   // Hour with no leading 0 (12 hour),
340
-			'i' => 'mm',  // Minute with leading 0,
341
-			's' => 'ss',  // Second with leading 0,
342
-			'a' => 'tt',  // am/pm
333
+			'y' => 'y', // Year, two digit
334
+			'Y' => 'yy', // Year, full
335
+			'H' => 'HH', // Hour with leading 0 (24 hour)
336
+			'G' => 'H', // Hour with no leading 0 (24 hour)
337
+			'h' => 'hh', // Hour with leading 0 (12 hour)
338
+			'g' => 'h', // Hour with no leading 0 (12 hour),
339
+			'i' => 'mm', // Minute with leading 0,
340
+			's' => 'ss', // Second with leading 0,
341
+			'a' => 'tt', // am/pm
343 342
 			'A' => 'TT'   // AM/PM
344 343
 		);
345 344
 
@@ -360,7 +359,7 @@  discard block
 block discarded – undo
360 359
 	 * @return string Modified value
361 360
 	 */
362 361
 	public function wrap_escaped_chars( $value ) {
363
-		return "&#39;" . str_replace( '\\', '', $value[0] ) . "&#39;";
362
+		return "&#39;" . str_replace( '\\', '', $value[ 0 ] ) . "&#39;";
364 363
 	}
365 364
 
366 365
 	/**
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -115,7 +115,8 @@  discard block
 block discarded – undo
115 115
 			$tzstring = '';
116 116
 		}
117 117
 
118
-		if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists
118
+		if ( empty( $tzstring ) ) {
119
+// Create a UTC+- zone if no timezone string exists
119 120
 			if ( 0 == $current_offset ) {
120 121
 				$tzstring = 'UTC+0';
121 122
 			} elseif ( $current_offset < 0 ) {
@@ -172,7 +173,7 @@  discard block
 block discarded – undo
172 173
 	 * @param  mixed $value Value to check
173 174
 	 * @return bool         True or false
174 175
 	 */
175
-	public function notempty( $value ){
176
+	public function notempty( $value ) {
176 177
 		return null !== $value && '' !== $value && false !== $value;
177 178
 	}
178 179
 
Please login to merge, or discard this patch.
includes/types/CMB2_Type_Taxonomy_Select.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 	public function render() {
16 16
 		$names = $this->get_object_terms();
17 17
 
18
-		$saved_term  = is_wp_error( $names ) || empty( $names ) ? $this->field->get_default() : $names[key( $names )]->slug;
18
+		$saved_term  = is_wp_error( $names ) || empty( $names ) ? $this->field->get_default() : $names[ key( $names ) ]->slug;
19 19
 		$terms       = $this->get_terms();
20 20
 		$options     = '';
21 21
 		$option_none = $this->field->args( 'show_option_none' );
Please login to merge, or discard this patch.
includes/types/CMB2_Type_Title.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
 		), $this->args );
30 30
 
31 31
 		return $this->rendered(
32
-			sprintf( '<%1$s %2$s>%3$s</%1$s>%4$s', $a['tag'], $this->concat_attrs( $a, array( 'tag', 'name', 'desc' ) ), $a['name'], $a['desc'] )
32
+			sprintf( '<%1$s %2$s>%3$s</%1$s>%4$s', $a[ 'tag' ], $this->concat_attrs( $a, array( 'tag', 'name', 'desc' ) ), $a[ 'name' ], $a[ 'desc' ] )
33 33
 		);
34 34
 	}
35 35
 
Please login to merge, or discard this patch.
includes/CMB2_Field_Display.php 2 patches
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -113,8 +113,6 @@
 block discarded – undo
113 113
 	 * Catchall method if field's 'display_cb' is NOT defined, or field type does
114 114
 	 * not have a corresponding display method
115 115
 	 * @since 2.2.2
116
-	 * @param  string $method    Non-existent method name
117
-	 * @param  array  $arguments All arguments passed to the method
118 116
 	 */
119 117
 	public function display() {
120 118
 		// If repeatable
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 			if ( is_array( $this->field->value ) ) {
125 125
 
126 126
 				// Then loop and output.
127
-				echo '<ul class="cmb2-'. str_replace( '_', '-', $this->field->type() ) .'">';
127
+				echo '<ul class="cmb2-' . str_replace( '_', '-', $this->field->type() ) . '">';
128 128
 				foreach ( $this->field->value as $val ) {
129 129
 					$this->value = $val;
130 130
 					echo '<li>', $this->_display(), '</li>';
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
 		$options = $this->field->options();
198 198
 
199 199
 		$fallback = $this->field->args( 'show_option_none' );
200
-		if ( ! $fallback && isset( $options[''] ) ) {
201
-			$fallback = $options[''];
200
+		if ( ! $fallback && isset( $options[ '' ] ) ) {
201
+			$fallback = $options[ '' ];
202 202
 		}
203 203
 		if ( ! $this->value && $fallback ) {
204 204
 			echo $fallback;
@@ -225,9 +225,9 @@  discard block
 block discarded – undo
225 225
 		$output = array();
226 226
 		foreach ( $this->value as $val ) {
227 227
 			if ( isset( $options[ $val ] ) ) {
228
-				$output[] = $options[ $val ];
228
+				$output[ ] = $options[ $val ];
229 229
 			} else {
230
-				$output[] = esc_attr( $val );
230
+				$output[ ] = esc_attr( $val );
231 231
 			}
232 232
 		}
233 233
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	 * @since 2.2.2
252 252
 	 */
253 253
 	protected function _display() {
254
-		echo '<xmp class="cmb2-code">'. print_r( $this->value, true ) .'</xmp>';
254
+		echo '<xmp class="cmb2-code">' . print_r( $this->value, true ) . '</xmp>';
255 255
 	}
256 256
 }
257 257
 
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 		if ( $datetime && $datetime instanceof DateTime ) {
294 294
 			$tz       = $datetime->getTimezone();
295 295
 			$tzstring = $tz->getName();
296
-			$this->value    = $datetime->getTimestamp();
296
+			$this->value = $datetime->getTimestamp();
297 297
 		}
298 298
 
299 299
 		$date = $this->field->get_timestamp_format( 'date_format', $this->value );
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 		if ( is_wp_error( $terms ) || empty( $terms ) && ( $default = $this->field->get_default() ) ) {
318 318
 			$term = get_term_by( 'slug', $default, $taxonomy );
319 319
 		} elseif ( ! empty( $terms ) ) {
320
-			$term = $terms[key( $terms )];
320
+			$term = $terms[ key( $terms ) ];
321 321
 		}
322 322
 
323 323
 		if ( $term ) {
@@ -341,10 +341,10 @@  discard block
 block discarded – undo
341 341
 			$terms = array();
342 342
 			if ( is_array( $default ) ) {
343 343
 				foreach ( $default as $slug ) {
344
-					$terms[] = get_term_by( 'slug', $slug, $taxonomy );
344
+					$terms[ ] = get_term_by( 'slug', $slug, $taxonomy );
345 345
 				}
346 346
 			} else {
347
-				$terms[] = get_term_by( 'slug', $default, $taxonomy );
347
+				$terms[ ] = get_term_by( 'slug', $default, $taxonomy );
348 348
 			}
349 349
 		}
350 350
 
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 			$links = array();
354 354
 			foreach ( $terms as $term ) {
355 355
 				$link = get_edit_term_link( $term->term_id, $taxonomy );
356
-				$links[] = '<a href="'. esc_url( $link ) .'">'. esc_html( $term->name ) .'</a>';
356
+				$links[ ] = '<a href="' . esc_url( $link ) . '">' . esc_html( $term->name ) . '</a>';
357 357
 			}
358 358
 			// Then loop and output.
359 359
 			echo '<div class="cmb2-taxonomy-terms-', esc_attr( $taxonomy ), '">';
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 			if ( $id ) {
397 397
 				$image = wp_get_attachment_image( $id, $img_size, null, array( 'class' => 'cmb-image-display' ) );
398 398
 			} else {
399
-				$size = is_array( $img_size ) ? $img_size[0] : 200;
399
+				$size = is_array( $img_size ) ? $img_size[ 0 ] : 200;
400 400
 				$image = '<img class="cmb-image-display" style="max-width: ' . absint( $size ) . 'px; width: 100%; height: auto;" src="' . $url_value . '" alt="" />';
401 401
 			}
402 402
 
Please login to merge, or discard this patch.