Download the PHP package nekojira/wp-api-menus without Composer
On this page you can find all versions of the php package nekojira/wp-api-menus. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nekojira/wp-api-menus
More information about nekojira/wp-api-menus
Files in nekojira/wp-api-menus
Package wp-api-menus
Short Description Extends WordPress WP API with menu routes.
License GPLv2.0+
Homepage https://github.com/unfulvio/wp-api-menus
Informations about the package wp-api-menus
Menu routes for WordPress JSON REST API
WordPress plugin that extends the JSON REST WP API with new routes pointing to WordPress registered menus. Read the WP API documentation.
New routes available:
/menus
list of every registered menu./menus/<id>
data for a specific menu./menu-locations
list of all registered theme locations./menu-locations/<location>
data for menu in specified menu in theme location.
Currently, the menu-locations/<location>
route for individual menus will return a tree with full menu hierarchy, with correct menu item order and listing children for each menu item. The menus/<id>
route will output menu details and a flat array of menu items. Item order or if each item has a parent will be indicated in each item attributes, but this route won't output items as a tree.
You can alter the V1 data arrangement of each individual menu items and children using the filter hook json_menus_format_menu_item
.
WP API V2
In V1 of the REST API 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.
You can alter the V2 data arrangement of the REST response using the filter hooks
rest_menus_format_menus
to alter the list of menu items returned (e.g fromwp-json/wp-api-menus/v2/menus/
)rest_menus_format_menu
to alter a single menu returned (e.gwp-json/wp-api-menus/v2/menus/<id>
)rest_menus_format_menu_item
to alter the menu items returned (e.gwp-json/wp-api-menus/v2/menus/<id>
items
property)
Contributing
- Submit a pull request or open a ticket here on GitHub.