@@ -186,6 +186,7 @@ discard block |
||
186 | 186 | * @param string|array $object_types Object(s) the field is being registered |
187 | 187 | * to, "post"|"term"|"comment" etc. |
188 | 188 | * @param string $object_types Canonical object type for callbacks. |
189 | + * @param string $object_type |
|
189 | 190 | * |
190 | 191 | * @return void |
191 | 192 | */ |
@@ -383,7 +384,7 @@ discard block |
||
383 | 384 | * |
384 | 385 | * @since 2.2.4 |
385 | 386 | * |
386 | - * @param mixed $value The value of the field |
|
387 | + * @param mixed $values The value of the field |
|
387 | 388 | * @param object $object The object from the response |
388 | 389 | * @param string $field_name Name of field |
389 | 390 | * @param WP_REST_Request $request Current request |
@@ -402,7 +403,7 @@ discard block |
||
402 | 403 | * |
403 | 404 | * @since 2.2.4 |
404 | 405 | * |
405 | - * @param mixed $value The value of the field |
|
406 | + * @param mixed $values The value of the field |
|
406 | 407 | * @param object $object The object from the response |
407 | 408 | * @param string $field_name Name of field |
408 | 409 | * @param WP_REST_Request $request Current request |
@@ -421,7 +422,7 @@ discard block |
||
421 | 422 | * |
422 | 423 | * @since 2.2.4 |
423 | 424 | * |
424 | - * @param mixed $value The value of the field |
|
425 | + * @param mixed $values The value of the field |
|
425 | 426 | * @param object $object The object from the response |
426 | 427 | * @param string $field_name Name of field |
427 | 428 | * @param WP_REST_Request $request Current request |
@@ -440,7 +441,7 @@ discard block |
||
440 | 441 | * |
441 | 442 | * @since 2.2.4 |
442 | 443 | * |
443 | - * @param mixed $value The value of the field |
|
444 | + * @param mixed $values The value of the field |
|
444 | 445 | * @param object $object The object from the response |
445 | 446 | * @param string $field_name Name of field |
446 | 447 | * @param WP_REST_Request $request Current request |
@@ -459,7 +460,7 @@ discard block |
||
459 | 460 | * |
460 | 461 | * @since 2.2.4 |
461 | 462 | * |
462 | - * @param mixed $value The value of the field |
|
463 | + * @param mixed $values The value of the field |
|
463 | 464 | * @param object $object The object from the response |
464 | 465 | * @param WP_REST_Request $request Current request |
465 | 466 | * @param string $object_type The request object type |
@@ -133,18 +133,18 @@ discard block |
||
133 | 133 | foreach ( self::$boxes as $cmb_id => $rest_box ) { |
134 | 134 | $types = array_flip( $rest_box->cmb->box_types() ); |
135 | 135 | |
136 | - if ( isset( $types['user'] ) ) { |
|
137 | - unset( $types['user'] ); |
|
136 | + if ( isset( $types[ 'user' ] ) ) { |
|
137 | + unset( $types[ 'user' ] ); |
|
138 | 138 | $has_user = true; |
139 | 139 | } |
140 | 140 | |
141 | - if ( isset( $types['comment'] ) ) { |
|
142 | - unset( $types['comment'] ); |
|
141 | + if ( isset( $types[ 'comment' ] ) ) { |
|
142 | + unset( $types[ 'comment' ] ); |
|
143 | 143 | $has_comment = true; |
144 | 144 | } |
145 | 145 | |
146 | - if ( isset( $types['term'] ) ) { |
|
147 | - unset( $types['term'] ); |
|
146 | + if ( isset( $types[ 'term' ] ) ) { |
|
147 | + unset( $types[ 'term' ] ); |
|
148 | 148 | |
149 | 149 | $taxonomies = array_merge( |
150 | 150 | $taxonomies, |
@@ -206,18 +206,18 @@ discard block |
||
206 | 206 | */ |
207 | 207 | protected function declare_read_edit_fields() { |
208 | 208 | foreach ( $this->cmb->prop( 'fields' ) as $field ) { |
209 | - $show_in_rest = isset( $field['show_in_rest'] ) ? $field['show_in_rest'] : null; |
|
209 | + $show_in_rest = isset( $field[ 'show_in_rest' ] ) ? $field[ 'show_in_rest' ] : null; |
|
210 | 210 | |
211 | 211 | if ( false === $show_in_rest ) { |
212 | 212 | continue; |
213 | 213 | } |
214 | 214 | |
215 | 215 | if ( $this->can_read( $show_in_rest ) ) { |
216 | - $this->read_fields[] = $field['id']; |
|
216 | + $this->read_fields[ ] = $field[ 'id' ]; |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | if ( $this->can_edit( $show_in_rest ) ) { |
220 | - $this->edit_fields[] = $field['id']; |
|
220 | + $this->edit_fields[ ] = $field[ 'id' ]; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | } |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | * @return mixed |
349 | 349 | */ |
350 | 350 | protected static function get_rest_values( $object, $request, $object_type, $main_object_type = 'post' ) { |
351 | - if ( ! isset( $object['id'] ) ) { |
|
351 | + if ( ! isset( $object[ 'id' ] ) ) { |
|
352 | 352 | return; |
353 | 353 | } |
354 | 354 | |
@@ -363,12 +363,12 @@ discard block |
||
363 | 363 | } |
364 | 364 | |
365 | 365 | foreach ( $rest_box->read_fields as $field_id ) { |
366 | - $rest_box->cmb->object_id( $object['id'] ); |
|
366 | + $rest_box->cmb->object_id( $object[ 'id' ] ); |
|
367 | 367 | $rest_box->cmb->object_type( $main_object_type ); |
368 | 368 | |
369 | 369 | $field = $rest_box->cmb->get_field( $field_id ); |
370 | 370 | |
371 | - $field->object_id( $object['id'] ); |
|
371 | + $field->object_id( $object[ 'id' ] ); |
|
372 | 372 | $field->object_type( $main_object_type ); |
373 | 373 | |
374 | 374 | $values[ $cmb_id ][ $field->id( true ) ] = $field->get_data(); |
@@ -486,8 +486,8 @@ discard block |
||
486 | 486 | continue; |
487 | 487 | } |
488 | 488 | |
489 | - $rest_box->cmb->object_id( $data['object_id'] ); |
|
490 | - $rest_box->cmb->object_type( $data['object_type'] ); |
|
489 | + $rest_box->cmb->object_id( $data[ 'object_id' ] ); |
|
490 | + $rest_box->cmb->object_type( $data[ 'object_type' ] ); |
|
491 | 491 | |
492 | 492 | // TODO: Test since refactor. |
493 | 493 | $updated[ $cmb_id ] = $rest_box->sanitize_box_values( $values ); |
@@ -595,8 +595,8 @@ discard block |
||
595 | 595 | } elseif ( isset( $object->comment_ID ) ) { |
596 | 596 | $object_id = intval( $object->comment_ID ); |
597 | 597 | $object_type = 'comment'; |
598 | - } elseif ( is_array( $object ) && isset( $object['term_id'] ) ) { |
|
599 | - $object_id = intval( $object['term_id'] ); |
|
598 | + } elseif ( is_array( $object ) && isset( $object[ 'term_id' ] ) ) { |
|
599 | + $object_id = intval( $object[ 'term_id' ] ); |
|
600 | 600 | $object_type = 'term'; |
601 | 601 | } elseif ( isset( $object->term_id ) ) { |
602 | 602 | $object_id = intval( $object->term_id ); |