- Timestamp:
- 07/31/2019 08:20:02 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php
r45566 r45706 518 518 */ 519 519 public function get_fields_for_response( $request ) { 520 $schema = $this->get_item_schema();521 $ fields = isset( $schema['properties'] ) ? array_keys( $schema['properties'] ): array();520 $schema = $this->get_item_schema(); 521 $properties = isset( $schema['properties'] ) ? $schema['properties'] : array(); 522 522 523 523 $additional_fields = $this->get_additional_fields(); … … 526 526 // because it won't be present in $this->get_item_schema(). 527 527 if ( is_null( $field_options['schema'] ) ) { 528 $fields[] = $field_name; 529 } 530 } 528 $properties[ $field_name ] = $field_options; 529 } 530 } 531 532 // Exclude fields that specify a different context than the request context. 533 $context = $request['context']; 534 if ( $context ) { 535 foreach ( $properties as $name => $options ) { 536 if ( ! empty( $options['context'] ) && ! in_array( $context, $options['context'], true ) ) { 537 unset( $properties[ $name ] ); 538 } 539 } 540 } 541 542 $fields = array_keys( $properties ); 531 543 532 544 if ( ! isset( $request['_fields'] ) ) {
Note: See TracChangeset
for help on using the changeset viewer.