rest_prepare_nav_menu_item
Filters the menu item data for a REST API response.
Usage
add_filter( 'rest_prepare_nav_menu_item', 'wp_kama_rest_prepare_nav_menu_item_filter', 10, 3 ); /** * Function for `rest_prepare_nav_menu_item` filter-hook. * * @param WP_REST_Response $response The response object. * @param object $menu_item Menu item setup by {@see wp_setup_nav_menu_item()}. * @param WP_REST_Request $request Request object. * * @return WP_REST_Response */ function wp_kama_rest_prepare_nav_menu_item_filter( $response, $menu_item, $request ){ // filter... return $response; }
- $response(WP_REST_Response)
- The response object.
- $menu_item(object)
- Menu item setup by {@see wp_setup_nav_menu_item()}.
- $request(WP_REST_Request)
- Request object.
Changelog
Since 5.9.0 | Introduced. |
Where the hook is called
rest_prepare_nav_menu_item
wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php 637
return apply_filters( 'rest_prepare_nav_menu_item', $response, $menu_item, $request );