- Timestamp:
- 10/17/2018 02:40:23 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.0/tests/phpunit/tests/rest-api/rest-test-controller.php
r38832 r43736 11 11 */ 12 12 class WP_REST_Test_Controller extends WP_REST_Controller { 13 /** 14 * Prepares the item for the REST response. 15 * 16 * @param mixed $item WordPress representation of the item. 17 * @param WP_REST_Request $request Request object. 18 * @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure. 19 */ 20 public function prepare_item_for_response( $item, $request ) { 21 $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; 22 $item = $this->add_additional_fields_to_object( $item, $request ); 23 $item = $this->filter_response_by_context( $item, $context ); 24 $response = rest_ensure_response( $item ); 25 return $response; 26 } 13 27 14 28 /** 15 * Get the Post type's schema, conforming to JSON Schema29 * Get the item's schema, conforming to JSON Schema. 16 30 * 17 31 * @return array … … 73 87 ); 74 88 75 return $ schema;89 return $this->add_additional_fields_schema( $schema ); 76 90 } 77 91
Note: See TracChangeset
for help on using the changeset viewer.