Completed
Pull Request — trunk (#848)
by
unknown
06:06
created
includes/CMB2_Utils.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -547,7 +547,7 @@
 block discarded – undo
547 547
 	 * @since  2.2.3
548 548
 	 *
549 549
 	 * @param  mixed $value   Value to ensure is array.
550
-	 * @param  array $default Default array. Defaults to empty array.
550
+	 * @param  string[] $default Default array. Defaults to empty array.
551 551
 	 *
552 552
 	 * @return array          The array.
553 553
 	 */
Please login to merge, or discard this patch.
Spacing   +33 added lines, -34 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 		$dir = wp_upload_dir();
38 38
 
39 39
 		// Is URL in uploads directory?
40
-		if ( false === strpos( $img_url, $dir['baseurl'] . '/' ) ) {
40
+		if ( false === strpos( $img_url, $dir[ 'baseurl' ] . '/' ) ) {
41 41
 			return false;
42 42
 		}
43 43
 
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
 
63 63
 			foreach ( $query->posts as $post_id ) {
64 64
 				$meta = wp_get_attachment_metadata( $post_id );
65
-				$original_file       = basename( $meta['file'] );
66
-				$cropped_image_files = isset( $meta['sizes'] ) ? wp_list_pluck( $meta['sizes'], 'file' ) : array();
65
+				$original_file       = basename( $meta[ 'file' ] );
66
+				$cropped_image_files = isset( $meta[ 'sizes' ] ) ? wp_list_pluck( $meta[ 'sizes' ], 'file' ) : array();
67 67
 				if ( $original_file === $file || in_array( $file, $cropped_image_files ) ) {
68 68
 					$attachment_id = $post_id;
69 69
 					break;
@@ -125,31 +125,31 @@  discard block
 block discarded – undo
125 125
 			foreach ( $image_sizes as $_size => $data ) {
126 126
 
127 127
 				// If there's an exact match to an existing image size, short circuit.
128
-				if ( $data['width'] == $size[0] && $data['height'] == $size[1] ) {
129
-					$candidates[ $data['width'] * $data['height'] ] = array( $_size, $data );
128
+				if ( $data[ 'width' ] == $size[ 0 ] && $data[ 'height' ] == $size[ 1 ] ) {
129
+					$candidates[ $data[ 'width' ] * $data[ 'height' ] ] = array( $_size, $data );
130 130
 					break;
131 131
 				}
132 132
 
133 133
 				// If it's not an exact match, consider larger sizes with the same aspect ratio.
134
-				if ( $data['width'] >= $size[0] && $data['height'] >= $size[1] ) {
134
+				if ( $data[ 'width' ] >= $size[ 0 ] && $data[ 'height' ] >= $size[ 1 ] ) {
135 135
 					
136 136
 					/*
137 137
 					 * To test for varying crops, we constrain the dimensions of the larger image
138 138
 					 * to the dimensions of the smaller image and see if they match.
139 139
 					 */
140
-					if ( $data['width'] > $size[0] ) {
141
-						$constrained_size = wp_constrain_dimensions( $data['width'], $data['height'], $size[0] );
142
-						$expected_size = array( $size[0], $size[1] );
140
+					if ( $data[ 'width' ] > $size[ 0 ] ) {
141
+						$constrained_size = wp_constrain_dimensions( $data[ 'width' ], $data[ 'height' ], $size[ 0 ] );
142
+						$expected_size = array( $size[ 0 ], $size[ 1 ] );
143 143
 					} else {
144
-						$constrained_size = wp_constrain_dimensions( $size[0], $size[1], $data['width'] );
145
-						$expected_size = array( $data['width'], $data['height'] );
144
+						$constrained_size = wp_constrain_dimensions( $size[ 0 ], $size[ 1 ], $data[ 'width' ] );
145
+						$expected_size = array( $data[ 'width' ], $data[ 'height' ] );
146 146
 					}
147 147
 
148 148
 					// If the image dimensions are within 1px of the expected size, we consider it a match.
149
-					$matched = ( abs( $constrained_size[0] - $expected_size[0] ) <= 1 && abs( $constrained_size[1] - $expected_size[1] ) <= 1 );
149
+					$matched = ( abs( $constrained_size[ 0 ] - $expected_size[ 0 ] ) <= 1 && abs( $constrained_size[ 1 ] - $expected_size[ 1 ] ) <= 1 );
150 150
 
151 151
 					if ( $matched ) {
152
-						$candidates[ $data['width'] * $data['height'] ] = array( $_size, $data );
152
+						$candidates[ $data[ 'width' ] * $data[ 'height' ] ] = array( $_size, $data );
153 153
 					}
154 154
 				}
155 155
 			}
@@ -161,12 +161,12 @@  discard block
 block discarded – undo
161 161
 				}
162 162
 
163 163
 				$data = array_shift( $candidates );
164
-				$data = $data[0];
164
+				$data = $data[ 0 ];
165 165
 			/*
166 166
 			 * When the size requested is smaller than the thumbnail dimensions, we
167 167
 			 * fall back to the thumbnail size.
168 168
 			 */
169
-			} elseif ( ! empty( $image_sizes['thumbnail'] ) && $image_sizes['thumbnail']['width'] >= $size[0] && $image_sizes['thumbnail']['width'] >= $size[1] ) {
169
+			} elseif ( ! empty( $image_sizes[ 'thumbnail' ] ) && $image_sizes[ 'thumbnail' ][ 'width' ] >= $size[ 0 ] && $image_sizes[ 'thumbnail' ][ 'width' ] >= $size[ 1 ] ) {
170 170
 				$data = 'thumbnail';
171 171
 			} else {
172 172
 				return false;
@@ -256,8 +256,7 @@  discard block
 block discarded – undo
256 256
 		}
257 257
 
258 258
 		return self::is_valid_time_stamp( $string )
259
-			? (int) $string :
260
-			strtotime( (string) $string );
259
+			? (int) $string : strtotime( (string) $string );
261 260
 	}
262 261
 
263 262
 	/**
@@ -288,7 +287,7 @@  discard block
 block discarded – undo
288 287
 	 * @param  mixed $value Value to check
289 288
 	 * @return bool         True or false
290 289
 	 */
291
-	public static function notempty( $value ){
290
+	public static function notempty( $value ) {
292 291
 		return null !== $value && '' !== $value && false !== $value && array() !== $value;
293 292
 	}
294 293
 
@@ -446,24 +445,24 @@  discard block
 block discarded – undo
446 445
 
447 446
 		// order is relevant here, since the replacement will be done sequentially.
448 447
 		$supported_options = array(
449
-			'd' => 'dd',  // Day, leading 0
450
-			'j' => 'd',   // Day, no 0
451
-			'z' => 'o',   // Day of the year, no leading zeroes,
448
+			'd' => 'dd', // Day, leading 0
449
+			'j' => 'd', // Day, no 0
450
+			'z' => 'o', // Day of the year, no leading zeroes,
452 451
 			// 'D' => 'D',   // Day name short, not sure how it'll work with translations
453 452
 			// 'l' => 'DD',  // Day name full, idem before
454
-			'm' => 'mm',  // Month of the year, leading 0
455
-			'n' => 'm',   // Month of the year, no leading 0
453
+			'm' => 'mm', // Month of the year, leading 0
454
+			'n' => 'm', // Month of the year, no leading 0
456 455
 			// 'M' => 'M',   // Month, Short name
457 456
 			// 'F' => 'MM',  // Month, full name,
458
-			'y' => 'y',   // Year, two digit
459
-			'Y' => 'yy',  // Year, full
460
-			'H' => 'HH',  // Hour with leading 0 (24 hour)
461
-			'G' => 'H',   // Hour with no leading 0 (24 hour)
462
-			'h' => 'hh',  // Hour with leading 0 (12 hour)
463
-			'g' => 'h',   // Hour with no leading 0 (12 hour),
464
-			'i' => 'mm',  // Minute with leading 0,
465
-			's' => 'ss',  // Second with leading 0,
466
-			'a' => 'tt',  // am/pm
457
+			'y' => 'y', // Year, two digit
458
+			'Y' => 'yy', // Year, full
459
+			'H' => 'HH', // Hour with leading 0 (24 hour)
460
+			'G' => 'H', // Hour with no leading 0 (24 hour)
461
+			'h' => 'hh', // Hour with leading 0 (12 hour)
462
+			'g' => 'h', // Hour with no leading 0 (12 hour),
463
+			'i' => 'mm', // Minute with leading 0,
464
+			's' => 'ss', // Second with leading 0,
465
+			'a' => 'tt', // am/pm
467 466
 			'A' => 'TT'   // AM/PM
468 467
 		);
469 468
 
@@ -484,7 +483,7 @@  discard block
 block discarded – undo
484 483
 	 * @return string Modified value
485 484
 	 */
486 485
 	public static function wrap_escaped_chars( $value ) {
487
-		return "&#39;" . str_replace( '\\', '', $value[0] ) . "&#39;";
486
+		return "&#39;" . str_replace( '\\', '', $value[ 0 ] ) . "&#39;";
488 487
 	}
489 488
 
490 489
 	/**
@@ -543,7 +542,7 @@  discard block
 block discarded – undo
543 542
 	 * @return string               String of attributes for form element.
544 543
 	 */
545 544
 	public static function concat_attrs( $attrs, $attr_exclude = array() ) {
546
-		$attr_exclude[] = 'rendered';
545
+		$attr_exclude[ ] = 'rendered';
547 546
 		$attributes = '';
548 547
 		foreach ( $attrs as $attr => $val ) {
549 548
 			$excluded = in_array( $attr, (array) $attr_exclude, true );
Please login to merge, or discard this patch.
includes/types/CMB2_Type_File.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,15 +26,15 @@
 block discarded – undo
26 26
 		$img_size_data = $this->get_image_size_data( $img_size, 'large' );
27 27
 
28 28
 		// if options array and 'url' => false, then hide the url field
29
-		$input_type = array_key_exists( 'url', $options ) && false === $options['url'] ? 'hidden' : 'text';
29
+		$input_type = array_key_exists( 'url', $options ) && false === $options[ 'url' ] ? 'hidden' : 'text';
30 30
 
31 31
 		$output .= parent::render( array(
32 32
 			'type'  => $input_type,
33 33
 			'class' => 'cmb2-upload-file regular-text',
34 34
 			'size'  => 45,
35 35
 			'desc'  => '',
36
-			'data-previewsize' => sprintf( '[%d,%d]', $img_size_data['width'], $img_size_data['height'] ),
37
-			'data-sizename'    => $img_size_data['name'],
36
+			'data-previewsize' => sprintf( '[%d,%d]', $img_size_data[ 'width' ], $img_size_data[ 'height' ] ),
37
+			'data-sizename'    => $img_size_data[ 'name' ],
38 38
 			'data-queryargs'   => ! empty( $query_args ) ? json_encode( $query_args ) : '',
39 39
 			'js_dependencies'  => 'media-editor',
40 40
 		) );
Please login to merge, or discard this patch.
includes/types/CMB2_Type_File_List.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@
 block discarded – undo
29 29
 			'type'  => 'hidden',
30 30
 			'class' => 'cmb2-upload-file cmb2-upload-list',
31 31
 			'size'  => 45, 'desc'  => '', 'value'  => '',
32
-			'data-previewsize' => sprintf( '[%d,%d]', $img_size_data['width'], $img_size_data['height'] ),
33
-			'data-sizename'    => $img_size_data['name'],
32
+			'data-previewsize' => sprintf( '[%d,%d]', $img_size_data[ 'width' ], $img_size_data[ 'height' ] ),
33
+			'data-sizename'    => $img_size_data[ 'name' ],
34 34
 			'data-queryargs'   => ! empty( $query_args ) ? json_encode( $query_args ) : '',
35 35
 			'js_dependencies'  => 'media-editor',
36 36
 		) );
Please login to merge, or discard this patch.
includes/types/CMB2_Type_File_Base.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -68,13 +68,13 @@  discard block
 block discarded – undo
68 68
 		$data = array();
69 69
 
70 70
 		if ( is_array( $img_size ) ) {
71
-			$data['width']  = intval( $img_size[0] );
72
-			$data['height'] = intval( $img_size[1] );
73
-			$data['name']   = '';
71
+			$data[ 'width' ]  = intval( $img_size[ 0 ] );
72
+			$data[ 'height' ] = intval( $img_size[ 1 ] );
73
+			$data[ 'name' ]   = '';
74 74
 
75 75
 			// Try and get the closest named size from our array of dimensions
76 76
 			if ( $named_size = CMB2_Utils::get_named_size( $img_size ) ) {
77
-				$data['name'] = $named_size;
77
+				$data[ 'name' ] = $named_size;
78 78
 			}
79 79
 		} else {
80 80
 
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
 			}
92 92
 
93 93
 			// Get image dimensions from named sizes
94
-			$data['width']  = intval( $image_sizes[ $img_size ]['width'] );
95
-			$data['height'] = intval( $image_sizes[ $img_size ]['height'] );
96
-			$data['name']   = $img_size;
94
+			$data[ 'width' ]  = intval( $image_sizes[ $img_size ][ 'width' ] );
95
+			$data[ 'height' ] = intval( $image_sizes[ $img_size ][ 'height' ] );
96
+			$data[ 'name' ]   = $img_size;
97 97
 		}
98 98
 		
99 99
 		return $data;
@@ -117,17 +117,17 @@  discard block
 block discarded – undo
117 117
 		
118 118
 		foreach ( $image_sizes as $size ) {
119 119
 			// registered image size exists for this attachment
120
-			if ( isset( $meta['sizes'][ $size ] ) ) {
120
+			if ( isset( $meta[ 'sizes' ][ $size ] ) ) {
121 121
 
122 122
 				$attachment_url = wp_get_attachment_url( $attachment->ID );
123 123
 				$base_url = str_replace( wp_basename( $attachment_url ), '', $attachment_url );
124
-				$size_meta = $meta['sizes'][ $size ];
124
+				$size_meta = $meta[ 'sizes' ][ $size ];
125 125
 
126
-				$response['sizes'][ $size ] = array(
127
-					'url'         => $base_url . $size_meta['file'],
128
-					'height'      => $size_meta['height'],
129
-					'width'       => $size_meta['width'],
130
-					'orientation' => $size_meta['height'] > $size_meta['width'] ? 'portrait' : 'landscape',
126
+				$response[ 'sizes' ][ $size ] = array(
127
+					'url'         => $base_url . $size_meta[ 'file' ],
128
+					'height'      => $size_meta[ 'height' ],
129
+					'width'       => $size_meta[ 'width' ],
130
+					'orientation' => $size_meta[ 'height' ] > $size_meta[ 'width' ] ? 'portrait' : 'landscape',
131 131
 				);
132 132
 			}
133 133
 		}
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
 	 */
144 144
 	public function img_status_output( $args ) {
145 145
 		return sprintf( '<%1$s class="img-status cmb2-media-item">%2$s<p class="cmb2-remove-wrapper"><a href="#" class="cmb2-remove-file-button"%3$s>%4$s</a></p>%5$s</%1$s>',
146
-			$args['tag'],
147
-			$args['image'],
148
-			isset( $args['cached_id'] ) ? ' rel="' . $args['cached_id'] . '"' : '',
146
+			$args[ 'tag' ],
147
+			$args[ 'image' ],
148
+			isset( $args[ 'cached_id' ] ) ? ' rel="' . $args[ 'cached_id' ] . '"' : '',
149 149
 			esc_html( $this->_text( 'remove_image_text', esc_html__( 'Remove Image', 'cmb2' ) ) ),
150
-			isset( $args['id_input'] ) ? $args['id_input'] : ''
150
+			isset( $args[ 'id_input' ] ) ? $args[ 'id_input' ] : ''
151 151
 		);
152 152
 	}
153 153
 
@@ -159,14 +159,14 @@  discard block
 block discarded – undo
159 159
 	 */
160 160
 	public function file_status_output( $args ) {
161 161
 		return sprintf( '<%1$s class="file-status cmb2-media-item"><span>%2$s <strong>%3$s</strong></span>&nbsp;&nbsp; (<a href="%4$s" target="_blank" rel="external">%5$s</a> / <a href="#" class="cmb2-remove-file-button"%6$s>%7$s</a>)%8$s</%1$s>',
162
-			$args['tag'],
162
+			$args[ 'tag' ],
163 163
 			esc_html( $this->_text( 'file_text', esc_html__( 'File:', 'cmb2' ) ) ),
164
-			CMB2_Utils::get_file_name_from_path( $args['value'] ),
165
-			$args['value'],
164
+			CMB2_Utils::get_file_name_from_path( $args[ 'value' ] ),
165
+			$args[ 'value' ],
166 166
 			esc_html( $this->_text( 'file_download_text', esc_html__( 'Download', 'cmb2' ) ) ),
167
-			isset( $args['cached_id'] ) ? ' rel="' . $args['cached_id'] . '"' : '',
167
+			isset( $args[ 'cached_id' ] ) ? ' rel="' . $args[ 'cached_id' ] . '"' : '',
168 168
 			esc_html( $this->_text( 'remove_text', esc_html__( 'Remove', 'cmb2' ) ) ),
169
-			isset( $args['id_input'] ) ? $args['id_input'] : ''
169
+			isset( $args[ 'id_input' ] ) ? $args[ 'id_input' ] : ''
170 170
 		);
171 171
 	}
172 172
 
Please login to merge, or discard this patch.
includes/CMB2.php 1 patch
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -123,19 +123,19 @@  discard block
 block discarded – undo
123 123
 	 */
124 124
 	public function __construct( $config, $object_id = 0 ) {
125 125
 
126
-		if ( empty( $config['id'] ) ) {
126
+		if ( empty( $config[ 'id' ] ) ) {
127 127
 			wp_die( esc_html__( 'Metabox configuration is required to have an ID parameter.', 'cmb2' ) );
128 128
 		}
129 129
 
130 130
 		$this->meta_box = wp_parse_args( $config, $this->mb_defaults );
131
-		$this->meta_box['fields'] = array();
131
+		$this->meta_box[ 'fields' ] = array();
132 132
 
133 133
 		$this->object_id( $object_id );
134 134
 		$this->mb_object_type();
135
-		$this->cmb_id = $config['id'];
135
+		$this->cmb_id = $config[ 'id' ];
136 136
 
137
-		if ( ! empty( $config['fields'] ) && is_array( $config['fields'] ) ) {
138
-			$this->add_fields( $config['fields'] );
137
+		if ( ! empty( $config[ 'fields' ] ) && is_array( $config[ 'fields' ] ) ) {
138
+			$this->add_fields( $config[ 'fields' ] );
139 139
 		}
140 140
 
141 141
 		CMB2_Boxes::add( $this );
@@ -243,17 +243,17 @@  discard block
 block discarded – undo
243 243
 
244 244
 			// Include custom class if requesting no title.
245 245
 			if ( ! $this->prop( 'title' ) && ! $this->prop( 'remove_box_wrap' ) ) {
246
-				$context[] = 'cmb2-context-wrap-no-title';
246
+				$context[ ] = 'cmb2-context-wrap-no-title';
247 247
 			}
248 248
 
249 249
 			// Include a generic context wrapper.
250
-			$context[] = 'cmb2-context-wrap';
250
+			$context[ ] = 'cmb2-context-wrap';
251 251
 
252 252
 			// Include a context-type based context wrapper.
253
-			$context[] = 'cmb2-context-wrap-' . $this->prop( 'context' );
253
+			$context[ ] = 'cmb2-context-wrap-' . $this->prop( 'context' );
254 254
 
255 255
 			// Include an ID based context wrapper as well.
256
-			$context[] = 'cmb2-context-wrap-' . $this->prop( 'id' );
256
+			$context[ ] = 'cmb2-context-wrap-' . $this->prop( 'id' );
257 257
 
258 258
 			// And merge all the classes back into the array.
259 259
 			$classes = array_merge( $classes, $context );
@@ -332,22 +332,22 @@  discard block
 block discarded – undo
332 332
 	 * @return mixed CMB2_Field object if successful.
333 333
 	 */
334 334
 	public function render_field( $field_args ) {
335
-		$field_args['context'] = $this->prop( 'context' );
335
+		$field_args[ 'context' ] = $this->prop( 'context' );
336 336
 
337
-		if ( 'group' == $field_args['type'] ) {
337
+		if ( 'group' == $field_args[ 'type' ] ) {
338 338
 
339
-			if ( ! isset( $field_args['show_names'] ) ) {
340
-				$field_args['show_names'] = $this->prop( 'show_names' );
339
+			if ( ! isset( $field_args[ 'show_names' ] ) ) {
340
+				$field_args[ 'show_names' ] = $this->prop( 'show_names' );
341 341
 			}
342 342
 			$field = $this->render_group( $field_args );
343 343
 
344
-		} elseif ( 'hidden' == $field_args['type'] && $this->get_field( $field_args )->should_show() ) {
344
+		} elseif ( 'hidden' == $field_args[ 'type' ] && $this->get_field( $field_args )->should_show() ) {
345 345
 			// Save rendering for after the metabox
346 346
 			$field = $this->add_hidden_field( $field_args );
347 347
 
348 348
 		} else {
349 349
 
350
-			$field_args['show_names'] = $this->prop( 'show_names' );
350
+			$field_args[ 'show_names' ] = $this->prop( 'show_names' );
351 351
 
352 352
 			// Render default fields
353 353
 			$field = $this->get_field( $field_args )->render_field();
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 	 */
364 364
 	public function render_group( $args ) {
365 365
 
366
-		if ( ! isset( $args['id'], $args['fields'] ) || ! is_array( $args['fields'] ) ) {
366
+		if ( ! isset( $args[ 'id' ], $args[ 'fields' ] ) || ! is_array( $args[ 'fields' ] ) ) {
367 367
 			return;
368 368
 		}
369 369
 
@@ -473,15 +473,15 @@  discard block
 block discarded – undo
473 473
 			<div class="inside cmb-td cmb-nested cmb-field-list">';
474 474
 				// Loop and render repeatable group fields
475 475
 				foreach ( array_values( $field_group->args( 'fields' ) ) as $field_args ) {
476
-					if ( 'hidden' == $field_args['type'] ) {
476
+					if ( 'hidden' == $field_args[ 'type' ] ) {
477 477
 
478 478
 						// Save rendering for after the metabox
479 479
 						$this->add_hidden_field( $field_args, $field_group );
480 480
 
481 481
 					} else {
482 482
 
483
-						$field_args['show_names'] = $field_group->args( 'show_names' );
484
-						$field_args['context']    = $field_group->args( 'context' );
483
+						$field_args[ 'show_names' ] = $field_group->args( 'show_names' );
484
+						$field_args[ 'context' ]    = $field_group->args( 'context' );
485 485
 
486 486
 						$field = $this->get_field( $field_args, $field_group )->render_field();
487 487
 					}
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 	 * @param CMB2_Field|null $field_group CMB2_Field group field object
511 511
 	 */
512 512
 	public function add_hidden_field( $field_args, $field_group = null ) {
513
-		if ( isset( $field_args['field_args'] ) ) {
513
+		if ( isset( $field_args[ 'field_args' ] ) ) {
514 514
 			// For back-compatibility.
515 515
 			$field = new CMB2_Field( $field_args );
516 516
 		} else {
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 			$types->iterator = $field_group->index;
524 524
 		}
525 525
 
526
-		$this->hidden_fields[] = $types;
526
+		$this->hidden_fields[ ] = $types;
527 527
 
528 528
 		return $field;
529 529
 	}
@@ -626,11 +626,11 @@  discard block
 block discarded – undo
626 626
 	 */
627 627
 	public function process_field( $field_args ) {
628 628
 
629
-		switch ( $field_args['type'] ) {
629
+		switch ( $field_args[ 'type' ] ) {
630 630
 
631 631
 			case 'group':
632 632
 				if ( $this->save_group( $field_args ) ) {
633
-					$this->updated[] = $field_args['id'];
633
+					$this->updated[ ] = $field_args[ 'id' ];
634 634
 				}
635 635
 
636 636
 				break;
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
 				$field = $this->get_new_field( $field_args );
645 645
 
646 646
 				if ( $field->save_field_from_data( $this->data_to_save ) ) {
647
-					$this->updated[] = $field->id();
647
+					$this->updated[ ] = $field->id();
648 648
 				}
649 649
 
650 650
 				break;
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
 	 * @return mixed        Return of CMB2_Field::update_data()
712 712
 	 */
713 713
 	public function save_group( $args ) {
714
-		if ( ! isset( $args['id'], $args['fields'] ) || ! is_array( $args['fields'] ) ) {
714
+		if ( ! isset( $args[ 'id' ], $args[ 'fields' ] ) || ! is_array( $args[ 'fields' ] ) ) {
715 715
 			return;
716 716
 		}
717 717
 
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
 		$field_group->data_to_save = $this->data_to_save;
741 741
 
742 742
 		foreach ( array_values( $field_group->fields() ) as $field_args ) {
743
-			if ( 'title' === $field_args['type'] ) {
743
+			if ( 'title' === $field_args[ 'type' ] ) {
744 744
 				// Don't process title fields
745 745
 				continue;
746 746
 			}
@@ -763,16 +763,16 @@  discard block
 block discarded – undo
763 763
 						$_new_val = array();
764 764
 						foreach ( $new_val as $group_index => $grouped_data ) {
765 765
 							// Add the supporting data to the $saved array stack
766
-							$saved[ $field_group->index ][ $grouped_data['supporting_field_id'] ][] = $grouped_data['supporting_field_value'];
766
+							$saved[ $field_group->index ][ $grouped_data[ 'supporting_field_id' ] ][ ] = $grouped_data[ 'supporting_field_value' ];
767 767
 							// Reset var to the actual value
768
-							$_new_val[ $group_index ] = $grouped_data['value'];
768
+							$_new_val[ $group_index ] = $grouped_data[ 'value' ];
769 769
 						}
770 770
 						$new_val = $_new_val;
771 771
 					} else {
772 772
 						// Add the supporting data to the $saved array stack
773
-						$saved[ $field_group->index ][ $new_val['supporting_field_id'] ] = $new_val['supporting_field_value'];
773
+						$saved[ $field_group->index ][ $new_val[ 'supporting_field_id' ] ] = $new_val[ 'supporting_field_value' ];
774 774
 						// Reset var to the actual value
775
-						$new_val = $new_val['value'];
775
+						$new_val = $new_val[ 'value' ];
776 776
 					}
777 777
 				}
778 778
 
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
 
787 787
 				// Compare values and add to `$updated` array
788 788
 				if ( $is_updated || $is_removed ) {
789
-					$this->updated[] = $base_id . '::' . $field_group->index . '::' . $sub_id;
789
+					$this->updated[ ] = $base_id . '::' . $field_group->index . '::' . $sub_id;
790 790
 				}
791 791
 
792 792
 				// Add to `$saved` array
@@ -823,22 +823,22 @@  discard block
 block discarded – undo
823 823
 		// Try to get our object ID from the global space
824 824
 		switch ( $this->object_type() ) {
825 825
 			case 'user':
826
-				$object_id = isset( $_REQUEST['user_id'] ) ? $_REQUEST['user_id'] : $object_id;
827
-				$object_id = ! $object_id && 'user-new.php' != $pagenow && isset( $GLOBALS['user_ID'] ) ? $GLOBALS['user_ID'] : $object_id;
826
+				$object_id = isset( $_REQUEST[ 'user_id' ] ) ? $_REQUEST[ 'user_id' ] : $object_id;
827
+				$object_id = ! $object_id && 'user-new.php' != $pagenow && isset( $GLOBALS[ 'user_ID' ] ) ? $GLOBALS[ 'user_ID' ] : $object_id;
828 828
 				break;
829 829
 
830 830
 			case 'comment':
831
-				$object_id = isset( $_REQUEST['c'] ) ? $_REQUEST['c'] : $object_id;
832
-				$object_id = ! $object_id && isset( $GLOBALS['comments']->comment_ID ) ? $GLOBALS['comments']->comment_ID : $object_id;
831
+				$object_id = isset( $_REQUEST[ 'c' ] ) ? $_REQUEST[ 'c' ] : $object_id;
832
+				$object_id = ! $object_id && isset( $GLOBALS[ 'comments' ]->comment_ID ) ? $GLOBALS[ 'comments' ]->comment_ID : $object_id;
833 833
 				break;
834 834
 
835 835
 			case 'term':
836
-				$object_id = isset( $_REQUEST['tag_ID'] ) ? $_REQUEST['tag_ID'] : $object_id;
836
+				$object_id = isset( $_REQUEST[ 'tag_ID' ] ) ? $_REQUEST[ 'tag_ID' ] : $object_id;
837 837
 				break;
838 838
 
839 839
 			default:
840
-				$object_id = isset( $GLOBALS['post']->ID ) ? $GLOBALS['post']->ID : $object_id;
841
-				$object_id = isset( $_REQUEST['post'] ) ? $_REQUEST['post'] : $object_id;
840
+				$object_id = isset( $GLOBALS[ 'post' ]->ID ) ? $GLOBALS[ 'post' ]->ID : $object_id;
841
+				$object_id = isset( $_REQUEST[ 'post' ] ) ? $_REQUEST[ 'post' ] : $object_id;
842 842
 				break;
843 843
 		}
844 844
 
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
 	 * @return boolean True/False
910 910
 	 */
911 911
 	public function is_options_page_mb() {
912
-		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'] ) );
912
+		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' ] ) );
913 913
 	}
914 914
 
915 915
 	/**
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
 			$type = 'term';
954 954
 		}
955 955
 
956
-		if ( defined( 'DOING_AJAX' ) && isset( $_POST['action'] ) && 'add-tag' === $_POST['action'] ) {
956
+		if ( defined( 'DOING_AJAX' ) && isset( $_POST[ 'action' ] ) && 'add-tag' === $_POST[ 'action' ] ) {
957 957
 			$type = 'term';
958 958
 		}
959 959
 
@@ -1000,7 +1000,7 @@  discard block
 block discarded – undo
1000 1000
 			return $field;
1001 1001
 		}
1002 1002
 
1003
-		$field_id = is_string( $field ) ? $field : $field['id'];
1003
+		$field_id = is_string( $field ) ? $field : $field[ 'id' ];
1004 1004
 
1005 1005
 		$parent_field_id = ! empty( $field_group ) ? $field_group->id() : '';
1006 1006
 		$ids = $this->get_field_ids( $field_id, $parent_field_id );
@@ -1036,16 +1036,16 @@  discard block
 block discarded – undo
1036 1036
 		if ( $field_group && ( $sub_field_id || 0 === $sub_field_id ) ) {
1037 1037
 
1038 1038
 			// Update the fields array w/ any modified properties inherited from the group field
1039
-			$this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] = $field_args;
1039
+			$this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] = $field_args;
1040 1040
 
1041 1041
 			return $this->get_default_args( $field_args, $field_group );
1042 1042
 		}
1043 1043
 
1044 1044
 		if ( is_array( $field_args ) ) {
1045
-			$this->meta_box['fields'][ $field_id ] = array_merge( $field_args, $this->meta_box['fields'][ $field_id ] );
1045
+			$this->meta_box[ 'fields' ][ $field_id ] = array_merge( $field_args, $this->meta_box[ 'fields' ][ $field_id ] );
1046 1046
 		}
1047 1047
 
1048
-		return $this->get_default_args( $this->meta_box['fields'][ $field_id ] );
1048
+		return $this->get_default_args( $this->meta_box[ 'fields' ][ $field_id ] );
1049 1049
 	}
1050 1050
 
1051 1051
 	/**
@@ -1095,8 +1095,8 @@  discard block
 block discarded – undo
1095 1095
 
1096 1096
 			$sub_fields = false;
1097 1097
 			if ( array_key_exists( 'fields', $field ) ) {
1098
-				$sub_fields = $field['fields'];
1099
-				unset( $field['fields'] );
1098
+				$sub_fields = $field[ 'fields' ];
1099
+				unset( $field[ 'fields' ] );
1100 1100
 			}
1101 1101
 
1102 1102
 			$field_id = $parent_field_id
@@ -1121,31 +1121,31 @@  discard block
 block discarded – undo
1121 1121
 			return false;
1122 1122
 		}
1123 1123
 
1124
-		if ( in_array( $field['type'], array( 'file', 'file_list' ) ) ) {
1124
+		if ( in_array( $field[ 'type' ], array( 'file', 'file_list' ) ) ) {
1125 1125
 			// Initiate attachment JS hooks
1126 1126
 			add_filter( 'wp_prepare_attachment_for_js', 'CMB2_Type_File_Base::prepare_image_sizes_for_js', 10, 3 );
1127 1127
 		}
1128 1128
 
1129
-		if ( 'oembed' === $field['type'] ) {
1129
+		if ( 'oembed' === $field[ 'type' ] ) {
1130 1130
 			// Initiate oembed Ajax hooks
1131 1131
 			cmb2_ajax();
1132 1132
 		}
1133 1133
 
1134
-		if ( isset( $field['column'] ) && false !== $field['column'] ) {
1134
+		if ( isset( $field[ 'column' ] ) && false !== $field[ 'column' ] ) {
1135 1135
 			$field = $this->define_field_column( $field );
1136 1136
 		}
1137 1137
 
1138
-		if ( isset( $field['taxonomy'] ) && ! empty( $field['remove_default'] ) ) {
1139
-			$this->tax_metaboxes_to_remove[ $field['taxonomy'] ] = $field['taxonomy'];
1138
+		if ( isset( $field[ 'taxonomy' ] ) && ! empty( $field[ 'remove_default' ] ) ) {
1139
+			$this->tax_metaboxes_to_remove[ $field[ 'taxonomy' ] ] = $field[ 'taxonomy' ];
1140 1140
 		}
1141 1141
 
1142 1142
 		$this->_add_field_to_array(
1143 1143
 			$field,
1144
-			$this->meta_box['fields'],
1144
+			$this->meta_box[ 'fields' ],
1145 1145
 			$position
1146 1146
 		);
1147 1147
 
1148
-		return $field['id'];
1148
+		return $field[ 'id' ];
1149 1149
 	}
1150 1150
 
1151 1151
 	/**
@@ -1157,10 +1157,10 @@  discard block
 block discarded – undo
1157 1157
 	protected function define_field_column( array $field ) {
1158 1158
 		$this->has_columns = true;
1159 1159
 
1160
-		$column = is_array( $field['column'] ) ? $field['column'] : array();
1160
+		$column = is_array( $field[ 'column' ] ) ? $field[ 'column' ] : array();
1161 1161
 
1162
-		$field['column'] = wp_parse_args( $column, array(
1163
-			'name'     => isset( $field['name'] ) ? $field['name'] : '',
1162
+		$field[ 'column' ] = wp_parse_args( $column, array(
1163
+			'name'     => isset( $field[ 'name' ] ) ? $field[ 'name' ] : '',
1164 1164
 			'position' => false,
1165 1165
 		) );
1166 1166
 
@@ -1176,27 +1176,27 @@  discard block
 block discarded – undo
1176 1176
 	 * @return mixed                   Array of parent/field ids or false
1177 1177
 	 */
1178 1178
 	public function add_group_field( $parent_field_id, array $field, $position = 0 ) {
1179
-		if ( ! array_key_exists( $parent_field_id, $this->meta_box['fields'] ) ) {
1179
+		if ( ! array_key_exists( $parent_field_id, $this->meta_box[ 'fields' ] ) ) {
1180 1180
 			return false;
1181 1181
 		}
1182 1182
 
1183
-		$parent_field = $this->meta_box['fields'][ $parent_field_id ];
1183
+		$parent_field = $this->meta_box[ 'fields' ][ $parent_field_id ];
1184 1184
 
1185
-		if ( 'group' !== $parent_field['type'] ) {
1185
+		if ( 'group' !== $parent_field[ 'type' ] ) {
1186 1186
 			return false;
1187 1187
 		}
1188 1188
 
1189
-		if ( ! isset( $parent_field['fields'] ) ) {
1190
-			$this->meta_box['fields'][ $parent_field_id ]['fields'] = array();
1189
+		if ( ! isset( $parent_field[ 'fields' ] ) ) {
1190
+			$this->meta_box[ 'fields' ][ $parent_field_id ][ 'fields' ] = array();
1191 1191
 		}
1192 1192
 
1193 1193
 		$this->_add_field_to_array(
1194 1194
 			$field,
1195
-			$this->meta_box['fields'][ $parent_field_id ]['fields'],
1195
+			$this->meta_box[ 'fields' ][ $parent_field_id ][ 'fields' ],
1196 1196
 			$position
1197 1197
 		);
1198 1198
 
1199
-		return array( $parent_field_id, $field['id'] );
1199
+		return array( $parent_field_id, $field[ 'id' ] );
1200 1200
 	}
1201 1201
 
1202 1202
 	/**
@@ -1208,9 +1208,9 @@  discard block
 block discarded – undo
1208 1208
 	 */
1209 1209
 	protected function _add_field_to_array( $field, &$fields, $position = 0 ) {
1210 1210
 		if ( $position ) {
1211
-			CMB2_Utils::array_insert( $fields, array( $field['id'] => $field ), $position );
1211
+			CMB2_Utils::array_insert( $fields, array( $field[ 'id' ] => $field ), $position );
1212 1212
 		} else {
1213
-			$fields[ $field['id'] ] = $field;
1213
+			$fields[ $field[ 'id' ] ] = $field;
1214 1214
 		}
1215 1215
 	}
1216 1216
 
@@ -1233,15 +1233,15 @@  discard block
 block discarded – undo
1233 1233
 		unset( $this->fields[ implode( '', $ids ) ] );
1234 1234
 
1235 1235
 		if ( ! $sub_field_id ) {
1236
-			unset( $this->meta_box['fields'][ $field_id ] );
1236
+			unset( $this->meta_box[ 'fields' ][ $field_id ] );
1237 1237
 			return true;
1238 1238
 		}
1239 1239
 
1240
-		if ( isset( $this->fields[ $field_id ]->args['fields'][ $sub_field_id ] ) ) {
1241
-			unset( $this->fields[ $field_id ]->args['fields'][ $sub_field_id ] );
1240
+		if ( isset( $this->fields[ $field_id ]->args[ 'fields' ][ $sub_field_id ] ) ) {
1241
+			unset( $this->fields[ $field_id ]->args[ 'fields' ][ $sub_field_id ] );
1242 1242
 		}
1243
-		if ( isset( $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] ) ) {
1244
-			unset( $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] );
1243
+		if ( isset( $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] ) ) {
1244
+			unset( $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] );
1245 1245
 		}
1246 1246
 		return true;
1247 1247
 	}
@@ -1265,11 +1265,11 @@  discard block
 block discarded – undo
1265 1265
 		list( $field_id, $sub_field_id ) = $ids;
1266 1266
 
1267 1267
 		if ( ! $sub_field_id ) {
1268
-			$this->meta_box['fields'][ $field_id ][ $property ] = $value;
1268
+			$this->meta_box[ 'fields' ][ $field_id ][ $property ] = $value;
1269 1269
 			return $field_id;
1270 1270
 		}
1271 1271
 
1272
-		$this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ][ $property ] = $value;
1272
+		$this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ][ $property ] = $value;
1273 1273
 		return $field_id;
1274 1274
 	}
1275 1275
 
@@ -1283,7 +1283,7 @@  discard block
 block discarded – undo
1283 1283
 	public function get_field_ids( $field_id, $parent_field_id = '' ) {
1284 1284
 		$sub_field_id = $parent_field_id ? $field_id : '';
1285 1285
 		$field_id     = $parent_field_id ? $parent_field_id : $field_id;
1286
-		$fields       =& $this->meta_box['fields'];
1286
+		$fields       = & $this->meta_box[ 'fields' ];
1287 1287
 
1288 1288
 		if ( ! array_key_exists( $field_id, $fields ) ) {
1289 1289
 			$field_id = $this->search_old_school_array( $field_id, $fields );
@@ -1297,12 +1297,12 @@  discard block
 block discarded – undo
1297 1297
 			return array( $field_id, $sub_field_id );
1298 1298
 		}
1299 1299
 
1300
-		if ( 'group' !== $fields[ $field_id ]['type'] ) {
1300
+		if ( 'group' !== $fields[ $field_id ][ 'type' ] ) {
1301 1301
 			return false;
1302 1302
 		}
1303 1303
 
1304
-		if ( ! array_key_exists( $sub_field_id, $fields[ $field_id ]['fields'] ) ) {
1305
-			$sub_field_id = $this->search_old_school_array( $sub_field_id, $fields[ $field_id ]['fields'] );
1304
+		if ( ! array_key_exists( $sub_field_id, $fields[ $field_id ][ 'fields' ] ) ) {
1305
+			$sub_field_id = $this->search_old_school_array( $sub_field_id, $fields[ $field_id ][ 'fields' ] );
1306 1306
 		}
1307 1307
 
1308 1308
 		return false === $sub_field_id ? false : array( $field_id, $sub_field_id );
Please login to merge, or discard this patch.