Completed
Push — trunk ( 704260...4af108 )
by Justin
04:55
created
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/CMB2.php 1 patch
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -118,19 +118,19 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	public function __construct( $meta_box, $object_id = 0 ) {
120 120
 
121
-		if ( empty( $meta_box['id'] ) ) {
121
+		if ( empty( $meta_box[ 'id' ] ) ) {
122 122
 			wp_die( __( 'Metabox configuration is required to have an ID parameter', 'cmb2' ) );
123 123
 		}
124 124
 
125 125
 		$this->meta_box = wp_parse_args( $meta_box, $this->mb_defaults );
126
-		$this->meta_box['fields'] = array();
126
+		$this->meta_box[ 'fields' ] = array();
127 127
 
128 128
 		$this->object_id( $object_id );
129 129
 		$this->mb_object_type();
130
-		$this->cmb_id = $meta_box['id'];
130
+		$this->cmb_id = $meta_box[ 'id' ];
131 131
 
132
-		if ( ! empty( $meta_box['fields'] ) && is_array( $meta_box['fields'] ) ) {
133
-			$this->add_fields( $meta_box['fields'] );
132
+		if ( ! empty( $meta_box[ 'fields' ] ) && is_array( $meta_box[ 'fields' ] ) ) {
133
+			$this->add_fields( $meta_box[ 'fields' ] );
134 134
 		}
135 135
 
136 136
 		CMB2_Boxes::add( $this );
@@ -261,22 +261,22 @@  discard block
 block discarded – undo
261 261
 	 * @return mixed CMB2_Field object if successful.
262 262
 	 */
263 263
 	public function render_field( $field_args ) {
264
-		$field_args['context'] = $this->prop( 'context' );
264
+		$field_args[ 'context' ] = $this->prop( 'context' );
265 265
 
266
-		if ( 'group' == $field_args['type'] ) {
266
+		if ( 'group' == $field_args[ 'type' ] ) {
267 267
 
268
-			if ( ! isset( $field_args['show_names'] ) ) {
269
-				$field_args['show_names'] = $this->prop( 'show_names' );
268
+			if ( ! isset( $field_args[ 'show_names' ] ) ) {
269
+				$field_args[ 'show_names' ] = $this->prop( 'show_names' );
270 270
 			}
271 271
 			$field = $this->render_group( $field_args );
272 272
 
273
-		} elseif ( 'hidden' == $field_args['type'] && $this->get_field( $field_args )->should_show() ) {
273
+		} elseif ( 'hidden' == $field_args[ 'type' ] && $this->get_field( $field_args )->should_show() ) {
274 274
 			// Save rendering for after the metabox
275 275
 			$field = $this->add_hidden_field( $field_args );
276 276
 
277 277
 		} else {
278 278
 
279
-			$field_args['show_names'] = $this->prop( 'show_names' );
279
+			$field_args[ 'show_names' ] = $this->prop( 'show_names' );
280 280
 
281 281
 			// Render default fields
282 282
 			$field = $this->get_field( $field_args )->render_field();
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 	 */
293 293
 	public function render_group( $args ) {
294 294
 
295
-		if ( ! isset( $args['id'], $args['fields'] ) || ! is_array( $args['fields'] ) ) {
295
+		if ( ! isset( $args[ 'id' ], $args[ 'fields' ] ) || ! is_array( $args[ 'fields' ] ) ) {
296 296
 			return;
297 297
 		}
298 298
 
@@ -374,15 +374,15 @@  discard block
 block discarded – undo
374 374
 			<div class="inside cmb-td cmb-nested cmb-field-list">';
375 375
 				// Loop and render repeatable group fields
376 376
 				foreach ( array_values( $field_group->args( 'fields' ) ) as $field_args ) {
377
-					if ( 'hidden' == $field_args['type'] ) {
377
+					if ( 'hidden' == $field_args[ 'type' ] ) {
378 378
 
379 379
 						// Save rendering for after the metabox
380 380
 						$this->add_hidden_field( $field_args, $field_group );
381 381
 
382 382
 					} else {
383 383
 
384
-						$field_args['show_names'] = $field_group->args( 'show_names' );
385
-						$field_args['context']    = $field_group->args( 'context' );
384
+						$field_args[ 'show_names' ] = $field_group->args( 'show_names' );
385
+						$field_args[ 'context' ]    = $field_group->args( 'context' );
386 386
 
387 387
 						$field = $this->get_field( $field_args, $field_group )->render_field();
388 388
 					}
@@ -410,14 +410,14 @@  discard block
 block discarded – undo
410 410
 	 * @param array  $field_args Array of field arguments to be passed to CMB2_Field
411 411
 	 */
412 412
 	public function add_hidden_field( $field_args, $field_group = null ) {
413
-		if ( isset( $field_args['field_args'] ) ) {
413
+		if ( isset( $field_args[ 'field_args' ] ) ) {
414 414
 			// For back-compatibility.
415 415
 			$field = new CMB2_Field( $field_args );
416 416
 		} else {
417 417
 			$field = $this->get_new_field( $field_args, $field_group );
418 418
 		}
419 419
 
420
-		$this->hidden_fields[] = new CMB2_Types( $field );
420
+		$this->hidden_fields[ ] = new CMB2_Types( $field );
421 421
 
422 422
 		return $field;
423 423
 	}
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 	 */
557 557
 	public function process_field( $field_args ) {
558 558
 
559
-		switch ( $field_args['type'] ) {
559
+		switch ( $field_args[ 'type' ] ) {
560 560
 
561 561
 			case 'group':
562 562
 				$this->save_group( $field_args );
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 				$field = $this->get_new_field( $field_args );
572 572
 
573 573
 				if ( $field->save_field_from_data( $this->data_to_save ) ) {
574
-					$this->updated[] = $field->id();
574
+					$this->updated[ ] = $field->id();
575 575
 				}
576 576
 
577 577
 				break;
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
 	 */
585 585
 	public function save_group( $args ) {
586 586
 
587
-		if ( ! isset( $args['id'], $args['fields'], $this->data_to_save[ $args['id'] ] ) || ! is_array( $args['fields'] ) ) {
587
+		if ( ! isset( $args[ 'id' ], $args[ 'fields' ], $this->data_to_save[ $args[ 'id' ] ] ) || ! is_array( $args[ 'fields' ] ) ) {
588 588
 			return;
589 589
 		}
590 590
 
@@ -617,16 +617,16 @@  discard block
 block discarded – undo
617 617
 						$_new_val = array();
618 618
 						foreach ( $new_val as $group_index => $grouped_data ) {
619 619
 							// Add the supporting data to the $saved array stack
620
-							$saved[ $field_group->index ][ $grouped_data['supporting_field_id'] ][] = $grouped_data['supporting_field_value'];
620
+							$saved[ $field_group->index ][ $grouped_data[ 'supporting_field_id' ] ][ ] = $grouped_data[ 'supporting_field_value' ];
621 621
 							// Reset var to the actual value
622
-							$_new_val[ $group_index ] = $grouped_data['value'];
622
+							$_new_val[ $group_index ] = $grouped_data[ 'value' ];
623 623
 						}
624 624
 						$new_val = $_new_val;
625 625
 					} else {
626 626
 						// Add the supporting data to the $saved array stack
627
-						$saved[ $field_group->index ][ $new_val['supporting_field_id'] ] = $new_val['supporting_field_value'];
627
+						$saved[ $field_group->index ][ $new_val[ 'supporting_field_id' ] ] = $new_val[ 'supporting_field_value' ];
628 628
 						// Reset var to the actual value
629
-						$new_val = $new_val['value'];
629
+						$new_val = $new_val[ 'value' ];
630 630
 					}
631 631
 				}
632 632
 
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
 				$is_removed = ( empty( $new_val ) && ! empty( $old_val ) );
640 640
 				// Compare values and add to `$updated` array
641 641
 				if ( $is_updated || $is_removed ) {
642
-					$this->updated[] = $base_id . '::' . $field_group->index . '::' . $sub_id;
642
+					$this->updated[ ] = $base_id . '::' . $field_group->index . '::' . $sub_id;
643 643
 				}
644 644
 
645 645
 				// Add to `$saved` array
@@ -674,22 +674,22 @@  discard block
 block discarded – undo
674 674
 		// Try to get our object ID from the global space
675 675
 		switch ( $this->object_type() ) {
676 676
 			case 'user':
677
-				$object_id = isset( $_REQUEST['user_id'] ) ? $_REQUEST['user_id'] : $object_id;
678
-				$object_id = ! $object_id && 'user-new.php' != $pagenow && isset( $GLOBALS['user_ID'] ) ? $GLOBALS['user_ID'] : $object_id;
677
+				$object_id = isset( $_REQUEST[ 'user_id' ] ) ? $_REQUEST[ 'user_id' ] : $object_id;
678
+				$object_id = ! $object_id && 'user-new.php' != $pagenow && isset( $GLOBALS[ 'user_ID' ] ) ? $GLOBALS[ 'user_ID' ] : $object_id;
679 679
 				break;
680 680
 
681 681
 			case 'comment':
682
-				$object_id = isset( $_REQUEST['c'] ) ? $_REQUEST['c'] : $object_id;
683
-				$object_id = ! $object_id && isset( $GLOBALS['comments']->comment_ID ) ? $GLOBALS['comments']->comment_ID : $object_id;
682
+				$object_id = isset( $_REQUEST[ 'c' ] ) ? $_REQUEST[ 'c' ] : $object_id;
683
+				$object_id = ! $object_id && isset( $GLOBALS[ 'comments' ]->comment_ID ) ? $GLOBALS[ 'comments' ]->comment_ID : $object_id;
684 684
 				break;
685 685
 
686 686
 			case 'term':
687
-				$object_id = isset( $_REQUEST['tag_ID'] ) ? $_REQUEST['tag_ID'] : $object_id;
687
+				$object_id = isset( $_REQUEST[ 'tag_ID' ] ) ? $_REQUEST[ 'tag_ID' ] : $object_id;
688 688
 				break;
689 689
 
690 690
 			default:
691
-				$object_id = isset( $GLOBALS['post']->ID ) ? $GLOBALS['post']->ID : $object_id;
692
-				$object_id = isset( $_REQUEST['post'] ) ? $_REQUEST['post'] : $object_id;
691
+				$object_id = isset( $GLOBALS[ 'post' ]->ID ) ? $GLOBALS[ 'post' ]->ID : $object_id;
692
+				$object_id = isset( $_REQUEST[ 'post' ] ) ? $_REQUEST[ 'post' ] : $object_id;
693 693
 				break;
694 694
 		}
695 695
 
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 	 * @return boolean True/False
762 762
 	 */
763 763
 	public function is_options_page_mb() {
764
-		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'] ) );
764
+		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' ] ) );
765 765
 	}
766 766
 
767 767
 	/**
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
 			return $field;
825 825
 		}
826 826
 
827
-		$field_id = is_string( $field ) ? $field : $field['id'];
827
+		$field_id = is_string( $field ) ? $field : $field[ 'id' ];
828 828
 
829 829
 		$parent_field_id = ! empty( $field_group ) ? $field_group->id() : '';
830 830
 		$ids = $this->get_field_ids( $field_id, $parent_field_id, true );
@@ -860,16 +860,16 @@  discard block
 block discarded – undo
860 860
 		if ( $field_group && ( $sub_field_id || 0 === $sub_field_id ) ) {
861 861
 
862 862
 			// Update the fields array w/ any modified properties inherited from the group field
863
-			$this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] = $field_args;
863
+			$this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] = $field_args;
864 864
 
865 865
 			return $this->get_default_args( $field_args, $field_group );
866 866
 		}
867 867
 
868 868
 		if ( is_array( $field_args ) ) {
869
-			$this->meta_box['fields'][ $field_id ] = array_merge( $field_args, $this->meta_box['fields'][ $field_id ] );
869
+			$this->meta_box[ 'fields' ][ $field_id ] = array_merge( $field_args, $this->meta_box[ 'fields' ][ $field_id ] );
870 870
 		}
871 871
 
872
-		return $this->get_default_args( $this->meta_box['fields'][ $field_id ] );
872
+		return $this->get_default_args( $this->meta_box[ 'fields' ][ $field_id ] );
873 873
 	}
874 874
 
875 875
 	/**
@@ -919,8 +919,8 @@  discard block
 block discarded – undo
919 919
 
920 920
 			$sub_fields = false;
921 921
 			if ( array_key_exists( 'fields', $field ) ) {
922
-				$sub_fields = $field['fields'];
923
-				unset( $field['fields'] );
922
+				$sub_fields = $field[ 'fields' ];
923
+				unset( $field[ 'fields' ] );
924 924
 			}
925 925
 
926 926
 			$field_id = $parent_field_id
@@ -945,18 +945,18 @@  discard block
 block discarded – undo
945 945
 			return false;
946 946
 		}
947 947
 
948
-		if ( 'oembed' === $field['type'] ) {
948
+		if ( 'oembed' === $field[ 'type' ] ) {
949 949
 			// Initiate oembed Ajax hooks
950 950
 			cmb2_ajax();
951 951
 		}
952 952
 
953 953
 		$this->_add_field_to_array(
954 954
 			$field,
955
-			$this->meta_box['fields'],
955
+			$this->meta_box[ 'fields' ],
956 956
 			$position
957 957
 		);
958 958
 
959
-		return $field['id'];
959
+		return $field[ 'id' ];
960 960
 	}
961 961
 
962 962
 	/**
@@ -968,27 +968,27 @@  discard block
 block discarded – undo
968 968
 	 * @return mixed                   Array of parent/field ids or false
969 969
 	 */
970 970
 	public function add_group_field( $parent_field_id, array $field, $position = 0 ) {
971
-		if ( ! array_key_exists( $parent_field_id, $this->meta_box['fields'] ) ) {
971
+		if ( ! array_key_exists( $parent_field_id, $this->meta_box[ 'fields' ] ) ) {
972 972
 			return false;
973 973
 		}
974 974
 
975
-		$parent_field = $this->meta_box['fields'][ $parent_field_id ];
975
+		$parent_field = $this->meta_box[ 'fields' ][ $parent_field_id ];
976 976
 
977
-		if ( 'group' !== $parent_field['type'] ) {
977
+		if ( 'group' !== $parent_field[ 'type' ] ) {
978 978
 			return false;
979 979
 		}
980 980
 
981
-		if ( ! isset( $parent_field['fields'] ) ) {
982
-			$this->meta_box['fields'][ $parent_field_id ]['fields'] = array();
981
+		if ( ! isset( $parent_field[ 'fields' ] ) ) {
982
+			$this->meta_box[ 'fields' ][ $parent_field_id ][ 'fields' ] = array();
983 983
 		}
984 984
 
985 985
 		$this->_add_field_to_array(
986 986
 			$field,
987
-			$this->meta_box['fields'][ $parent_field_id ]['fields'],
987
+			$this->meta_box[ 'fields' ][ $parent_field_id ][ 'fields' ],
988 988
 			$position
989 989
 		);
990 990
 
991
-		return array( $parent_field_id, $field['id'] );
991
+		return array( $parent_field_id, $field[ 'id' ] );
992 992
 	}
993 993
 
994 994
 	/**
@@ -1000,9 +1000,9 @@  discard block
 block discarded – undo
1000 1000
 	 */
1001 1001
 	protected function _add_field_to_array( $field, &$fields, $position = 0 ) {
1002 1002
 		if ( $position ) {
1003
-			cmb2_utils()->array_insert( $fields, array( $field['id'] => $field ), $position );
1003
+			cmb2_utils()->array_insert( $fields, array( $field[ 'id' ] => $field ), $position );
1004 1004
 		} else {
1005
-			$fields[ $field['id'] ] = $field;
1005
+			$fields[ $field[ 'id' ] ] = $field;
1006 1006
 		}
1007 1007
 	}
1008 1008
 
@@ -1025,15 +1025,15 @@  discard block
 block discarded – undo
1025 1025
 		unset( $this->fields[ implode( '', $ids ) ] );
1026 1026
 
1027 1027
 		if ( ! $sub_field_id ) {
1028
-			unset( $this->meta_box['fields'][ $field_id ] );
1028
+			unset( $this->meta_box[ 'fields' ][ $field_id ] );
1029 1029
 			return true;
1030 1030
 		}
1031 1031
 
1032
-		if ( isset( $this->fields[ $field_id ]->args['fields'][ $sub_field_id ] ) ) {
1033
-			unset( $this->fields[ $field_id ]->args['fields'][ $sub_field_id ] );
1032
+		if ( isset( $this->fields[ $field_id ]->args[ 'fields' ][ $sub_field_id ] ) ) {
1033
+			unset( $this->fields[ $field_id ]->args[ 'fields' ][ $sub_field_id ] );
1034 1034
 		}
1035
-		if ( isset( $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] ) ) {
1036
-			unset( $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] );
1035
+		if ( isset( $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] ) ) {
1036
+			unset( $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] );
1037 1037
 		}
1038 1038
 		return true;
1039 1039
 	}
@@ -1057,11 +1057,11 @@  discard block
 block discarded – undo
1057 1057
 		list( $field_id, $sub_field_id ) = $ids;
1058 1058
 
1059 1059
 		if ( ! $sub_field_id ) {
1060
-			$this->meta_box['fields'][ $field_id ][ $property ] = $value;
1060
+			$this->meta_box[ 'fields' ][ $field_id ][ $property ] = $value;
1061 1061
 			return $field_id;
1062 1062
 		}
1063 1063
 
1064
-		$this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ][ $property ] = $value;
1064
+		$this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ][ $property ] = $value;
1065 1065
 		return $field_id;
1066 1066
 	}
1067 1067
 
@@ -1075,7 +1075,7 @@  discard block
 block discarded – undo
1075 1075
 	public function get_field_ids( $field_id, $parent_field_id = '' ) {
1076 1076
 		$sub_field_id = $parent_field_id ? $field_id : '';
1077 1077
 		$field_id     = $parent_field_id ? $parent_field_id : $field_id;
1078
-		$fields       =& $this->meta_box['fields'];
1078
+		$fields       = & $this->meta_box[ 'fields' ];
1079 1079
 
1080 1080
 		if ( ! array_key_exists( $field_id, $fields ) ) {
1081 1081
 			$field_id = $this->search_old_school_array( $field_id, $fields );
@@ -1089,12 +1089,12 @@  discard block
 block discarded – undo
1089 1089
 			return array( $field_id, $sub_field_id );
1090 1090
 		}
1091 1091
 
1092
-		if ( 'group' !== $fields[ $field_id ]['type'] ) {
1092
+		if ( 'group' !== $fields[ $field_id ][ 'type' ] ) {
1093 1093
 			return false;
1094 1094
 		}
1095 1095
 
1096
-		if ( ! array_key_exists( $sub_field_id, $fields[ $field_id ]['fields'] ) ) {
1097
-			$sub_field_id = $this->search_old_school_array( $sub_field_id, $fields[ $field_id ]['fields'] );
1096
+		if ( ! array_key_exists( $sub_field_id, $fields[ $field_id ][ 'fields' ] ) ) {
1097
+			$sub_field_id = $this->search_old_school_array( $sub_field_id, $fields[ $field_id ][ 'fields' ] );
1098 1098
 		}
1099 1099
 
1100 1100
 		return false === $sub_field_id ? false : array( $field_id, $sub_field_id );
Please login to merge, or discard this patch.