Leaderboards::prepare_item_for_response()publicWC 1.0

Prepare the data object for response.

Method of the class: Leaderboards{}

Hooks from the method


WP_REST_Response. $response Response data.


$Leaderboards = new Leaderboards();
$Leaderboards->prepare_item_for_response( $item, $request );
$item(object) (required)
Data object.
$request(WP_REST_Request) (required)
Request object.

Leaderboards::prepare_item_for_response() code WC 7.3.0

public function prepare_item_for_response( $item, $request ) {
	$data     = $this->add_additional_fields_to_object( $item, $request );
	$data     = $this->filter_response_by_context( $data, 'view' );
	$response = rest_ensure_response( $data );

	 * Filter the list returned from the API.
	 * @param WP_REST_Response $response The response object.
	 * @param array            $item     The original item.
	 * @param WP_REST_Request  $request  Request used to generate the response.
	return apply_filters( 'woocommerce_rest_prepare_leaderboard', $response, $item, $request );