Filters a response based on the context defined in the schema.
Parameters
$data
arrayrequired- Response data to filter.
$context
stringrequired- Context defined in the schema.
Source
public function filter_response_by_context( $data, $context ) {
$data = parent::filter_response_by_context( $data, $context );
/*
* Remove `title.rendered` and `content.rendered` from the response.
* It doesn't make sense for a pattern to have rendered content on its own,
* since rendering a block requires it to be inside a post or a page.
*/
unset( $data['title']['rendered'] );
unset( $data['content']['rendered'] );
// Add the core wp_pattern_sync_status meta as top level property to the response.
$data['wp_pattern_sync_status'] = isset( $data['meta']['wp_pattern_sync_status'] ) ? $data['meta']['wp_pattern_sync_status'] : '';
unset( $data['meta']['wp_pattern_sync_status'] );
return $data;
}
User Contributed Notes
You must log in before being able to contribute a note or feedback.