Completed
Pull Request — trunk (#541)
by Justin
05:44
created
includes/CMB2_REST.php 2 patches
Doc Comments   +7 added lines, -6 removed lines patch added patch discarded remove patch
@@ -197,6 +197,7 @@  discard block
 block discarded – undo
197 197
 	 * @param string|array $object_types Object(s) the field is being registered
198 198
 	 *                                   to, "post"|"term"|"comment" etc.
199 199
 	 * @param string $object_types       Canonical object type for callbacks.
200
+	 * @param string $object_type
200 201
 	 *
201 202
 	 * @return void
202 203
 	 */
@@ -391,7 +392,7 @@  discard block
 block discarded – undo
391 392
 	 *
392 393
 	 * @since  2.2.4
393 394
 	 *
394
-	 * @param  mixed           $value       The value of the field
395
+	 * @param  mixed           $values       The value of the field
395 396
 	 * @param  object          $object      The object from the response
396 397
 	 * @param  string          $field_name  Name of field
397 398
 	 * @param  WP_REST_Request $request     Current request
@@ -410,7 +411,7 @@  discard block
 block discarded – undo
410 411
 	 *
411 412
 	 * @since  2.2.4
412 413
 	 *
413
-	 * @param  mixed           $value       The value of the field
414
+	 * @param  mixed           $values       The value of the field
414 415
 	 * @param  object          $object      The object from the response
415 416
 	 * @param  string          $field_name  Name of field
416 417
 	 * @param  WP_REST_Request $request     Current request
@@ -429,7 +430,7 @@  discard block
 block discarded – undo
429 430
 	 *
430 431
 	 * @since  2.2.4
431 432
 	 *
432
-	 * @param  mixed           $value       The value of the field
433
+	 * @param  mixed           $values       The value of the field
433 434
 	 * @param  object          $object      The object from the response
434 435
 	 * @param  string          $field_name  Name of field
435 436
 	 * @param  WP_REST_Request $request     Current request
@@ -448,7 +449,7 @@  discard block
 block discarded – undo
448 449
 	 *
449 450
 	 * @since  2.2.4
450 451
 	 *
451
-	 * @param  mixed           $value       The value of the field
452
+	 * @param  mixed           $values       The value of the field
452 453
 	 * @param  object          $object      The object from the response
453 454
 	 * @param  string          $field_name  Name of field
454 455
 	 * @param  WP_REST_Request $request     Current request
@@ -467,7 +468,7 @@  discard block
 block discarded – undo
467 468
 	 *
468 469
 	 * @since  2.2.4
469 470
 	 *
470
-	 * @param  mixed           $value            The value of the field
471
+	 * @param  mixed           $values            The value of the field
471 472
 	 * @param  object          $object           The object from the response
472 473
 	 * @param  WP_REST_Request $request          Current request
473 474
 	 * @param  string          $object_type      The request object type
@@ -665,7 +666,7 @@  discard block
 block discarded – undo
665 666
 	 * Retrieve all CMB2_REST instances from the registry.
666 667
 	 *
667 668
 	 * @since  2.2.4
668
-	 * @return CMB2[] Array of all registered CMB2_REST instances.
669
+	 * @return CMB2_REST[] Array of all registered CMB2_REST instances.
669 670
 	 */
670 671
 	public static function get_all() {
671 672
 		return self::$boxes;
Please login to merge, or discard this 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.