WordPress at Your Fingertips
function is not described


Leaderboards::prepare_item_for_response() public WC 1.0

Prepare the data object for response.

{} It's a 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.

Code of Leaderboards::prepare_item_for_response() WC 6.1.1

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 );