钩子文档

rest_prepare_menu_location

💡 云策文档标注

概述

rest_prepare_menu_location 是一个 WordPress REST API 过滤器,用于修改菜单位置数据在 API 响应中的序列化结果。它允许开发者在数据返回给客户端前进行自定义处理。

关键要点

  • 这是一个过滤器,用于过滤 REST API 返回的菜单位置数据。
  • 接收三个参数:$response(WP_REST_Response 对象)、$location(原始位置对象)和 $request(WP_REST_Request 对象)。
  • 在 WP_REST_Menu_Locations_Controller::prepare_item_for_response() 方法中被调用,用于准备菜单位置对象的序列化。
  • 从 WordPress 5.9.0 版本开始引入。

📄 原文内容

Filters menu location data returned from the REST API.

Parameters

$responseWP_REST_Response
The response object.
$locationobject
The original location object.
$requestWP_REST_Request
Request used to generate the response.

Source

return apply_filters( 'rest_prepare_menu_location', $response, $location, $request );

Changelog

Version Description
5.9.0 Introduced.