WP_REST_Controller::filter_response_by_context()publicWP 4.7.0

Filters a response based on the context defined in the schema.

Method of the class: WP_REST_Controller{}

No Hooks.

Return

Array. Filtered response.

Usage

$WP_REST_Controller = new WP_REST_Controller();
$WP_REST_Controller->filter_response_by_context( $response_data, $context );
$response_data(array) (required)
Response data to filter.
$context(string) (required)
Context defined in the schema.

Changelog

Since 4.7.0 Introduced.

WP_REST_Controller::filter_response_by_context() code WP 6.6.1

public function filter_response_by_context( $response_data, $context ) {

	$schema = $this->get_item_schema();

	return rest_filter_response_by_context( $response_data, $schema, $context );
}