- Timestamp:
- 09/19/2019 02:04:51 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php
r46069 r46184 563 563 $requested_fields[] = 'id'; 564 564 } 565 return array_intersect( $fields, $requested_fields ); 565 // Return the list of all requested fields which appear in the schema. 566 return array_reduce( 567 $requested_fields, 568 function( $response_fields, $field ) use ( $fields ) { 569 if ( in_array( $field, $fields, true ) ) { 570 $response_fields[] = $field; 571 return $response_fields; 572 } 573 // Check for nested fields if $field is not a direct match. 574 $nested_fields = explode( '.', $field ); 575 // A nested field is included so long as its top-level property is 576 // present in the schema. 577 if ( in_array( $nested_fields[0], $fields, true ) ) { 578 $response_fields[] = $field; 579 } 580 return $response_fields; 581 }, 582 array() 583 ); 566 584 } 567 585
Note: See TracChangeset
for help on using the changeset viewer.