BP_REST_Components_Endpoint::prepare_item_for_response( array $component, WP_REST_Request $request )

Prepares component data for return as an object.

Parameters Parameters


(array) (Required) The component and its values.


(WP_REST_Request) (Required) Full details about the request.

Top ↑

Return Return


Source Source

File: bp-core/classes/class-bp-rest-components-endpoint.php

	public function prepare_item_for_response( $component, $request ) {
		$context  = ! empty( $request['context'] ) ? $request['context'] : 'view';
		$data     = $this->add_additional_fields_to_object( $component, $request );
		$data     = $this->filter_response_by_context( $data, $context );
		$response = rest_ensure_response( $data );

		 * Filter a component value returned from the API.
		 * @since 5.0.0
		 * @param WP_REST_Response $response  The Response data.
		 * @param WP_REST_Request  $request   Request used to generate the response.
		 * @param array            $component The component and its values.
		return apply_filters( 'bp_rest_components_prepare_value', $response, $request, $component );

Top ↑

Changelog Changelog

Version Description
5.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.