rest_prepare_menu_location
Filters menu location data returned from the REST API.
Usage
add_filter( 'rest_prepare_menu_location', 'wp_kama_rest_prepare_menu_location_filter', 10, 3 );
/**
* Function for `rest_prepare_menu_location` filter-hook.
*
* @param WP_REST_Response $response The response object.
* @param object $location The original location object.
* @param WP_REST_Request $request Request used to generate the response.
*
* @return WP_REST_Response
*/
function wp_kama_rest_prepare_menu_location_filter( $response, $location, $request ){
// filter...
return $response;
}
- $response(WP_REST_Response)
- The response object.
- $location(object)
- The original location object.
- $request(WP_REST_Request)
- Request used to generate the response.
Changelog
| Since 5.9.0 | Introduced. |
Where the hook is called
rest_prepare_menu_location
wp-includes/rest-api/endpoints/class-wp-rest-menu-locations-controller.php 220
return apply_filters( 'rest_prepare_menu_location', $response, $location, $request );