Completed
Pull Request — trunk (#541)
by Justin
04:53
created
example-functions.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	$cmb_demo = new_cmb2_box( array(
79 79
 		'id'              => $prefix . 'metabox',
80 80
 		'title'           => __( 'Test Metabox', 'cmb2' ),
81
-		'object_types'    => array( 'page', ), // Post type
81
+		'object_types'    => array( 'page',), // Post type
82 82
 		// 'show_on_cb'   => 'yourprefix_show_if_front_page', // function should return a bool value
83 83
 		// 'context'      => 'normal',
84 84
 		// 'priority'     => 'high',
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 		'desc'    => __( 'field description (optional)', 'cmb2' ),
323 323
 		'id'      => $prefix . 'wysiwyg',
324 324
 		'type'    => 'wysiwyg',
325
-		'options' => array( 'textarea_rows' => 5, ),
325
+		'options' => array( 'textarea_rows' => 5,),
326 326
 	) );
327 327
 
328 328
 	$cmb_demo->add_field( array(
@@ -374,11 +374,11 @@  discard block
 block discarded – undo
374 374
 	$cmb_about_page = new_cmb2_box( array(
375 375
 		'id'           => $prefix . 'metabox',
376 376
 		'title'        => __( 'About Page Metabox', 'cmb2' ),
377
-		'object_types' => array( 'page', ), // Post type
377
+		'object_types' => array( 'page',), // Post type
378 378
 		'context'      => 'normal',
379 379
 		'priority'     => 'high',
380 380
 		'show_names'   => true, // Show field names on the left
381
-		'show_on'      => array( 'id' => array( 2, ) ), // Specific post IDs to display this metabox
381
+		'show_on'      => array( 'id' => array( 2,) ), // Specific post IDs to display this metabox
382 382
 	) );
383 383
 
384 384
 	$cmb_about_page->add_field( array(
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 	$cmb_group = new_cmb2_box( array(
404 404
 		'id'           => $prefix . 'metabox',
405 405
 		'title'        => __( 'Repeating Field Group', 'cmb2' ),
406
-		'object_types' => array( 'page', ),
406
+		'object_types' => array( 'page',),
407 407
 	) );
408 408
 
409 409
 	// $group_field_id is the field id string, so in this case: $prefix . 'demo'
Please login to merge, or discard this patch.
includes/CMB2_Hookup_Base.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
 			return;
55 55
 		}
56 56
 
57
-		self::$hooks_completed[] = $key;
57
+		self::$hooks_completed[ ] = $key;
58 58
 		add_filter( $action, $hook, $priority, $accepted_args );
59 59
 	}
60 60
 
Please login to merge, or discard this patch.
includes/CMB2_hookup.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	 * @return array           Modified array of classes
258 258
 	 */
259 259
 	public function close_metabox_class( $classes ) {
260
-		$classes[] = 'closed';
260
+		$classes[ ] = 'closed';
261 261
 		return $classes;
262 262
 	}
263 263
 
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 	public function user_new_metabox( $section ) {
278 278
 		if ( $section == $this->cmb->prop( 'new_user_section' ) ) {
279 279
 			$object_id = $this->cmb->object_id();
280
-			$this->cmb->object_id( isset( $_REQUEST['user_id'] ) ? $_REQUEST['user_id'] : $object_id );
280
+			$this->cmb->object_id( isset( $_REQUEST[ 'user_id' ] ) ? $_REQUEST[ 'user_id' ] : $object_id );
281 281
 			$this->user_metabox();
282 282
 		}
283 283
 	}
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 		if ( $this->taxonomy_can_save( $taxonomy ) ) {
429 429
 
430 430
 			foreach ( $this->cmb->prop( 'fields' ) as $field ) {
431
-				$data_to_delete[ $field['id'] ] = '';
431
+				$data_to_delete[ $field[ 'id' ] ] = '';
432 432
 			}
433 433
 
434 434
 			$this->cmb->save_fields( $term_id, 'term', $data_to_delete );
Please login to merge, or discard this patch.
includes/CMB2_REST.php 2 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	/**
153 153
 	 * Handler for updating custom field data.
154 154
 	 * @since  2.2.0
155
-	 * @param  mixed    $value    The value of the field
155
+	 * @param  mixed    $values    The value of the field
156 156
 	 * @param  object   $object   The object from the response
157 157
 	 * @param  string   $field_id Name of field
158 158
 	 * @return bool|int
@@ -233,6 +233,9 @@  discard block
 block discarded – undo
233 233
 		return $protected;
234 234
 	}
235 235
 
236
+	/**
237
+	 * @param string $field_id
238
+	 */
236 239
 	public function field_can_update( $field_id ) {
237 240
 
238 241
 		$field        = $this->cmb->get_field( $field_id );
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -120,18 +120,18 @@  discard block
 block discarded – undo
120 120
 
121 121
 	protected function declare_read_write_fields() {
122 122
 		foreach ( $this->cmb->prop( 'fields' ) as $field ) {
123
-			$show_in_rest = isset( $field['show_in_rest'] ) ? $field['show_in_rest'] : null;
123
+			$show_in_rest = isset( $field[ 'show_in_rest' ] ) ? $field[ 'show_in_rest' ] : null;
124 124
 
125 125
 			if ( false === $show_in_rest ) {
126 126
 				continue;
127 127
 			}
128 128
 
129 129
 			if ( $this->can_read( $show_in_rest ) ) {
130
-				$this->read_fields[] = $field['id'];
130
+				$this->read_fields[ ] = $field[ 'id' ];
131 131
 			}
132 132
 
133 133
 			if ( $this->can_write( $show_in_rest ) ) {
134
-				$this->write_fields[] = $field['id'];
134
+				$this->write_fields[ ] = $field[ 'id' ];
135 135
 			}
136 136
 
137 137
 		}
@@ -159,14 +159,14 @@  discard block
 block discarded – undo
159 159
 	 */
160 160
 	public static function get_restable_field_values( $object, $field_id, $request ) {
161 161
 		$values = array();
162
-		if ( ! isset( $object['id'] ) ) {
162
+		if ( ! isset( $object[ 'id' ] ) ) {
163 163
 			return;
164 164
 		}
165 165
 
166 166
 		foreach ( self::$boxes as $cmb_id => $rest_box ) {
167 167
 			foreach ( $rest_box->read_fields as $field_id ) {
168 168
 				$field = $rest_box->cmb->get_field( $field_id );
169
-				$field->object_id = $object['id'];
169
+				$field->object_id = $object[ 'id' ];
170 170
 
171 171
 				// TODO: test other object types (users, comments, etc)
172 172
 				if ( isset( $object->type ) ) {
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 				continue;
206 206
 			}
207 207
 
208
-			$rest_box->cmb->object_id( $data['object_id'] );
209
-			$rest_box->cmb->object_type( $data['object_type'] );
208
+			$rest_box->cmb->object_id( $data[ 'object_id' ] );
209
+			$rest_box->cmb->object_type( $data[ 'object_type' ] );
210 210
 
211 211
 			// TODO: Test since refactor.
212 212
 			$updated[ $cmb_id ] = $rest_box->sanitize_box_values( $values );
@@ -304,8 +304,8 @@  discard block
 block discarded – undo
304 304
 		} elseif ( isset( $object->comment_ID ) ) {
305 305
 			$object_id   = intval( $object->comment_ID );
306 306
 			$object_type = 'comment';
307
-		} elseif ( is_array( $object ) && isset( $object['term_id'] ) ) {
308
-			$object_id   = intval( $object['term_id'] );
307
+		} elseif ( is_array( $object ) && isset( $object[ 'term_id' ] ) ) {
308
+			$object_id   = intval( $object[ 'term_id' ] );
309 309
 			$object_type = 'term';
310 310
 		} elseif ( isset( $object->term_id ) ) {
311 311
 			$object_id   = intval( $object->term_id );
Please login to merge, or discard this patch.
includes/CMB2_REST_Controller.php 2 patches
Doc Comments   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -94,7 +94,6 @@  discard block
 block discarded – undo
94 94
 	 *
95 95
 	 * @since 2.2.0
96 96
 	 *
97
-	 * @param  mixed $data
98 97
 	 * @return array $data
99 98
 	 */
100 99
 	public function prepare_item( $post ) {
@@ -107,7 +106,7 @@  discard block
 block discarded – undo
107 106
 	 * @since  2.2.0
108 107
 	 *
109 108
 	 * @param  mixed $cb Callable function/method.
110
-	 * @return mixed     Results of output buffer after calling function/method.
109
+	 * @return string     Results of output buffer after calling function/method.
111 110
 	 */
112 111
 	public function get_cb_results( $cb ) {
113 112
 		$args = func_get_args();
@@ -142,6 +141,9 @@  discard block
 block discarded – undo
142 141
 		return apply_filters( 'cmb2_rest_prepare', rest_ensure_response( $data ), $this->request, $this );
143 142
 	}
144 143
 
144
+	/**
145
+	 * @param string $request_type
146
+	 */
145 147
 	protected function initiate_rest_read_box( $request, $request_type ) {
146 148
 		$this->initiate_rest_box( $request, $request_type );
147 149
 
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @return array $data
129 129
 	 */
130 130
 	public function prepare_item_for_response( $data, $request = null ) {
131
-		$data = $this->filter_response_by_context( $data, $this->request['context'] );
131
+		$data = $this->filter_response_by_context( $data, $this->request[ 'context' ] );
132 132
 
133 133
 		/**
134 134
 		 * Filter the prepared CMB2 item response.
@@ -170,16 +170,16 @@  discard block
 block discarded – undo
170 170
 
171 171
 	public function initiate_request( $request, $request_type ) {
172 172
 		$this->request = $request;
173
-		$this->request['context'] = isset( $this->request['context'] ) && ! empty( $this->request['context'] )
174
-			? $this->request['context']
173
+		$this->request[ 'context' ] = isset( $this->request[ 'context' ] ) && ! empty( $this->request[ 'context' ] )
174
+			? $this->request[ 'context' ]
175 175
 			: 'view';
176 176
 
177
-		if ( isset( $_REQUEST['object_id'] ) ) {
178
-			$this->object_id = absint( $_REQUEST['object_id'] );
177
+		if ( isset( $_REQUEST[ 'object_id' ] ) ) {
178
+			$this->object_id = absint( $_REQUEST[ 'object_id' ] );
179 179
 		}
180 180
 
181
-		if ( isset( $_REQUEST['object_type'] ) ) {
182
-			$this->object_type = absint( $_REQUEST['object_type'] );
181
+		if ( isset( $_REQUEST[ 'object_type' ] ) ) {
182
+			$this->object_type = absint( $_REQUEST[ 'object_type' ] );
183 183
 		}
184 184
 
185 185
 		self::$request_type = self::$request_type ? self::$request_type : $request_type;
Please login to merge, or discard this patch.
includes/CMB2_REST_Controller_Boxes.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -100,7 +100,6 @@
 block discarded – undo
100 100
 	 *
101 101
 	 * @since 2.2.0
102 102
 	 *
103
-	 * @param CMB2 $cmb
104 103
 	 * @return array
105 104
 	 */
106 105
 	public function get_rest_box() {
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		foreach ( CMB2_REST::$boxes as $this->rest_box ) {
71 71
 			if ( $this->rest_box->rest_read ) {
72 72
 				$rest_box = $this->get_rest_box();
73
-				$boxes_data[ $this->rest_box->cmb->cmb_id ] = $this->server->response_to_data( $rest_box, isset( $_GET['_embed'] ) );
73
+				$boxes_data[ $this->rest_box->cmb->cmb_id ] = $this->server->response_to_data( $rest_box, isset( $_GET[ '_embed' ] ) );
74 74
 			}
75 75
 		}
76 76
 
@@ -110,9 +110,9 @@  discard block
 block discarded – undo
110 110
 
111 111
 		$boxes_data = $cmb->meta_box;
112 112
 
113
-		if ( isset( $_REQUEST['_rendered'] ) && '/cmb2/v1/boxes' !== CMB2_REST_Controller::get_intial_route() ) {
114
-			$boxes_data['form_open'] = $this->get_cb_results( array( $cmb, 'render_form_open' ) );
115
-			$boxes_data['form_close'] = $this->get_cb_results( array( $cmb, 'render_form_close' ) );
113
+		if ( isset( $_REQUEST[ '_rendered' ] ) && '/cmb2/v1/boxes' !== CMB2_REST_Controller::get_intial_route() ) {
114
+			$boxes_data[ 'form_open' ] = $this->get_cb_results( array( $cmb, 'render_form_open' ) );
115
+			$boxes_data[ 'form_close' ] = $this->get_cb_results( array( $cmb, 'render_form_close' ) );
116 116
 
117 117
 			global $wp_scripts, $wp_styles;
118 118
 			$before_css = $wp_styles->queue;
@@ -120,15 +120,15 @@  discard block
 block discarded – undo
120 120
 
121 121
 			CMB2_JS::enqueue();
122 122
 
123
-			$boxes_data['js_dependencies'] = array_values( array_diff( $wp_scripts->queue, $before_js ) );
124
-			$boxes_data['css_dependencies'] = array_values( array_diff( $wp_styles->queue, $before_css ) );
123
+			$boxes_data[ 'js_dependencies' ] = array_values( array_diff( $wp_scripts->queue, $before_js ) );
124
+			$boxes_data[ 'css_dependencies' ] = array_values( array_diff( $wp_styles->queue, $before_css ) );
125 125
 		}
126 126
 
127 127
 		// TODO: look into 'embed' parameter.
128 128
 		// http://demo.wp-api.org/wp-json/wp/v2/posts?_embed
129
-		unset( $boxes_data['fields'] );
129
+		unset( $boxes_data[ 'fields' ] );
130 130
 		// Handle callable properties.
131
-		unset( $boxes_data['show_on_cb'] );
131
+		unset( $boxes_data[ 'show_on_cb' ] );
132 132
 
133 133
 		$response = rest_ensure_response( $boxes_data );
134 134
 
Please login to merge, or discard this patch.
includes/CMB2_REST_Controller_Fields.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
 
68 68
 		$fields = array();
69 69
 		foreach ( $this->rest_box->cmb->prop( 'fields', array() ) as $field ) {
70
-			$field_id = $field['id'];
70
+			$field_id = $field[ 'id' ];
71 71
 			$rest_field = $this->get_rest_field( $field_id );
72 72
 
73 73
 			if ( ! is_wp_error( $rest_field ) ) {
74
-				$fields[ $field_id ] = $this->server->response_to_data( $rest_field, isset( $_GET['_embed'] ) );
74
+				$fields[ $field_id ] = $this->server->response_to_data( $rest_field, isset( $_GET[ '_embed' ] ) );
75 75
 			} else {
76 76
 				$fields[ $field_id ] = array( 'error' => $rest_field->get_error_message() );
77 77
 			}
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
 			}
166 166
 		}
167 167
 
168
-		if ( isset( $_REQUEST['_rendered'] ) ) {
169
-			$field_data['rendered'] = $rendered;
168
+		if ( isset( $_REQUEST[ '_rendered' ] ) ) {
169
+			$field_data[ 'rendered' ] = $rendered;
170 170
 		}
171 171
 
172
-		$field_data['value'] = $field->get_data();
172
+		$field_data[ 'value' ] = $field->get_data();
173 173
 
174 174
 		return $field_data;
175 175
 	}
@@ -190,14 +190,14 @@  discard block
 block discarded – undo
190 190
 		);
191 191
 
192 192
 		// TODO ?
193
-		error_log( '$this->request[context]: '. print_r( $this->request['context'], true ) );
194
-		error_log( 'CMB2_REST_Controller::get_intial_route(): '. print_r( CMB2_REST_Controller::get_intial_route(), true ) );
195
-		error_log( '$match: '. print_r( 'box_read' === CMB2_REST_Controller::get_intial_request_type(), true ) );
193
+		error_log( '$this->request[context]: ' . print_r( $this->request[ 'context' ], true ) );
194
+		error_log( 'CMB2_REST_Controller::get_intial_route(): ' . print_r( CMB2_REST_Controller::get_intial_route(), true ) );
195
+		error_log( '$match: ' . print_r( 'box_read' === CMB2_REST_Controller::get_intial_request_type(), true ) );
196 196
 
197 197
 
198 198
 		// Don't embed boxes when looking at boxes route.
199 199
 		if ( '/cmb2/v1/boxes' !== CMB2_REST_Controller::get_intial_route() ) {
200
-			$links['up']['embeddable'] = true;
200
+			$links[ 'up' ][ 'embeddable' ] = true;
201 201
 		}
202 202
 
203 203
 		return $links;
Please login to merge, or discard this patch.
includes/CMB2.php 2 patches
Doc Comments   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -409,6 +409,7 @@  discard block
 block discarded – undo
409 409
 	 * Add a hidden field to the list of hidden fields to be rendered later
410 410
 	 * @since 2.0.0
411 411
 	 * @param array  $field_args Array of field arguments to be passed to CMB2_Field
412
+	 * @param CMB2_Field $field_group
412 413
 	 */
413 414
 	public function add_hidden_field( $field_args, $field_group = null ) {
414 415
 		if ( isset( $field_args['field_args'] ) ) {
@@ -610,7 +611,7 @@  discard block
 block discarded – undo
610 611
 	/**
611 612
 	 * Save a repeatable group
612 613
 	 * @since  1.x.x
613
-	 * @param  array $field_group CMB2_Field group field object
614
+	 * @param  CMB2_Field $field_group CMB2_Field group field object
614 615
 	 * @return mixed              Return of CMB2_Field::update_data()
615 616
 	 */
616 617
 	public function save_group_field( $field_group ) {
@@ -910,7 +911,7 @@  discard block
 block discarded – undo
910 911
 	 * @param  mixed  $field_id     Field (or group field) ID
911 912
 	 * @param  mixed  $field_args   Array of field arguments
912 913
 	 * @param  mixed  $sub_field_id Sub field ID (if field_group exists)
913
-	 * @param  mixed  $field_group  If a sub-field, will be the parent group CMB2_Field object
914
+	 * @param  CMB2_Field|null  $field_group  If a sub-field, will be the parent group CMB2_Field object
914 915
 	 * @return array                Array of CMB2_Field arguments
915 916
 	 */
916 917
 	public function get_field_args( $field_id, $field_args, $sub_field_id, $field_group ) {
@@ -997,7 +998,7 @@  discard block
 block discarded – undo
997 998
 	 * @since  2.0.0
998 999
 	 * @param  array  $field           Metabox field config array
999 1000
 	 * @param  int    $position        (optional) Position of metabox. 1 for first, etc
1000
-	 * @return mixed                   Field id or false
1001
+	 * @return string                   Field id or false
1001 1002
 	 */
1002 1003
 	public function add_field( array $field, $position = 0 ) {
1003 1004
 		if ( ! is_array( $field ) || ! array_key_exists( 'id', $field ) ) {
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -119,19 +119,19 @@  discard block
 block discarded – undo
119 119
 	 */
120 120
 	public function __construct( $meta_box, $object_id = 0 ) {
121 121
 
122
-		if ( empty( $meta_box['id'] ) ) {
122
+		if ( empty( $meta_box[ 'id' ] ) ) {
123 123
 			wp_die( __( 'Metabox configuration is required to have an ID parameter', 'cmb2' ) );
124 124
 		}
125 125
 
126 126
 		$this->meta_box = wp_parse_args( $meta_box, $this->mb_defaults );
127
-		$this->meta_box['fields'] = array();
127
+		$this->meta_box[ 'fields' ] = array();
128 128
 
129 129
 		$this->object_id( $object_id );
130 130
 		$this->mb_object_type();
131
-		$this->cmb_id = $meta_box['id'];
131
+		$this->cmb_id = $meta_box[ 'id' ];
132 132
 
133
-		if ( ! empty( $meta_box['fields'] ) && is_array( $meta_box['fields'] ) ) {
134
-			$this->add_fields( $meta_box['fields'] );
133
+		if ( ! empty( $meta_box[ 'fields' ] ) && is_array( $meta_box[ 'fields' ] ) ) {
134
+			$this->add_fields( $meta_box[ 'fields' ] );
135 135
 		}
136 136
 
137 137
 		CMB2_Boxes::add( $this );
@@ -262,22 +262,22 @@  discard block
 block discarded – undo
262 262
 	 * @return mixed CMB2_Field object if successful.
263 263
 	 */
264 264
 	public function render_field( $field_args ) {
265
-		$field_args['context'] = $this->prop( 'context' );
265
+		$field_args[ 'context' ] = $this->prop( 'context' );
266 266
 
267
-		if ( 'group' == $field_args['type'] ) {
267
+		if ( 'group' == $field_args[ 'type' ] ) {
268 268
 
269
-			if ( ! isset( $field_args['show_names'] ) ) {
270
-				$field_args['show_names'] = $this->prop( 'show_names' );
269
+			if ( ! isset( $field_args[ 'show_names' ] ) ) {
270
+				$field_args[ 'show_names' ] = $this->prop( 'show_names' );
271 271
 			}
272 272
 			$field = $this->render_group( $field_args );
273 273
 
274
-		} elseif ( 'hidden' == $field_args['type'] && $this->get_field( $field_args )->should_show() ) {
274
+		} elseif ( 'hidden' == $field_args[ 'type' ] && $this->get_field( $field_args )->should_show() ) {
275 275
 			// Save rendering for after the metabox
276 276
 			$field = $this->add_hidden_field( $field_args );
277 277
 
278 278
 		} else {
279 279
 
280
-			$field_args['show_names'] = $this->prop( 'show_names' );
280
+			$field_args[ 'show_names' ] = $this->prop( 'show_names' );
281 281
 
282 282
 			// Render default fields
283 283
 			$field = $this->get_field( $field_args )->render_field();
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	 */
294 294
 	public function render_group( $args ) {
295 295
 
296
-		if ( ! isset( $args['id'], $args['fields'] ) || ! is_array( $args['fields'] ) ) {
296
+		if ( ! isset( $args[ 'id' ], $args[ 'fields' ] ) || ! is_array( $args[ 'fields' ] ) ) {
297 297
 			return;
298 298
 		}
299 299
 
@@ -375,15 +375,15 @@  discard block
 block discarded – undo
375 375
 			<div class="inside cmb-td cmb-nested cmb-field-list">';
376 376
 				// Loop and render repeatable group fields
377 377
 				foreach ( array_values( $field_group->args( 'fields' ) ) as $field_args ) {
378
-					if ( 'hidden' == $field_args['type'] ) {
378
+					if ( 'hidden' == $field_args[ 'type' ] ) {
379 379
 
380 380
 						// Save rendering for after the metabox
381 381
 						$this->add_hidden_field( $field_args, $field_group );
382 382
 
383 383
 					} else {
384 384
 
385
-						$field_args['show_names'] = $field_group->args( 'show_names' );
386
-						$field_args['context']    = $field_group->args( 'context' );
385
+						$field_args[ 'show_names' ] = $field_group->args( 'show_names' );
386
+						$field_args[ 'context' ]    = $field_group->args( 'context' );
387 387
 
388 388
 						$field = $this->get_field( $field_args, $field_group )->render_field();
389 389
 					}
@@ -411,14 +411,14 @@  discard block
 block discarded – undo
411 411
 	 * @param array  $field_args Array of field arguments to be passed to CMB2_Field
412 412
 	 */
413 413
 	public function add_hidden_field( $field_args, $field_group = null ) {
414
-		if ( isset( $field_args['field_args'] ) ) {
414
+		if ( isset( $field_args[ 'field_args' ] ) ) {
415 415
 			// For back-compatibility.
416 416
 			$field = new CMB2_Field( $field_args );
417 417
 		} else {
418 418
 			$field = $this->get_new_field( $field_args, $field_group );
419 419
 		}
420 420
 
421
-		$this->hidden_fields[] = new CMB2_Types( $field );
421
+		$this->hidden_fields[ ] = new CMB2_Types( $field );
422 422
 
423 423
 		return $field;
424 424
 	}
@@ -515,11 +515,11 @@  discard block
 block discarded – undo
515 515
 	 */
516 516
 	public function process_field( $field_args ) {
517 517
 
518
-		switch ( $field_args['type'] ) {
518
+		switch ( $field_args[ 'type' ] ) {
519 519
 
520 520
 			case 'group':
521 521
 				if ( $this->save_group( $field_args ) ) {
522
-					$this->updated[] = $field_args['id'];
522
+					$this->updated[ ] = $field_args[ 'id' ];
523 523
 				}
524 524
 
525 525
 				break;
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 				$field = $this->get_new_field( $field_args );
534 534
 
535 535
 				if ( $field->save_field_from_data( $this->data_to_save ) ) {
536
-					$this->updated[] = $field->id();
536
+					$this->updated[ ] = $field->id();
537 537
 				}
538 538
 
539 539
 				break;
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 	 * @return mixed        Return of CMB2_Field::update_data()
601 601
 	 */
602 602
 	public function save_group( $args ) {
603
-		if ( ! isset( $args['id'], $args['fields'] ) || ! is_array( $args['fields'] ) ) {
603
+		if ( ! isset( $args[ 'id' ], $args[ 'fields' ] ) || ! is_array( $args[ 'fields' ] ) ) {
604 604
 			return;
605 605
 		}
606 606
 
@@ -648,16 +648,16 @@  discard block
 block discarded – undo
648 648
 						$_new_val = array();
649 649
 						foreach ( $new_val as $group_index => $grouped_data ) {
650 650
 							// Add the supporting data to the $saved array stack
651
-							$saved[ $field_group->index ][ $grouped_data['supporting_field_id'] ][] = $grouped_data['supporting_field_value'];
651
+							$saved[ $field_group->index ][ $grouped_data[ 'supporting_field_id' ] ][ ] = $grouped_data[ 'supporting_field_value' ];
652 652
 							// Reset var to the actual value
653
-							$_new_val[ $group_index ] = $grouped_data['value'];
653
+							$_new_val[ $group_index ] = $grouped_data[ 'value' ];
654 654
 						}
655 655
 						$new_val = $_new_val;
656 656
 					} else {
657 657
 						// Add the supporting data to the $saved array stack
658
-						$saved[ $field_group->index ][ $new_val['supporting_field_id'] ] = $new_val['supporting_field_value'];
658
+						$saved[ $field_group->index ][ $new_val[ 'supporting_field_id' ] ] = $new_val[ 'supporting_field_value' ];
659 659
 						// Reset var to the actual value
660
-						$new_val = $new_val['value'];
660
+						$new_val = $new_val[ 'value' ];
661 661
 					}
662 662
 				}
663 663
 
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
 				$is_removed = ( empty( $new_val ) && ! empty( $old_val ) );
671 671
 				// Compare values and add to `$updated` array
672 672
 				if ( $is_updated || $is_removed ) {
673
-					$this->updated[] = $base_id . '::' . $field_group->index . '::' . $sub_id;
673
+					$this->updated[ ] = $base_id . '::' . $field_group->index . '::' . $sub_id;
674 674
 				}
675 675
 
676 676
 				// Add to `$saved` array
@@ -705,22 +705,22 @@  discard block
 block discarded – undo
705 705
 		// Try to get our object ID from the global space
706 706
 		switch ( $this->object_type() ) {
707 707
 			case 'user':
708
-				$object_id = isset( $_REQUEST['user_id'] ) ? $_REQUEST['user_id'] : $object_id;
709
-				$object_id = ! $object_id && 'user-new.php' != $pagenow && isset( $GLOBALS['user_ID'] ) ? $GLOBALS['user_ID'] : $object_id;
708
+				$object_id = isset( $_REQUEST[ 'user_id' ] ) ? $_REQUEST[ 'user_id' ] : $object_id;
709
+				$object_id = ! $object_id && 'user-new.php' != $pagenow && isset( $GLOBALS[ 'user_ID' ] ) ? $GLOBALS[ 'user_ID' ] : $object_id;
710 710
 				break;
711 711
 
712 712
 			case 'comment':
713
-				$object_id = isset( $_REQUEST['c'] ) ? $_REQUEST['c'] : $object_id;
714
-				$object_id = ! $object_id && isset( $GLOBALS['comments']->comment_ID ) ? $GLOBALS['comments']->comment_ID : $object_id;
713
+				$object_id = isset( $_REQUEST[ 'c' ] ) ? $_REQUEST[ 'c' ] : $object_id;
714
+				$object_id = ! $object_id && isset( $GLOBALS[ 'comments' ]->comment_ID ) ? $GLOBALS[ 'comments' ]->comment_ID : $object_id;
715 715
 				break;
716 716
 
717 717
 			case 'term':
718
-				$object_id = isset( $_REQUEST['tag_ID'] ) ? $_REQUEST['tag_ID'] : $object_id;
718
+				$object_id = isset( $_REQUEST[ 'tag_ID' ] ) ? $_REQUEST[ 'tag_ID' ] : $object_id;
719 719
 				break;
720 720
 
721 721
 			default:
722
-				$object_id = isset( $GLOBALS['post']->ID ) ? $GLOBALS['post']->ID : $object_id;
723
-				$object_id = isset( $_REQUEST['post'] ) ? $_REQUEST['post'] : $object_id;
722
+				$object_id = isset( $GLOBALS[ 'post' ]->ID ) ? $GLOBALS[ 'post' ]->ID : $object_id;
723
+				$object_id = isset( $_REQUEST[ 'post' ] ) ? $_REQUEST[ 'post' ] : $object_id;
724 724
 				break;
725 725
 		}
726 726
 
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
 	 * @return boolean True/False
797 797
 	 */
798 798
 	public function is_options_page_mb() {
799
-		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'] ) );
799
+		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' ] ) );
800 800
 	}
801 801
 
802 802
 	/**
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
 			return $field;
884 884
 		}
885 885
 
886
-		$field_id = is_string( $field ) ? $field : $field['id'];
886
+		$field_id = is_string( $field ) ? $field : $field[ 'id' ];
887 887
 
888 888
 		$parent_field_id = ! empty( $field_group ) ? $field_group->id() : '';
889 889
 		$ids = $this->get_field_ids( $field_id, $parent_field_id, true );
@@ -919,16 +919,16 @@  discard block
 block discarded – undo
919 919
 		if ( $field_group && ( $sub_field_id || 0 === $sub_field_id ) ) {
920 920
 
921 921
 			// Update the fields array w/ any modified properties inherited from the group field
922
-			$this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] = $field_args;
922
+			$this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] = $field_args;
923 923
 
924 924
 			return $this->get_default_args( $field_args, $field_group );
925 925
 		}
926 926
 
927 927
 		if ( is_array( $field_args ) ) {
928
-			$this->meta_box['fields'][ $field_id ] = array_merge( $field_args, $this->meta_box['fields'][ $field_id ] );
928
+			$this->meta_box[ 'fields' ][ $field_id ] = array_merge( $field_args, $this->meta_box[ 'fields' ][ $field_id ] );
929 929
 		}
930 930
 
931
-		return $this->get_default_args( $this->meta_box['fields'][ $field_id ] );
931
+		return $this->get_default_args( $this->meta_box[ 'fields' ][ $field_id ] );
932 932
 	}
933 933
 
934 934
 	/**
@@ -978,8 +978,8 @@  discard block
 block discarded – undo
978 978
 
979 979
 			$sub_fields = false;
980 980
 			if ( array_key_exists( 'fields', $field ) ) {
981
-				$sub_fields = $field['fields'];
982
-				unset( $field['fields'] );
981
+				$sub_fields = $field[ 'fields' ];
982
+				unset( $field[ 'fields' ] );
983 983
 			}
984 984
 
985 985
 			$field_id = $parent_field_id
@@ -1004,18 +1004,18 @@  discard block
 block discarded – undo
1004 1004
 			return false;
1005 1005
 		}
1006 1006
 
1007
-		if ( 'oembed' === $field['type'] ) {
1007
+		if ( 'oembed' === $field[ 'type' ] ) {
1008 1008
 			// Initiate oembed Ajax hooks
1009 1009
 			cmb2_ajax();
1010 1010
 		}
1011 1011
 
1012 1012
 		$this->_add_field_to_array(
1013 1013
 			$field,
1014
-			$this->meta_box['fields'],
1014
+			$this->meta_box[ 'fields' ],
1015 1015
 			$position
1016 1016
 		);
1017 1017
 
1018
-		return $field['id'];
1018
+		return $field[ 'id' ];
1019 1019
 	}
1020 1020
 
1021 1021
 	/**
@@ -1027,27 +1027,27 @@  discard block
 block discarded – undo
1027 1027
 	 * @return mixed                   Array of parent/field ids or false
1028 1028
 	 */
1029 1029
 	public function add_group_field( $parent_field_id, array $field, $position = 0 ) {
1030
-		if ( ! array_key_exists( $parent_field_id, $this->meta_box['fields'] ) ) {
1030
+		if ( ! array_key_exists( $parent_field_id, $this->meta_box[ 'fields' ] ) ) {
1031 1031
 			return false;
1032 1032
 		}
1033 1033
 
1034
-		$parent_field = $this->meta_box['fields'][ $parent_field_id ];
1034
+		$parent_field = $this->meta_box[ 'fields' ][ $parent_field_id ];
1035 1035
 
1036
-		if ( 'group' !== $parent_field['type'] ) {
1036
+		if ( 'group' !== $parent_field[ 'type' ] ) {
1037 1037
 			return false;
1038 1038
 		}
1039 1039
 
1040
-		if ( ! isset( $parent_field['fields'] ) ) {
1041
-			$this->meta_box['fields'][ $parent_field_id ]['fields'] = array();
1040
+		if ( ! isset( $parent_field[ 'fields' ] ) ) {
1041
+			$this->meta_box[ 'fields' ][ $parent_field_id ][ 'fields' ] = array();
1042 1042
 		}
1043 1043
 
1044 1044
 		$this->_add_field_to_array(
1045 1045
 			$field,
1046
-			$this->meta_box['fields'][ $parent_field_id ]['fields'],
1046
+			$this->meta_box[ 'fields' ][ $parent_field_id ][ 'fields' ],
1047 1047
 			$position
1048 1048
 		);
1049 1049
 
1050
-		return array( $parent_field_id, $field['id'] );
1050
+		return array( $parent_field_id, $field[ 'id' ] );
1051 1051
 	}
1052 1052
 
1053 1053
 	/**
@@ -1059,9 +1059,9 @@  discard block
 block discarded – undo
1059 1059
 	 */
1060 1060
 	protected function _add_field_to_array( $field, &$fields, $position = 0 ) {
1061 1061
 		if ( $position ) {
1062
-			cmb2_utils()->array_insert( $fields, array( $field['id'] => $field ), $position );
1062
+			cmb2_utils()->array_insert( $fields, array( $field[ 'id' ] => $field ), $position );
1063 1063
 		} else {
1064
-			$fields[ $field['id'] ] = $field;
1064
+			$fields[ $field[ 'id' ] ] = $field;
1065 1065
 		}
1066 1066
 	}
1067 1067
 
@@ -1084,15 +1084,15 @@  discard block
 block discarded – undo
1084 1084
 		unset( $this->fields[ implode( '', $ids ) ] );
1085 1085
 
1086 1086
 		if ( ! $sub_field_id ) {
1087
-			unset( $this->meta_box['fields'][ $field_id ] );
1087
+			unset( $this->meta_box[ 'fields' ][ $field_id ] );
1088 1088
 			return true;
1089 1089
 		}
1090 1090
 
1091
-		if ( isset( $this->fields[ $field_id ]->args['fields'][ $sub_field_id ] ) ) {
1092
-			unset( $this->fields[ $field_id ]->args['fields'][ $sub_field_id ] );
1091
+		if ( isset( $this->fields[ $field_id ]->args[ 'fields' ][ $sub_field_id ] ) ) {
1092
+			unset( $this->fields[ $field_id ]->args[ 'fields' ][ $sub_field_id ] );
1093 1093
 		}
1094
-		if ( isset( $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] ) ) {
1095
-			unset( $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] );
1094
+		if ( isset( $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] ) ) {
1095
+			unset( $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] );
1096 1096
 		}
1097 1097
 		return true;
1098 1098
 	}
@@ -1116,11 +1116,11 @@  discard block
 block discarded – undo
1116 1116
 		list( $field_id, $sub_field_id ) = $ids;
1117 1117
 
1118 1118
 		if ( ! $sub_field_id ) {
1119
-			$this->meta_box['fields'][ $field_id ][ $property ] = $value;
1119
+			$this->meta_box[ 'fields' ][ $field_id ][ $property ] = $value;
1120 1120
 			return $field_id;
1121 1121
 		}
1122 1122
 
1123
-		$this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ][ $property ] = $value;
1123
+		$this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ][ $property ] = $value;
1124 1124
 		return $field_id;
1125 1125
 	}
1126 1126
 
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
 	public function get_field_ids( $field_id, $parent_field_id = '' ) {
1135 1135
 		$sub_field_id = $parent_field_id ? $field_id : '';
1136 1136
 		$field_id     = $parent_field_id ? $parent_field_id : $field_id;
1137
-		$fields       =& $this->meta_box['fields'];
1137
+		$fields       = & $this->meta_box[ 'fields' ];
1138 1138
 
1139 1139
 		if ( ! array_key_exists( $field_id, $fields ) ) {
1140 1140
 			$field_id = $this->search_old_school_array( $field_id, $fields );
@@ -1148,12 +1148,12 @@  discard block
 block discarded – undo
1148 1148
 			return array( $field_id, $sub_field_id );
1149 1149
 		}
1150 1150
 
1151
-		if ( 'group' !== $fields[ $field_id ]['type'] ) {
1151
+		if ( 'group' !== $fields[ $field_id ][ 'type' ] ) {
1152 1152
 			return false;
1153 1153
 		}
1154 1154
 
1155
-		if ( ! array_key_exists( $sub_field_id, $fields[ $field_id ]['fields'] ) ) {
1156
-			$sub_field_id = $this->search_old_school_array( $sub_field_id, $fields[ $field_id ]['fields'] );
1155
+		if ( ! array_key_exists( $sub_field_id, $fields[ $field_id ][ 'fields' ] ) ) {
1156
+			$sub_field_id = $this->search_old_school_array( $sub_field_id, $fields[ $field_id ][ 'fields' ] );
1157 1157
 		}
1158 1158
 
1159 1159
 		return false === $sub_field_id ? false : array( $field_id, $sub_field_id );
Please login to merge, or discard this patch.
includes/CMB2_Field.php 1 patch
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -124,21 +124,21 @@  discard block
 block discarded – undo
124 124
 	 */
125 125
 	public function __construct( $args ) {
126 126
 
127
-		if ( ! empty( $args['group_field'] ) ) {
128
-			$this->group       = $args['group_field'];
127
+		if ( ! empty( $args[ 'group_field' ] ) ) {
128
+			$this->group       = $args[ 'group_field' ];
129 129
 			$this->object_id   = $this->group->object_id;
130 130
 			$this->object_type = $this->group->object_type;
131 131
 			$this->cmb_id      = $this->group->cmb_id;
132 132
 		} else {
133
-			$this->object_id   = isset( $args['object_id'] ) && '_' !== $args['object_id'] ? $args['object_id'] : 0;
134
-			$this->object_type = isset( $args['object_type'] ) ? $args['object_type'] : 'post';
133
+			$this->object_id   = isset( $args[ 'object_id' ] ) && '_' !== $args[ 'object_id' ] ? $args[ 'object_id' ] : 0;
134
+			$this->object_type = isset( $args[ 'object_type' ] ) ? $args[ 'object_type' ] : 'post';
135 135
 
136
-			if ( isset( $args['cmb_id'] ) ) {
137
-				$this->cmb_id = $args['cmb_id'];
136
+			if ( isset( $args[ 'cmb_id' ] ) ) {
137
+				$this->cmb_id = $args[ 'cmb_id' ];
138 138
 			}
139 139
 		}
140 140
 
141
-		$this->args = $this->_set_field_defaults( $args['field_args'] );
141
+		$this->args = $this->_set_field_defaults( $args[ 'field_args' ] );
142 142
 
143 143
 		if ( $this->object_id ) {
144 144
 			$this->value = $this->get_data();
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 * @return mixed             Value of field argument
154 154
 	 */
155 155
 	public function __call( $name, $arguments ) {
156
-		$key = isset( $arguments[0] ) ? $arguments[0] : false;
156
+		$key = isset( $arguments[ 0 ] ) ? $arguments[ 0 ] : false;
157 157
 		return $this->args( $name, $key );
158 158
 	}
159 159
 
@@ -224,9 +224,9 @@  discard block
 block discarded – undo
224 224
 	 */
225 225
 	public function get_data( $field_id = '', $args = array() ) {
226 226
 		if ( $field_id ) {
227
-			$args['field_id'] = $field_id;
227
+			$args[ 'field_id' ] = $field_id;
228 228
 		} else if ( $this->group ) {
229
-			$args['field_id'] = $this->group->id();
229
+			$args[ 'field_id' ] = $this->group->id();
230 230
 		}
231 231
 
232 232
 		$a = $this->data_args( $args );
@@ -267,13 +267,13 @@  discard block
 block discarded – undo
267 267
 		 *
268 268
 		 * @since 2.0.0
269 269
 		 */
270
-		$data = apply_filters( "cmb2_override_{$a['field_id']}_meta_value", $data, $this->object_id, $a, $this );
270
+		$data = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_value", $data, $this->object_id, $a, $this );
271 271
 
272 272
 		// If no override, get value normally
273 273
 		if ( 'cmb2_field_no_override_val' === $data ) {
274
-			$data = 'options-page' === $a['type']
275
-				? cmb2_options( $a['id'] )->get( $a['field_id'] )
276
-				: get_metadata( $a['type'], $a['id'], $a['field_id'], ( $a['single'] || $a['repeat'] ) );
274
+			$data = 'options-page' === $a[ 'type' ]
275
+				? cmb2_options( $a[ 'id' ] )->get( $a[ 'field_id' ] )
276
+				: get_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], ( $a[ 'single' ] || $a[ 'repeat' ] ) );
277 277
 		}
278 278
 
279 279
 		if ( $this->group ) {
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 	public function update_data( $new_value, $single = true ) {
296 296
 		$a = $this->data_args( array( 'single' => $single ) );
297 297
 
298
-		$a['value'] = $a['repeat'] ? array_values( $new_value ) : $new_value;
298
+		$a[ 'value' ] = $a[ 'repeat' ] ? array_values( $new_value ) : $new_value;
299 299
 
300 300
 		/**
301 301
 		 * Filter whether to override saving of meta value.
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 		 *
332 332
 		 * @since 2.0.0
333 333
 		 */
334
-		$override = apply_filters( "cmb2_override_{$a['field_id']}_meta_save", $override, $a, $this->args(), $this );
334
+		$override = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_save", $override, $a, $this->args(), $this );
335 335
 
336 336
 		// If override, return that
337 337
 		if ( null !== $override ) {
@@ -339,22 +339,22 @@  discard block
 block discarded – undo
339 339
 		}
340 340
 
341 341
 		// Options page handling (or temp data store)
342
-		if ( 'options-page' === $a['type'] || empty( $a['id'] ) ) {
343
-			return cmb2_options( $a['id'] )->update( $a['field_id'], $a['value'], false, $a['single'] );
342
+		if ( 'options-page' === $a[ 'type' ] || empty( $a[ 'id' ] ) ) {
343
+			return cmb2_options( $a[ 'id' ] )->update( $a[ 'field_id' ], $a[ 'value' ], false, $a[ 'single' ] );
344 344
 		}
345 345
 
346 346
 		// Add metadata if not single
347
-		if ( ! $a['single'] ) {
348
-			return add_metadata( $a['type'], $a['id'], $a['field_id'], $a['value'], false );
347
+		if ( ! $a[ 'single' ] ) {
348
+			return add_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $a[ 'value' ], false );
349 349
 		}
350 350
 
351 351
 		// Delete meta if we have an empty array
352
-		if ( is_array( $a['value'] ) && empty( $a['value'] ) ) {
353
-			return delete_metadata( $a['type'], $a['id'], $a['field_id'], $this->value );
352
+		if ( is_array( $a[ 'value' ] ) && empty( $a[ 'value' ] ) ) {
353
+			return delete_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $this->value );
354 354
 		}
355 355
 
356 356
 		// Update metadata
357
-		return update_metadata( $a['type'], $a['id'], $a['field_id'], $a['value'] );
357
+		return update_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $a[ 'value' ] );
358 358
 	}
359 359
 
360 360
 	/**
@@ -404,19 +404,19 @@  discard block
 block discarded – undo
404 404
 		 * @param array $field_args All field arguments
405 405
 		 * @param CMB2_Field object $field This field object
406 406
 		 */
407
-		$override = apply_filters( "cmb2_override_{$a['field_id']}_meta_remove", $override, $a, $this->args(), $this );
407
+		$override = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_remove", $override, $a, $this->args(), $this );
408 408
 
409 409
 		// If no override, remove as usual
410 410
 		if ( null !== $override ) {
411 411
 			return $override;
412 412
 		}
413 413
 		// Option page handling
414
-		elseif ( 'options-page' === $a['type'] || empty( $a['id'] ) ) {
415
-			return cmb2_options( $a['id'] )->remove( $a['field_id'] );
414
+		elseif ( 'options-page' === $a[ 'type' ] || empty( $a[ 'id' ] ) ) {
415
+			return cmb2_options( $a[ 'id' ] )->remove( $a[ 'field_id' ] );
416 416
 		}
417 417
 
418 418
 		// Remove metadata
419
-		return delete_metadata( $a['type'], $a['id'], $a['field_id'], $old );
419
+		return delete_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $old );
420 420
 	}
421 421
 
422 422
 	/**
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
 
889 889
 		foreach ( $conditional_classes as $class => $condition ) {
890 890
 			if ( $condition ) {
891
-				$classes[] = $class;
891
+				$classes[ ] = $class;
892 892
 			}
893 893
 		}
894 894
 
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
 		}
898 898
 
899 899
 		if ( $added_classes ) {
900
-			$classes[] = esc_attr( $added_classes );
900
+			$classes[ ] = esc_attr( $added_classes );
901 901
 		}
902 902
 
903 903
 		/**
@@ -1002,10 +1002,10 @@  discard block
 block discarded – undo
1002 1002
 			return $this->field_options;
1003 1003
 		}
1004 1004
 
1005
-		$this->field_options = (array) $this->args['options'];
1005
+		$this->field_options = (array) $this->args[ 'options' ];
1006 1006
 
1007
-		if ( is_callable( $this->args['options_cb'] ) ) {
1008
-			$options = call_user_func( $this->args['options_cb'], $this );
1007
+		if ( is_callable( $this->args[ 'options_cb' ] ) ) {
1008
+			$options = call_user_func( $this->args[ 'options_cb' ], $this );
1009 1009
 
1010 1010
 			if ( $options && is_array( $options ) ) {
1011 1011
 				$this->field_options += $options;
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
 	 */
1027 1027
 	public function add_js_dependencies( $dependencies = array() ) {
1028 1028
 		foreach ( (array) $dependencies as $dependency ) {
1029
-			$this->args['js_dependencies'][ $dependency ] = $dependency;
1029
+			$this->args[ 'js_dependencies' ][ $dependency ] = $dependency;
1030 1030
 		}
1031 1031
 
1032 1032
 		CMB2_JS::add_dependencies( $dependencies );
@@ -1040,17 +1040,17 @@  discard block
 block discarded – undo
1040 1040
 	 * @return mixed  Default field value
1041 1041
 	 */
1042 1042
 	public function get_default() {
1043
-		if ( null !== $this->args['default'] ) {
1044
-			return $this->args['default'];
1043
+		if ( null !== $this->args[ 'default' ] ) {
1044
+			return $this->args[ 'default' ];
1045 1045
 		}
1046 1046
 
1047
-		$param = is_callable( $this->args['default_cb'] ) ? 'default_cb' : 'default';
1047
+		$param = is_callable( $this->args[ 'default_cb' ] ) ? 'default_cb' : 'default';
1048 1048
 		$default = $this->get_param_callback_result( $param, false );
1049 1049
 
1050 1050
 		// Allow a filter override of the default value
1051
-		$this->args['default'] = apply_filters( 'cmb2_default_filter', $default, $this );
1051
+		$this->args[ 'default' ] = apply_filters( 'cmb2_default_filter', $default, $this );
1052 1052
 
1053
-		return $this->args['default'];
1053
+		return $this->args[ 'default' ];
1054 1054
 	}
1055 1055
 
1056 1056
 	/**
@@ -1075,70 +1075,70 @@  discard block
 block discarded – undo
1075 1075
 			'default_cb'        => '',
1076 1076
 			'select_all_button' => true,
1077 1077
 			'multiple'          => false,
1078
-			'repeatable'        => isset( $args['type'] ) && 'group' == $args['type'],
1078
+			'repeatable'        => isset( $args[ 'type' ] ) && 'group' == $args[ 'type' ],
1079 1079
 			'inline'            => false,
1080 1080
 			'on_front'          => true,
1081 1081
 			'show_names'        => true,
1082 1082
 			'date_format'       => 'm\/d\/Y',
1083 1083
 			'time_format'       => 'h:i A',
1084
-			'description'       => isset( $args['desc'] ) ? $args['desc'] : '',
1085
-			'preview_size'      => 'file' == $args['type'] ? array( 350, 350 ) : array( 50, 50 ),
1084
+			'description'       => isset( $args[ 'desc' ] ) ? $args[ 'desc' ] : '',
1085
+			'preview_size'      => 'file' == $args[ 'type' ] ? array( 350, 350 ) : array( 50, 50 ),
1086 1086
 			'render_row_cb'     => array( $this, 'render_field_callback' ),
1087
-			'label_cb'          => 'title' != $args['type'] ? array( $this, 'label' ) : '',
1087
+			'label_cb'          => 'title' != $args[ 'type' ] ? array( $this, 'label' ) : '',
1088 1088
 			'show_in_rest'      => null,
1089 1089
 			'js_dependencies'   => array(),
1090 1090
 		) );
1091 1091
 
1092 1092
 		// default param can be passed a callback as well
1093
-		if ( is_callable( $args['default'] ) ) {
1094
-			$args['default_cb'] = $args['default'];
1095
-			$args['default'] = null;
1093
+		if ( is_callable( $args[ 'default' ] ) ) {
1094
+			$args[ 'default_cb' ] = $args[ 'default' ];
1095
+			$args[ 'default' ] = null;
1096 1096
 		}
1097 1097
 
1098
-		$args['repeatable'] = $args['repeatable'] && ! $this->repeatable_exception( $args['type'] );
1099
-		$args['inline']     = $args['inline'] || false !== stripos( $args['type'], '_inline' );
1098
+		$args[ 'repeatable' ] = $args[ 'repeatable' ] && ! $this->repeatable_exception( $args[ 'type' ] );
1099
+		$args[ 'inline' ]     = $args[ 'inline' ] || false !== stripos( $args[ 'type' ], '_inline' );
1100 1100
 
1101 1101
 		// options param can be passed a callback as well
1102
-		if ( is_callable( $args['options'] ) ) {
1103
-			$args['options_cb'] = $args['options'];
1104
-			$args['options'] = array();
1102
+		if ( is_callable( $args[ 'options' ] ) ) {
1103
+			$args[ 'options_cb' ] = $args[ 'options' ];
1104
+			$args[ 'options' ] = array();
1105 1105
 		}
1106 1106
 
1107
-		$args['options']    = 'group' == $args['type'] ? wp_parse_args( $args['options'], array(
1107
+		$args[ 'options' ] = 'group' == $args[ 'type' ] ? wp_parse_args( $args[ 'options' ], array(
1108 1108
 			'add_button'    => __( 'Add Group', 'cmb2' ),
1109 1109
 			'remove_button' => __( 'Remove Group', 'cmb2' ),
1110
-		) ) : $args['options'];
1110
+		) ) : $args[ 'options' ];
1111 1111
 
1112
-		$args['_id']        = $args['id'];
1113
-		$args['_name']      = $args['id'];
1112
+		$args[ '_id' ]        = $args[ 'id' ];
1113
+		$args[ '_name' ]      = $args[ 'id' ];
1114 1114
 
1115 1115
 		if ( $this->group ) {
1116 1116
 
1117
-			$args['id']    = $this->group->args( 'id' ) . '_' . $this->group->index . '_' . $args['id'];
1118
-			$args['_name'] = $this->group->args( 'id' ) . '[' . $this->group->index . '][' . $args['_name'] . ']';
1117
+			$args[ 'id' ]    = $this->group->args( 'id' ) . '_' . $this->group->index . '_' . $args[ 'id' ];
1118
+			$args[ '_name' ] = $this->group->args( 'id' ) . '[' . $this->group->index . '][' . $args[ '_name' ] . ']';
1119 1119
 		}
1120 1120
 
1121
-		if ( 'wysiwyg' == $args['type'] ) {
1122
-			$args['id'] = strtolower( str_ireplace( '-', '_', $args['id'] ) );
1123
-			$args['options']['textarea_name'] = $args['_name'];
1121
+		if ( 'wysiwyg' == $args[ 'type' ] ) {
1122
+			$args[ 'id' ] = strtolower( str_ireplace( '-', '_', $args[ 'id' ] ) );
1123
+			$args[ 'options' ][ 'textarea_name' ] = $args[ '_name' ];
1124 1124
 		}
1125 1125
 
1126 1126
 		$option_types = apply_filters( 'cmb2_all_or_nothing_types', array( 'select', 'radio', 'radio_inline', 'taxonomy_select', 'taxonomy_radio', 'taxonomy_radio_inline' ), $this );
1127 1127
 
1128
-		if ( in_array( $args['type'], $option_types, true ) ) {
1128
+		if ( in_array( $args[ 'type' ], $option_types, true ) ) {
1129 1129
 
1130
-			$args['show_option_none'] = isset( $args['show_option_none'] ) ? $args['show_option_none'] : null;
1131
-			$args['show_option_none'] = true === $args['show_option_none'] ? __( 'None', 'cmb2' ) : $args['show_option_none'];
1130
+			$args[ 'show_option_none' ] = isset( $args[ 'show_option_none' ] ) ? $args[ 'show_option_none' ] : null;
1131
+			$args[ 'show_option_none' ] = true === $args[ 'show_option_none' ] ? __( 'None', 'cmb2' ) : $args[ 'show_option_none' ];
1132 1132
 
1133
-			if ( null === $args['show_option_none'] ) {
1134
-				$off_by_default = in_array( $args['type'], array( 'select', 'radio', 'radio_inline' ), true );
1135
-				$args['show_option_none'] = $off_by_default ? false : __( 'None', 'cmb2' );
1133
+			if ( null === $args[ 'show_option_none' ] ) {
1134
+				$off_by_default = in_array( $args[ 'type' ], array( 'select', 'radio', 'radio_inline' ), true );
1135
+				$args[ 'show_option_none' ] = $off_by_default ? false : __( 'None', 'cmb2' );
1136 1136
 			}
1137 1137
 
1138 1138
 		}
1139 1139
 
1140
-		$args['has_supporting_data'] = in_array(
1141
-			$args['type'],
1140
+		$args[ 'has_supporting_data' ] = in_array(
1141
+			$args[ 'type' ],
1142 1142
 			array(
1143 1143
 				// CMB2_Sanitize::_save_file_id_value()/CMB2_Sanitize::_get_group_file_value_array()
1144 1144
 				'file',
@@ -1170,10 +1170,10 @@  discard block
 block discarded – undo
1170 1170
 			'cmb_id'      => $this->cmb_id,
1171 1171
 		);
1172 1172
 
1173
-		if ( isset( $field_args['field_args'] ) ) {
1173
+		if ( isset( $field_args[ 'field_args' ] ) ) {
1174 1174
 			$args = wp_parse_args( $field_args, $args );
1175 1175
 		} else {
1176
-			$args['field_args'] = wp_parse_args( $field_args, $this->args );
1176
+			$args[ 'field_args' ] = wp_parse_args( $field_args, $this->args );
1177 1177
 		}
1178 1178
 
1179 1179
 		return new CMB2_Field( $args );
Please login to merge, or discard this patch.