Completed
Push — trunk ( f37561...2096f9 )
by Justin
07:55
created
includes/rest-api/CMB2_REST_Controller.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 	 * @return WP_REST_Response $response
227 227
 	 */
228 228
 	public function prepare_item_for_response( $data, $request = null ) {
229
-		$data = $this->filter_response_by_context( $data, $this->request['context'] );
229
+		$data = $this->filter_response_by_context( $data, $this->request[ 'context' ] );
230 230
 
231 231
 		/**
232 232
 		 * Filter the prepared CMB2 item response.
@@ -297,12 +297,12 @@  discard block
 block discarded – undo
297 297
 
298 298
 		} else {
299 299
 
300
-			if ( isset( $this->request['object_id'] ) ) {
301
-				$this->rest_box->cmb->object_id( sanitize_text_field( $this->request['object_id'] ) );
300
+			if ( isset( $this->request[ 'object_id' ] ) ) {
301
+				$this->rest_box->cmb->object_id( sanitize_text_field( $this->request[ 'object_id' ] ) );
302 302
 			}
303 303
 
304
-			if ( isset( $this->request['object_type'] ) ) {
305
-				$this->rest_box->cmb->object_type( sanitize_text_field( $this->request['object_type'] ) );
304
+			if ( isset( $this->request[ 'object_type' ] ) ) {
305
+				$this->rest_box->cmb->object_type( sanitize_text_field( $this->request[ 'object_type' ] ) );
306 306
 			}
307 307
 		}
308 308
 	}
@@ -320,8 +320,8 @@  discard block
 block discarded – undo
320 320
 	public function initiate_request( $request, $request_type ) {
321 321
 		$this->request = $request;
322 322
 
323
-		if ( ! isset( $this->request['context'] ) || empty( $this->request['context'] ) ) {
324
-			$this->request['context'] = 'view';
323
+		if ( ! isset( $this->request[ 'context' ] ) || empty( $this->request[ 'context' ] ) ) {
324
+			$this->request[ 'context' ] = 'view';
325 325
 		}
326 326
 
327 327
 		if ( ! self::$request_type ) {
Please login to merge, or discard this patch.
includes/rest-api/CMB2_REST.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -143,30 +143,30 @@  discard block
 block discarded – undo
143 143
 		foreach ( self::$boxes as $cmb_id => $rest_box ) {
144 144
 			$types = array_flip( $rest_box->cmb->box_types() );
145 145
 
146
-			if ( isset( $types['user'] ) ) {
147
-				unset( $types['user'] );
148
-				self::$type_boxes['user'][ $cmb_id ] = $cmb_id;
146
+			if ( isset( $types[ 'user' ] ) ) {
147
+				unset( $types[ 'user' ] );
148
+				self::$type_boxes[ 'user' ][ $cmb_id ] = $cmb_id;
149 149
 			}
150 150
 
151
-			if ( isset( $types['comment'] ) ) {
152
-				unset( $types['comment'] );
153
-				self::$type_boxes['comment'][ $cmb_id ] = $cmb_id;
151
+			if ( isset( $types[ 'comment' ] ) ) {
152
+				unset( $types[ 'comment' ] );
153
+				self::$type_boxes[ 'comment' ][ $cmb_id ] = $cmb_id;
154 154
 			}
155 155
 
156
-			if ( isset( $types['term'] ) ) {
157
-				unset( $types['term'] );
156
+			if ( isset( $types[ 'term' ] ) ) {
157
+				unset( $types[ 'term' ] );
158 158
 
159 159
 				$taxonomies = array_merge(
160 160
 					$taxonomies,
161 161
 					CMB2_Utils::ensure_array( $rest_box->cmb->prop( 'taxonomies' ) )
162 162
 				);
163 163
 
164
-				self::$type_boxes['term'][ $cmb_id ] = $cmb_id;
164
+				self::$type_boxes[ 'term' ][ $cmb_id ] = $cmb_id;
165 165
 			}
166 166
 
167 167
 			if ( ! empty( $types ) ) {
168 168
 				$alltypes = array_merge( $alltypes, array_flip( $types ) );
169
-				self::$type_boxes['post'][ $cmb_id ] = $cmb_id;
169
+				self::$type_boxes[ 'post' ][ $cmb_id ] = $cmb_id;
170 170
 			}
171 171
 		}
172 172
 
@@ -176,15 +176,15 @@  discard block
 block discarded – undo
176 176
 			self::register_rest_field( $alltypes, 'post' );
177 177
 		}
178 178
 
179
-		if ( ! empty( self::$type_boxes['user'] ) ) {
179
+		if ( ! empty( self::$type_boxes[ 'user' ] ) ) {
180 180
 			self::register_rest_field( 'user', 'user' );
181 181
 		}
182 182
 
183
-		if ( ! empty( self::$type_boxes['comment'] ) ) {
183
+		if ( ! empty( self::$type_boxes[ 'comment' ] ) ) {
184 184
 			self::register_rest_field( 'comment', 'comment' );
185 185
 		}
186 186
 
187
-		if ( ! empty( self::$type_boxes['term'] ) ) {
187
+		if ( ! empty( self::$type_boxes[ 'term' ] ) ) {
188 188
 			self::register_rest_field( $taxonomies, 'term' );
189 189
 		}
190 190
 	}
@@ -217,18 +217,18 @@  discard block
 block discarded – undo
217 217
 	 */
218 218
 	protected function declare_read_edit_fields() {
219 219
 		foreach ( $this->cmb->prop( 'fields' ) as $field ) {
220
-			$show_in_rest = isset( $field['show_in_rest'] ) ? $field['show_in_rest'] : null;
220
+			$show_in_rest = isset( $field[ 'show_in_rest' ] ) ? $field[ 'show_in_rest' ] : null;
221 221
 
222 222
 			if ( false === $show_in_rest ) {
223 223
 				continue;
224 224
 			}
225 225
 
226 226
 			if ( $this->can_read( $show_in_rest ) ) {
227
-				$this->read_fields[] = $field['id'];
227
+				$this->read_fields[ ] = $field[ 'id' ];
228 228
 			}
229 229
 
230 230
 			if ( $this->can_edit( $show_in_rest ) ) {
231
-				$this->edit_fields[] = $field['id'];
231
+				$this->edit_fields[ ] = $field[ 'id' ];
232 232
 			}
233 233
 
234 234
 		}
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 	 * @return mixed
360 360
 	 */
361 361
 	protected static function get_rest_values( $object, $request, $object_type, $main_object_type = 'post' ) {
362
-		if ( ! isset( $object['id'] ) ) {
362
+		if ( ! isset( $object[ 'id' ] ) ) {
363 363
 			return;
364 364
 		}
365 365
 
@@ -370,12 +370,12 @@  discard block
 block discarded – undo
370 370
 				$rest_box = self::$boxes[ $cmb_id ];
371 371
 
372 372
 				foreach ( $rest_box->read_fields as $field_id ) {
373
-					$rest_box->cmb->object_id( $object['id'] );
373
+					$rest_box->cmb->object_id( $object[ 'id' ] );
374 374
 					$rest_box->cmb->object_type( $main_object_type );
375 375
 
376 376
 					$field = $rest_box->cmb->get_field( $field_id );
377 377
 
378
-					$field->object_id( $object['id'] );
378
+					$field->object_id( $object[ 'id' ] );
379 379
 					$field->object_type( $main_object_type );
380 380
 
381 381
 					$values[ $cmb_id ][ $field->id( true ) ] = $field->get_data();
@@ -609,8 +609,8 @@  discard block
 block discarded – undo
609 609
 					return intval( $object->comment_ID );
610 610
 				}
611 611
 			case 'term':
612
-				if ( is_array( $object ) && isset( $object['term_id'] ) ) {
613
-					return intval( $object['term_id'] );
612
+				if ( is_array( $object ) && isset( $object[ 'term_id' ] ) ) {
613
+					return intval( $object[ 'term_id' ] );
614 614
 				} elseif ( isset( $object->term_id ) ) {
615 615
 					return intval( $object->term_id );
616 616
 				}
Please login to merge, or discard this patch.
includes/CMB2_Base.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 		}
359 359
 
360 360
 		// Cast to bool.
361
-		return !! $val;
361
+		return ! ! $val;
362 362
 	}
363 363
 
364 364
 	/**
@@ -386,11 +386,11 @@  discard block
 block discarded – undo
386 386
 			switch ( $message ) {
387 387
 
388 388
 				case self::DEPRECATED_PARAM:
389
-					$message = sprintf( __( 'The "%s" field parameter has been deprecated in favor of the "%s" parameter.', 'cmb2' ), $args[3], $args[4] );
389
+					$message = sprintf( __( 'The "%s" field parameter has been deprecated in favor of the "%s" parameter.', 'cmb2' ), $args[ 3 ], $args[ 4 ] );
390 390
 					break;
391 391
 
392 392
 				case self::DEPRECATED_CB_PARAM:
393
-					$message = sprintf( __( 'Using the "%s" field parameter as a callback has been deprecated in favor of the "%s" parameter.', 'cmb2' ), $args[3], $args[4] );
393
+					$message = sprintf( __( 'Using the "%s" field parameter as a callback has been deprecated in favor of the "%s" parameter.', 'cmb2' ), $args[ 3 ], $args[ 4 ] );
394 394
 					break;
395 395
 
396 396
 				default:
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 	public function __call( $method, $args ) {
470 470
 		$object_class = strtolower( get_class( $this ) );
471 471
 
472
-		if ( ! has_filter(  "{$object_class}_inherit_{$method}" ) ) {
472
+		if ( ! has_filter( "{$object_class}_inherit_{$method}" ) ) {
473 473
 			throw new Exception( sprintf( esc_html__( 'Invalid %1$s method: %2$s', 'give' ), get_class( $this ), $method ) );
474 474
 		}
475 475
 
Please login to merge, or discard this patch.
includes/rest-api/CMB2_REST_Controller_Boxes.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 			'schema' => array( $this, 'get_item_schema' ),
69 69
 		) );
70 70
 
71
-		$args['_rendered'] = array(
71
+		$args[ '_rendered' ] = array(
72 72
 			'description' => __( 'Includes the fully rendered attributes, \'form_open\', \'form_close\', as well as the enqueued \'js_dependencies\' script handles, and \'css_dependencies\' stylesheet handles.', 'cmb2' ),
73 73
 		);
74 74
 
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
 				// And make sure current user can view this box.
133 133
 				&& $this->get_item_permissions_check_filter( $this->request )
134 134
 			) {
135
-				$boxes_data[] = $this->server->response_to_data(
135
+				$boxes_data[ ] = $this->server->response_to_data(
136 136
 					$this->get_rest_box(),
137
-					isset( $this->request['_embed'] )
137
+					isset( $this->request[ '_embed' ] )
138 138
 				);
139 139
 			}
140 140
 		}
@@ -210,9 +210,9 @@  discard block
 block discarded – undo
210 210
 
211 211
 		$boxes_data = $cmb->meta_box;
212 212
 
213
-		if ( isset( $this->request['_rendered'] ) && $this->namespace_base !== ltrim( CMB2_REST_Controller::get_intial_route(), '/' ) ) {
214
-			$boxes_data['form_open'] = $this->get_cb_results( array( $cmb, 'render_form_open' ) );
215
-			$boxes_data['form_close'] = $this->get_cb_results( array( $cmb, 'render_form_close' ) );
213
+		if ( isset( $this->request[ '_rendered' ] ) && $this->namespace_base !== ltrim( CMB2_REST_Controller::get_intial_route(), '/' ) ) {
214
+			$boxes_data[ 'form_open' ] = $this->get_cb_results( array( $cmb, 'render_form_open' ) );
215
+			$boxes_data[ 'form_close' ] = $this->get_cb_results( array( $cmb, 'render_form_close' ) );
216 216
 
217 217
 			global $wp_scripts, $wp_styles;
218 218
 			$before_css = $wp_styles->queue;
@@ -220,15 +220,15 @@  discard block
 block discarded – undo
220 220
 
221 221
 			CMB2_JS::enqueue();
222 222
 
223
-			$boxes_data['js_dependencies'] = array_values( array_diff( $wp_scripts->queue, $before_js ) );
224
-			$boxes_data['css_dependencies'] = array_values( array_diff( $wp_styles->queue, $before_css ) );
223
+			$boxes_data[ 'js_dependencies' ] = array_values( array_diff( $wp_scripts->queue, $before_js ) );
224
+			$boxes_data[ 'css_dependencies' ] = array_values( array_diff( $wp_styles->queue, $before_css ) );
225 225
 		}
226 226
 
227 227
 		// TODO: look into 'embed' parameter.
228 228
 		// http://demo.wp-api.org/wp-json/wp/v2/posts?_embed
229
-		unset( $boxes_data['fields'] );
229
+		unset( $boxes_data[ 'fields' ] );
230 230
 		// Handle callable properties.
231
-		unset( $boxes_data['show_on_cb'] );
231
+		unset( $boxes_data[ 'show_on_cb' ] );
232 232
 
233 233
 		$response = rest_ensure_response( $boxes_data );
234 234
 
Please login to merge, or discard this patch.
includes/rest-api/CMB2_REST_Controller_Fields.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 		) );
50 50
 
51 51
 		$delete_args = $args;
52
-		$delete_args['object_id']['required'] = true;
53
-		$delete_args['object_type']['required'] = true;
52
+		$delete_args[ 'object_id' ][ 'required' ] = true;
53
+		$delete_args[ 'object_type' ][ 'required' ] = true;
54 54
 
55 55
 		// Returns specific field data.
56 56
 		register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<cmb_id>[\w-]+)/fields/(?P<field_id>[\w-]+)', array(
@@ -122,13 +122,13 @@  discard block
 block discarded – undo
122 122
 		foreach ( $this->rest_box->cmb->prop( 'fields', array() ) as $field ) {
123 123
 
124 124
 			// Make sure this field can be read.
125
-			$this->field = $this->rest_box->field_can_read( $field['id'], true );
125
+			$this->field = $this->rest_box->field_can_read( $field[ 'id' ], true );
126 126
 
127 127
 			// And make sure current user can view this box.
128 128
 			if ( $this->field && $this->get_item_permissions_check_filter() ) {
129
-				$fields[ $field['id'] ] = $this->server->response_to_data(
129
+				$fields[ $field[ 'id' ] ] = $this->server->response_to_data(
130 130
 					$this->prepare_field_response(),
131
-					isset( $this->request['_embed'] )
131
+					isset( $this->request[ '_embed' ] )
132 132
 				);
133 133
 			}
134 134
 		}
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	public function update_item( $request ) {
235 235
 		$this->initiate_rest_read_box( $request, 'field_value_update' );
236 236
 
237
-		if ( ! $this->request['value'] ) {
237
+		if ( ! $this->request[ 'value' ] ) {
238 238
 			return new WP_Error( 'cmb2_rest_update_field_error', __( 'CMB2 Field value cannot be updated without the value parameter specified.', 'cmb2' ), array( 'status' => 400 ) );
239 239
 		}
240 240
 
@@ -291,9 +291,9 @@  discard block
 block discarded – undo
291 291
 	 * @param  string $activity The modification activity (updated or deleted).
292 292
 	 * @return WP_Error|WP_REST_Response
293 293
 	 */
294
-	public function modify_field_value( $activity) {
294
+	public function modify_field_value( $activity ) {
295 295
 
296
-		if ( ! $this->request['object_id'] || ! $this->request['object_type'] ) {
296
+		if ( ! $this->request[ 'object_id' ] || ! $this->request[ 'object_type' ] ) {
297 297
 			return new WP_Error( 'cmb2_rest_modify_field_value_error', __( 'CMB2 Field value cannot be modified without the object_id and object_type parameters specified.', 'cmb2' ), array( 'status' => 400 ) );
298 298
 		}
299 299
 
@@ -310,13 +310,13 @@  discard block
 block discarded – undo
310 310
 			return new WP_Error( 'cmb2_rest_no_field_by_id_error', __( 'No field found by that id.', 'cmb2' ), array( 'status' => 403 ) );
311 311
 		}
312 312
 
313
-		$this->field->args["value_{$activity}"] = (bool) 'deleted' === $activity
313
+		$this->field->args[ "value_{$activity}" ] = (bool) 'deleted' === $activity
314 314
 			? $this->field->remove_data()
315
-			: $this->field->save_field( $this->request['value'] );
315
+			: $this->field->save_field( $this->request[ 'value' ] );
316 316
 
317 317
 		// If options page, save the $activity options
318
-		if ( 'options-page' == $this->request['object_type'] ) {
319
-			$this->field->args["value_{$activity}"] = cmb2_options( $this->request['object_id'] )->set();
318
+		if ( 'options-page' == $this->request[ 'object_type' ] ) {
319
+			$this->field->args[ "value_{$activity}" ] = cmb2_options( $this->request[ 'object_id' ] )->set();
320 320
 		}
321 321
 
322 322
 		return $this->prepare_read_field( $this->field );
@@ -391,13 +391,13 @@  discard block
 block discarded – undo
391 391
 				$value = $field->options();
392 392
 			} elseif ( in_array( $key, CMB2_Field::$callable_fields, true ) ) {
393 393
 
394
-				if ( isset( $this->request['_rendered'] ) ) {
394
+				if ( isset( $this->request[ '_rendered' ] ) ) {
395 395
 					$value = $key === 'render_row_cb' ? $rendered : $field->get_param_callback_result( $key );
396 396
 				} elseif ( is_array( $value ) ) {
397 397
 					// We need to rewrite callbacks as string as they will cause
398 398
 					// JSON recursion errors.
399
-					$class = is_string( $value[0] ) ? $value[0] : get_class( $value[0] );
400
-					$value = $class . '::' . $value[1];
399
+					$class = is_string( $value[ 0 ] ) ? $value[ 0 ] : get_class( $value[ 0 ] );
400
+					$value = $class . '::' . $value[ 1 ];
401 401
 				}
402 402
 			}
403 403
 
@@ -410,8 +410,8 @@  discard block
 block discarded – undo
410 410
 			}
411 411
 		}
412 412
 
413
-		if ( $this->request['object_id'] && $this->request['object_type'] ) {
414
-			$field_data['value'] = $field->get_data();
413
+		if ( $this->request[ 'object_id' ] && $this->request[ 'object_type' ] ) {
414
+			$field_data[ 'value' ] = $field->get_data();
415 415
 		}
416 416
 
417 417
 		return $field_data;
Please login to merge, or discard this patch.
example-functions.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	$cmb_demo = new_cmb2_box( array(
116 116
 		'id'            => $prefix . 'metabox',
117 117
 		'title'         => esc_html__( 'Test Metabox', 'cmb2' ),
118
-		'object_types'  => array( 'page', ), // Post type
118
+		'object_types'  => array( 'page',), // Post type
119 119
 		// 'show_on_cb' => 'yourprefix_show_if_front_page', // function should return a bool value
120 120
 		// 'context'    => 'normal',
121 121
 		// 'priority'   => 'high',
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 		'desc'    => esc_html__( 'field description (optional)', 'cmb2' ),
386 386
 		'id'      => $prefix . 'wysiwyg',
387 387
 		'type'    => 'wysiwyg',
388
-		'options' => array( 'textarea_rows' => 5, ),
388
+		'options' => array( 'textarea_rows' => 5,),
389 389
 	) );
390 390
 
391 391
 	$cmb_demo->add_field( array(
@@ -441,11 +441,11 @@  discard block
 block discarded – undo
441 441
 	$cmb_about_page = new_cmb2_box( array(
442 442
 		'id'           => $prefix . 'metabox',
443 443
 		'title'        => esc_html__( 'About Page Metabox', 'cmb2' ),
444
-		'object_types' => array( 'page', ), // Post type
444
+		'object_types' => array( 'page',), // Post type
445 445
 		'context'      => 'normal',
446 446
 		'priority'     => 'high',
447 447
 		'show_names'   => true, // Show field names on the left
448
-		'show_on'      => array( 'id' => array( 2, ) ), // Specific post IDs to display this metabox
448
+		'show_on'      => array( 'id' => array( 2,) ), // Specific post IDs to display this metabox
449 449
 	) );
450 450
 
451 451
 	$cmb_about_page->add_field( array(
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 	$cmb_group = new_cmb2_box( array(
471 471
 		'id'           => $prefix . 'metabox',
472 472
 		'title'        => esc_html__( 'Repeating Field Group', 'cmb2' ),
473
-		'object_types' => array( 'page', ),
473
+		'object_types' => array( 'page',),
474 474
 	) );
475 475
 
476 476
 	// $group_field_id is the field id string, so in this case: $prefix . 'demo'
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
 	$cmb_rest = new_cmb2_box( array(
700 700
 		'id'            => $prefix . 'metabox',
701 701
 		'title'         => esc_html__( 'REST Test Box', 'cmb2' ),
702
-		'object_types'  => array( 'page', ), // Post type
702
+		'object_types'  => array( 'page',), // Post type
703 703
 		'show_in_rest' => WP_REST_Server::ALLMETHODS, // WP_REST_Server::READABLE|WP_REST_Server::EDITABLE, // Determines which HTTP methods the box is visible in.
704 704
 		// Optional callback to limit box visibility.
705 705
 		// See: https://github.com/WebDevStudios/CMB2/wiki/REST-API#permissions
Please login to merge, or discard this patch.
includes/CMB2_Types.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
 		// Check for methods to be proxied to the CMB2_Type_Base object.
55 55
 		if ( $exists = $this->maybe_proxy_method( $fieldtype, $arguments ) ) {
56
-			return $exists['value'];
56
+			return $exists[ 'value' ];
57 57
 		}
58 58
 
59 59
 		// Check for custom field type class.
@@ -448,8 +448,8 @@  discard block
 block discarded – undo
448 448
 			'class' => 'cmb2-hidden',
449 449
 		);
450 450
 		if ( $this->field->group ) {
451
-			$args['data-groupid'] = $this->field->group->id();
452
-			$args['data-iterator'] = $this->iterator;
451
+			$args[ 'data-groupid' ] = $this->field->group->id();
452
+			$args[ 'data-iterator' ] = $this->iterator;
453 453
 		}
454 454
 		return $this->input( $args );
455 455
 	}
Please login to merge, or discard this patch.
includes/CMB2.php 1 patch
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -113,19 +113,19 @@  discard block
 block discarded – undo
113 113
 	 */
114 114
 	public function __construct( $config, $object_id = 0 ) {
115 115
 
116
-		if ( empty( $config['id'] ) ) {
116
+		if ( empty( $config[ 'id' ] ) ) {
117 117
 			wp_die( esc_html__( 'Metabox configuration is required to have an ID parameter.', 'cmb2' ) );
118 118
 		}
119 119
 
120 120
 		$this->meta_box = wp_parse_args( $config, $this->mb_defaults );
121
-		$this->meta_box['fields'] = array();
121
+		$this->meta_box[ 'fields' ] = array();
122 122
 
123 123
 		$this->object_id( $object_id );
124 124
 		$this->mb_object_type();
125
-		$this->cmb_id = $config['id'];
125
+		$this->cmb_id = $config[ 'id' ];
126 126
 
127
-		if ( ! empty( $config['fields'] ) && is_array( $config['fields'] ) ) {
128
-			$this->add_fields( $config['fields'] );
127
+		if ( ! empty( $config[ 'fields' ] ) && is_array( $config[ 'fields' ] ) ) {
128
+			$this->add_fields( $config[ 'fields' ] );
129 129
 		}
130 130
 
131 131
 		CMB2_Boxes::add( $this );
@@ -294,22 +294,22 @@  discard block
 block discarded – undo
294 294
 	 * @return mixed CMB2_Field object if successful.
295 295
 	 */
296 296
 	public function render_field( $field_args ) {
297
-		$field_args['context'] = $this->prop( 'context' );
297
+		$field_args[ 'context' ] = $this->prop( 'context' );
298 298
 
299
-		if ( 'group' == $field_args['type'] ) {
299
+		if ( 'group' == $field_args[ 'type' ] ) {
300 300
 
301
-			if ( ! isset( $field_args['show_names'] ) ) {
302
-				$field_args['show_names'] = $this->prop( 'show_names' );
301
+			if ( ! isset( $field_args[ 'show_names' ] ) ) {
302
+				$field_args[ 'show_names' ] = $this->prop( 'show_names' );
303 303
 			}
304 304
 			$field = $this->render_group( $field_args );
305 305
 
306
-		} elseif ( 'hidden' == $field_args['type'] && $this->get_field( $field_args )->should_show() ) {
306
+		} elseif ( 'hidden' == $field_args[ 'type' ] && $this->get_field( $field_args )->should_show() ) {
307 307
 			// Save rendering for after the metabox
308 308
 			$field = $this->add_hidden_field( $field_args );
309 309
 
310 310
 		} else {
311 311
 
312
-			$field_args['show_names'] = $this->prop( 'show_names' );
312
+			$field_args[ 'show_names' ] = $this->prop( 'show_names' );
313 313
 
314 314
 			// Render default fields
315 315
 			$field = $this->get_field( $field_args )->render_field();
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 	 */
326 326
 	public function render_group( $args ) {
327 327
 
328
-		if ( ! isset( $args['id'], $args['fields'] ) || ! is_array( $args['fields'] ) ) {
328
+		if ( ! isset( $args[ 'id' ], $args[ 'fields' ] ) || ! is_array( $args[ 'fields' ] ) ) {
329 329
 			return;
330 330
 		}
331 331
 
@@ -435,15 +435,15 @@  discard block
 block discarded – undo
435 435
 			<div class="inside cmb-td cmb-nested cmb-field-list">';
436 436
 				// Loop and render repeatable group fields
437 437
 				foreach ( array_values( $field_group->args( 'fields' ) ) as $field_args ) {
438
-					if ( 'hidden' == $field_args['type'] ) {
438
+					if ( 'hidden' == $field_args[ 'type' ] ) {
439 439
 
440 440
 						// Save rendering for after the metabox
441 441
 						$this->add_hidden_field( $field_args, $field_group );
442 442
 
443 443
 					} else {
444 444
 
445
-						$field_args['show_names'] = $field_group->args( 'show_names' );
446
-						$field_args['context']    = $field_group->args( 'context' );
445
+						$field_args[ 'show_names' ] = $field_group->args( 'show_names' );
446
+						$field_args[ 'context' ]    = $field_group->args( 'context' );
447 447
 
448 448
 						$field = $this->get_field( $field_args, $field_group )->render_field();
449 449
 					}
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 	 * @param CMB2_Field|null $field_group CMB2_Field group field object
473 473
 	 */
474 474
 	public function add_hidden_field( $field_args, $field_group = null ) {
475
-		if ( isset( $field_args['field_args'] ) ) {
475
+		if ( isset( $field_args[ 'field_args' ] ) ) {
476 476
 			// For back-compatibility.
477 477
 			$field = new CMB2_Field( $field_args );
478 478
 		} else {
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 			$type->iterator = $field_group->index;
486 486
 		}
487 487
 
488
-		$this->hidden_fields[] = $type;
488
+		$this->hidden_fields[ ] = $type;
489 489
 
490 490
 		return $field;
491 491
 	}
@@ -582,11 +582,11 @@  discard block
 block discarded – undo
582 582
 	 */
583 583
 	public function process_field( $field_args ) {
584 584
 
585
-		switch ( $field_args['type'] ) {
585
+		switch ( $field_args[ 'type' ] ) {
586 586
 
587 587
 			case 'group':
588 588
 				if ( $this->save_group( $field_args ) ) {
589
-					$this->updated[] = $field_args['id'];
589
+					$this->updated[ ] = $field_args[ 'id' ];
590 590
 				}
591 591
 
592 592
 				break;
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 				$field = $this->get_new_field( $field_args );
601 601
 
602 602
 				if ( $field->save_field_from_data( $this->data_to_save ) ) {
603
-					$this->updated[] = $field->id();
603
+					$this->updated[ ] = $field->id();
604 604
 				}
605 605
 
606 606
 				break;
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 	 * @return mixed        Return of CMB2_Field::update_data()
668 668
 	 */
669 669
 	public function save_group( $args ) {
670
-		if ( ! isset( $args['id'], $args['fields'] ) || ! is_array( $args['fields'] ) ) {
670
+		if ( ! isset( $args[ 'id' ], $args[ 'fields' ] ) || ! is_array( $args[ 'fields' ] ) ) {
671 671
 			return;
672 672
 		}
673 673
 
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 		$field_group->data_to_save = $this->data_to_save;
697 697
 
698 698
 		foreach ( array_values( $field_group->fields() ) as $field_args ) {
699
-			if ( 'title' === $field_args['type'] ) {
699
+			if ( 'title' === $field_args[ 'type' ] ) {
700 700
 				// Don't process title fields
701 701
 				continue;
702 702
 			}
@@ -719,16 +719,16 @@  discard block
 block discarded – undo
719 719
 						$_new_val = array();
720 720
 						foreach ( $new_val as $group_index => $grouped_data ) {
721 721
 							// Add the supporting data to the $saved array stack
722
-							$saved[ $field_group->index ][ $grouped_data['supporting_field_id'] ][] = $grouped_data['supporting_field_value'];
722
+							$saved[ $field_group->index ][ $grouped_data[ 'supporting_field_id' ] ][ ] = $grouped_data[ 'supporting_field_value' ];
723 723
 							// Reset var to the actual value
724
-							$_new_val[ $group_index ] = $grouped_data['value'];
724
+							$_new_val[ $group_index ] = $grouped_data[ 'value' ];
725 725
 						}
726 726
 						$new_val = $_new_val;
727 727
 					} else {
728 728
 						// Add the supporting data to the $saved array stack
729
-						$saved[ $field_group->index ][ $new_val['supporting_field_id'] ] = $new_val['supporting_field_value'];
729
+						$saved[ $field_group->index ][ $new_val[ 'supporting_field_id' ] ] = $new_val[ 'supporting_field_value' ];
730 730
 						// Reset var to the actual value
731
-						$new_val = $new_val['value'];
731
+						$new_val = $new_val[ 'value' ];
732 732
 					}
733 733
 				}
734 734
 
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
 
743 743
 				// Compare values and add to `$updated` array
744 744
 				if ( $is_updated || $is_removed ) {
745
-					$this->updated[] = $base_id . '::' . $field_group->index . '::' . $sub_id;
745
+					$this->updated[ ] = $base_id . '::' . $field_group->index . '::' . $sub_id;
746 746
 				}
747 747
 
748 748
 				// Add to `$saved` array
@@ -779,22 +779,22 @@  discard block
 block discarded – undo
779 779
 		// Try to get our object ID from the global space
780 780
 		switch ( $this->object_type() ) {
781 781
 			case 'user':
782
-				$object_id = isset( $_REQUEST['user_id'] ) ? $_REQUEST['user_id'] : $object_id;
783
-				$object_id = ! $object_id && 'user-new.php' != $pagenow && isset( $GLOBALS['user_ID'] ) ? $GLOBALS['user_ID'] : $object_id;
782
+				$object_id = isset( $_REQUEST[ 'user_id' ] ) ? $_REQUEST[ 'user_id' ] : $object_id;
783
+				$object_id = ! $object_id && 'user-new.php' != $pagenow && isset( $GLOBALS[ 'user_ID' ] ) ? $GLOBALS[ 'user_ID' ] : $object_id;
784 784
 				break;
785 785
 
786 786
 			case 'comment':
787
-				$object_id = isset( $_REQUEST['c'] ) ? $_REQUEST['c'] : $object_id;
788
-				$object_id = ! $object_id && isset( $GLOBALS['comments']->comment_ID ) ? $GLOBALS['comments']->comment_ID : $object_id;
787
+				$object_id = isset( $_REQUEST[ 'c' ] ) ? $_REQUEST[ 'c' ] : $object_id;
788
+				$object_id = ! $object_id && isset( $GLOBALS[ 'comments' ]->comment_ID ) ? $GLOBALS[ 'comments' ]->comment_ID : $object_id;
789 789
 				break;
790 790
 
791 791
 			case 'term':
792
-				$object_id = isset( $_REQUEST['tag_ID'] ) ? $_REQUEST['tag_ID'] : $object_id;
792
+				$object_id = isset( $_REQUEST[ 'tag_ID' ] ) ? $_REQUEST[ 'tag_ID' ] : $object_id;
793 793
 				break;
794 794
 
795 795
 			default:
796
-				$object_id = isset( $GLOBALS['post']->ID ) ? $GLOBALS['post']->ID : $object_id;
797
-				$object_id = isset( $_REQUEST['post'] ) ? $_REQUEST['post'] : $object_id;
796
+				$object_id = isset( $GLOBALS[ 'post' ]->ID ) ? $GLOBALS[ 'post' ]->ID : $object_id;
797
+				$object_id = isset( $_REQUEST[ 'post' ] ) ? $_REQUEST[ 'post' ] : $object_id;
798 798
 				break;
799 799
 		}
800 800
 
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
 	 * @return boolean True/False
866 866
 	 */
867 867
 	public function is_options_page_mb() {
868
-		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'] ) );
868
+		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' ] ) );
869 869
 	}
870 870
 
871 871
 	/**
@@ -952,7 +952,7 @@  discard block
 block discarded – undo
952 952
 			return $field;
953 953
 		}
954 954
 
955
-		$field_id = is_string( $field ) ? $field : $field['id'];
955
+		$field_id = is_string( $field ) ? $field : $field[ 'id' ];
956 956
 
957 957
 		$parent_field_id = ! empty( $field_group ) ? $field_group->id() : '';
958 958
 		$ids = $this->get_field_ids( $field_id, $parent_field_id, true );
@@ -988,16 +988,16 @@  discard block
 block discarded – undo
988 988
 		if ( $field_group && ( $sub_field_id || 0 === $sub_field_id ) ) {
989 989
 
990 990
 			// Update the fields array w/ any modified properties inherited from the group field
991
-			$this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] = $field_args;
991
+			$this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] = $field_args;
992 992
 
993 993
 			return $this->get_default_args( $field_args, $field_group );
994 994
 		}
995 995
 
996 996
 		if ( is_array( $field_args ) ) {
997
-			$this->meta_box['fields'][ $field_id ] = array_merge( $field_args, $this->meta_box['fields'][ $field_id ] );
997
+			$this->meta_box[ 'fields' ][ $field_id ] = array_merge( $field_args, $this->meta_box[ 'fields' ][ $field_id ] );
998 998
 		}
999 999
 
1000
-		return $this->get_default_args( $this->meta_box['fields'][ $field_id ] );
1000
+		return $this->get_default_args( $this->meta_box[ 'fields' ][ $field_id ] );
1001 1001
 	}
1002 1002
 
1003 1003
 	/**
@@ -1047,8 +1047,8 @@  discard block
 block discarded – undo
1047 1047
 
1048 1048
 			$sub_fields = false;
1049 1049
 			if ( array_key_exists( 'fields', $field ) ) {
1050
-				$sub_fields = $field['fields'];
1051
-				unset( $field['fields'] );
1050
+				$sub_fields = $field[ 'fields' ];
1051
+				unset( $field[ 'fields' ] );
1052 1052
 			}
1053 1053
 
1054 1054
 			$field_id = $parent_field_id
@@ -1073,26 +1073,26 @@  discard block
 block discarded – undo
1073 1073
 			return false;
1074 1074
 		}
1075 1075
 
1076
-		if ( 'oembed' === $field['type'] ) {
1076
+		if ( 'oembed' === $field[ 'type' ] ) {
1077 1077
 			// Initiate oembed Ajax hooks
1078 1078
 			cmb2_ajax();
1079 1079
 		}
1080 1080
 
1081
-		if ( isset( $field['column'] ) && false !== $field['column'] ) {
1081
+		if ( isset( $field[ 'column' ] ) && false !== $field[ 'column' ] ) {
1082 1082
 			$field = $this->define_field_column( $field );
1083 1083
 		}
1084 1084
 
1085
-		if ( isset( $field['taxonomy'] ) && ! empty( $field['remove_default'] ) ) {
1086
-			$this->tax_metaboxes_to_remove[ $field['taxonomy'] ] = $field['taxonomy'];
1085
+		if ( isset( $field[ 'taxonomy' ] ) && ! empty( $field[ 'remove_default' ] ) ) {
1086
+			$this->tax_metaboxes_to_remove[ $field[ 'taxonomy' ] ] = $field[ 'taxonomy' ];
1087 1087
 		}
1088 1088
 
1089 1089
 		$this->_add_field_to_array(
1090 1090
 			$field,
1091
-			$this->meta_box['fields'],
1091
+			$this->meta_box[ 'fields' ],
1092 1092
 			$position
1093 1093
 		);
1094 1094
 
1095
-		return $field['id'];
1095
+		return $field[ 'id' ];
1096 1096
 	}
1097 1097
 
1098 1098
 	/**
@@ -1104,10 +1104,10 @@  discard block
 block discarded – undo
1104 1104
 	protected function define_field_column( array $field ) {
1105 1105
 		$this->has_columns = true;
1106 1106
 
1107
-		$column = is_array( $field['column'] ) ? $field['column'] : array();
1107
+		$column = is_array( $field[ 'column' ] ) ? $field[ 'column' ] : array();
1108 1108
 
1109
-		$field['column'] = wp_parse_args( $column, array(
1110
-			'name'     => isset( $field['name'] ) ? $field['name'] : '',
1109
+		$field[ 'column' ] = wp_parse_args( $column, array(
1110
+			'name'     => isset( $field[ 'name' ] ) ? $field[ 'name' ] : '',
1111 1111
 			'position' => false,
1112 1112
 		) );
1113 1113
 
@@ -1123,27 +1123,27 @@  discard block
 block discarded – undo
1123 1123
 	 * @return mixed                   Array of parent/field ids or false
1124 1124
 	 */
1125 1125
 	public function add_group_field( $parent_field_id, array $field, $position = 0 ) {
1126
-		if ( ! array_key_exists( $parent_field_id, $this->meta_box['fields'] ) ) {
1126
+		if ( ! array_key_exists( $parent_field_id, $this->meta_box[ 'fields' ] ) ) {
1127 1127
 			return false;
1128 1128
 		}
1129 1129
 
1130
-		$parent_field = $this->meta_box['fields'][ $parent_field_id ];
1130
+		$parent_field = $this->meta_box[ 'fields' ][ $parent_field_id ];
1131 1131
 
1132
-		if ( 'group' !== $parent_field['type'] ) {
1132
+		if ( 'group' !== $parent_field[ 'type' ] ) {
1133 1133
 			return false;
1134 1134
 		}
1135 1135
 
1136
-		if ( ! isset( $parent_field['fields'] ) ) {
1137
-			$this->meta_box['fields'][ $parent_field_id ]['fields'] = array();
1136
+		if ( ! isset( $parent_field[ 'fields' ] ) ) {
1137
+			$this->meta_box[ 'fields' ][ $parent_field_id ][ 'fields' ] = array();
1138 1138
 		}
1139 1139
 
1140 1140
 		$this->_add_field_to_array(
1141 1141
 			$field,
1142
-			$this->meta_box['fields'][ $parent_field_id ]['fields'],
1142
+			$this->meta_box[ 'fields' ][ $parent_field_id ][ 'fields' ],
1143 1143
 			$position
1144 1144
 		);
1145 1145
 
1146
-		return array( $parent_field_id, $field['id'] );
1146
+		return array( $parent_field_id, $field[ 'id' ] );
1147 1147
 	}
1148 1148
 
1149 1149
 	/**
@@ -1155,9 +1155,9 @@  discard block
 block discarded – undo
1155 1155
 	 */
1156 1156
 	protected function _add_field_to_array( $field, &$fields, $position = 0 ) {
1157 1157
 		if ( $position ) {
1158
-			CMB2_Utils::array_insert( $fields, array( $field['id'] => $field ), $position );
1158
+			CMB2_Utils::array_insert( $fields, array( $field[ 'id' ] => $field ), $position );
1159 1159
 		} else {
1160
-			$fields[ $field['id'] ] = $field;
1160
+			$fields[ $field[ 'id' ] ] = $field;
1161 1161
 		}
1162 1162
 	}
1163 1163
 
@@ -1180,15 +1180,15 @@  discard block
 block discarded – undo
1180 1180
 		unset( $this->fields[ implode( '', $ids ) ] );
1181 1181
 
1182 1182
 		if ( ! $sub_field_id ) {
1183
-			unset( $this->meta_box['fields'][ $field_id ] );
1183
+			unset( $this->meta_box[ 'fields' ][ $field_id ] );
1184 1184
 			return true;
1185 1185
 		}
1186 1186
 
1187
-		if ( isset( $this->fields[ $field_id ]->args['fields'][ $sub_field_id ] ) ) {
1188
-			unset( $this->fields[ $field_id ]->args['fields'][ $sub_field_id ] );
1187
+		if ( isset( $this->fields[ $field_id ]->args[ 'fields' ][ $sub_field_id ] ) ) {
1188
+			unset( $this->fields[ $field_id ]->args[ 'fields' ][ $sub_field_id ] );
1189 1189
 		}
1190
-		if ( isset( $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] ) ) {
1191
-			unset( $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] );
1190
+		if ( isset( $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] ) ) {
1191
+			unset( $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] );
1192 1192
 		}
1193 1193
 		return true;
1194 1194
 	}
@@ -1212,11 +1212,11 @@  discard block
 block discarded – undo
1212 1212
 		list( $field_id, $sub_field_id ) = $ids;
1213 1213
 
1214 1214
 		if ( ! $sub_field_id ) {
1215
-			$this->meta_box['fields'][ $field_id ][ $property ] = $value;
1215
+			$this->meta_box[ 'fields' ][ $field_id ][ $property ] = $value;
1216 1216
 			return $field_id;
1217 1217
 		}
1218 1218
 
1219
-		$this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ][ $property ] = $value;
1219
+		$this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ][ $property ] = $value;
1220 1220
 		return $field_id;
1221 1221
 	}
1222 1222
 
@@ -1230,7 +1230,7 @@  discard block
 block discarded – undo
1230 1230
 	public function get_field_ids( $field_id, $parent_field_id = '' ) {
1231 1231
 		$sub_field_id = $parent_field_id ? $field_id : '';
1232 1232
 		$field_id     = $parent_field_id ? $parent_field_id : $field_id;
1233
-		$fields       =& $this->meta_box['fields'];
1233
+		$fields       = & $this->meta_box[ 'fields' ];
1234 1234
 
1235 1235
 		if ( ! array_key_exists( $field_id, $fields ) ) {
1236 1236
 			$field_id = $this->search_old_school_array( $field_id, $fields );
@@ -1244,12 +1244,12 @@  discard block
 block discarded – undo
1244 1244
 			return array( $field_id, $sub_field_id );
1245 1245
 		}
1246 1246
 
1247
-		if ( 'group' !== $fields[ $field_id ]['type'] ) {
1247
+		if ( 'group' !== $fields[ $field_id ][ 'type' ] ) {
1248 1248
 			return false;
1249 1249
 		}
1250 1250
 
1251
-		if ( ! array_key_exists( $sub_field_id, $fields[ $field_id ]['fields'] ) ) {
1252
-			$sub_field_id = $this->search_old_school_array( $sub_field_id, $fields[ $field_id ]['fields'] );
1251
+		if ( ! array_key_exists( $sub_field_id, $fields[ $field_id ][ 'fields' ] ) ) {
1252
+			$sub_field_id = $this->search_old_school_array( $sub_field_id, $fields[ $field_id ][ 'fields' ] );
1253 1253
 		}
1254 1254
 
1255 1255
 		return false === $sub_field_id ? false : array( $field_id, $sub_field_id );
Please login to merge, or discard this patch.
includes/types/CMB2_Type_Taxonomy_Radio.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 		if ( ! $terms ) {
25 25
 			$options .= sprintf( '<li><label>%s</label></li>', esc_html( $this->_text( 'no_terms_text', esc_html__( 'No terms', 'cmb2' ) ) ) );
26 26
 		} else {
27
-			$option_none  = $field->args( 'show_option_none' );
27
+			$option_none = $field->args( 'show_option_none' );
28 28
 			if ( ! empty( $option_none ) ) {
29 29
 
30 30
 				$field_id = $this->_id();
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 					'label' => $option_none,
55 55
 				);
56 56
 				if ( $saved_term == $option_none_value ) {
57
-					$args['checked'] = 'checked';
57
+					$args[ 'checked' ] = 'checked';
58 58
 				}
59 59
 				$options .= $this->list_input( $args, $i );
60 60
 				$i++;
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 				);
68 68
 
69 69
 				if ( $saved_term == $term->slug ) {
70
-					$args['checked'] = 'checked';
70
+					$args[ 'checked' ] = 'checked';
71 71
 				}
72 72
 				$options .= $this->list_input( $args, $i );
73 73
 				$i++;
Please login to merge, or discard this patch.