k1sul1 / wp-api-menus

:abcd: Menu routes for WordPress JSON REST API.

Home Page:https://wordpress.org/plugins/wp-api-menus

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Menu routes for WordPress JSON REST API

GitHub version Scrutinizer Code Quality Join the chat at https://gitter.im/unfulvio/wp-api-menus

WordPress plugin that extends the JSON REST WP API with new routes pointing to WordPress registered menus. Read the WP API documentation.

Download from WordPress.org

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 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.

Contributing

  • Submit a pull request or open a ticket here on GitHub.

About

:abcd: Menu routes for WordPress JSON REST API.

https://wordpress.org/plugins/wp-api-menus

License:GNU General Public License v2.0


Languages

Language:PHP 88.6%Language:JavaScript 11.4%