rest_prepare_sidebar filter-hookWP 5.8.0

Filters the REST API response for a sidebar.

Usage

add_filter( 'rest_prepare_sidebar', 'wp_kama_rest_prepare_sidebar_filter', 10, 3 );

/**
 * Function for `rest_prepare_sidebar` filter-hook.
 * 
 * @param WP_REST_Response $response    The response object.
 * @param array            $raw_sidebar The raw sidebar data.
 * @param WP_REST_Request  $request     The request object.
 *
 * @return WP_REST_Response
 */
function wp_kama_rest_prepare_sidebar_filter( $response, $raw_sidebar, $request ){

	// filter...
	return $response;
}
$response(WP_REST_Response)
The response object.
$raw_sidebar(array)
The raw sidebar data.
$request(WP_REST_Request)
The request object.

Changelog

Since 5.8.0 Introduced.

Where the hook is called

WP_REST_Sidebars_Controller::prepare_item_for_response()
rest_prepare_sidebar
wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php 391
return apply_filters( 'rest_prepare_sidebar', $response, $raw_sidebar, $request );

Where the hook is used in WordPress

Usage not found.