
內容簡介
此外掛擴充了 WordPress JSON REST API,並提供 WordPress 註冊選單的新路徑。
現在提供的新路徑如下:
/menus 所有已註冊選單的清單。
/menus/<id> 特定選單的資料。
/menu-locations 所有已註冊主題位置的清單。
/menu-locations/<location> 特定主題位置中指定選單的資料。
目前具有 menu-locations/<location> 路徑的個別選單將會返回完整的選單階層樹狀結構,並且會以正確的選單項目排序並列出每個選單項目的子項目。 menus/<id> 路徑將會輸出選單詳情及平面陣列的選單項目。每個項目的層級和排序方式都會在每個項目屬性中指示,但是此路徑不會將項目輸出為樹狀結構。
您可以使用篩選鉤子 json_menus_format_menu_item 修改每個個別選單項目及其子項目的資料佈局。
關於 WP API V2 的重要注意事項:
在 V1 中,預設路徑位於 wp-json/menus/,以此類推。
在 V2 中,預設路徑位於 wp-json/wp-api-menus/v2/(例如:wp-json/wp-api-menus/v2/menus/ 等),因為 V2 鼓勵添加前綴和版本命名空間。
外掛標籤
開發者團隊
原文外掛簡介
This plugin extends the WordPress JSON REST API with new routes for WordPress registered menus
The new routes available will be:
/menus list of every registered menu.
/menus/
/menu-locations list of all registered theme locations.
/menu-locations/
Currently, the menu-locations/
You can alter the data arrangement of each individual menu items and children using the filter hook json_menus_format_menu_item.
An important note on WP API V2:
In V1 the routes are located by default at wp-json/menus/ etc.
In V2 the routes by default are at wp-json/wp-api-menus/v2/ (e.g. wp-json/wp-api-menus/v2/menus/, etc.) since V2 encourages prefixing and version namespacing.
