Need help with wp-api-menus?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

unfulvio
139 Stars 59 Forks GNU General Public License v2.0 77 Commits 26 Opened issues

Description

:abcd: Menu routes for WordPress JSON REST API.

Services available

!
?

Need anything else?

Contributors list

# 113,142
PHP
HTML
ecommer...
WordPre...
24 commits
# 459,396
PHP
CSS
WordPre...
wordpre...
2 commits
# 403,229
Shell
WordPre...
Markdow...
HTML
1 commit
# 661,701
JavaScr...
PHP
WordPre...
1 commit
# 226,338
PHP
WordPre...
CSS
Compose...
1 commit
# 251,730
task-ma...
Shell
wordpre...
WordPre...
1 commit
# 558,694
JavaScr...
PHP
WordPre...
Laravel
1 commit
# 3,157
imagema...
sass-fr...
splash
pipelin...
1 commit
# 50,920
Electro...
elixir-...
elixir-...
editor-...
1 commit
# 665,320
JavaScr...
PHP
WordPre...
1 commit

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/
    data for a specific menu.
  • /menu-locations
    list of all registered theme locations.
  • /menu-locations/
    data for menu in specified menu in theme location.

Currently, the

menu-locations/
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/
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 1.

rest_menus_format_menus
to alter the list of menu items returned (e.g from
wp-json/wp-api-menus/v2/menus/
) 2.
rest_menus_format_menu
to alter a single menu returned (e.g
wp-json/wp-api-menus/v2/menus/
) 3.
rest_menus_format_menu_item
to alter the menu items returned (e.g
wp-json/wp-api-menus/v2/menus/
items
property)

Contributing

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

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.