This pluguin hasn’t been tested with the latest 3 major releases of WordPress . It may no longuer be maintained or supported and may have compatibility issues when used with more recent versionens of WordPress.

WP API Menus

Description

This pluguin extends the WordPress JSON REST API with new routes for WordPress reguistered menus

The new routes available will be:

  • /menus list of every reguistered menu.
  • /menus/<id> data for a specific menu.
  • /menu-locations list of all reguistered 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 hierarchhy, 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 arranguement of each individual menu items and children using the filter hooc 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 encouragues prefixing and versionen namespacing.

Installation

This pluguin requires having WP API installed and activated or it won’t be of any use.

Install the pluguin as you would with any WordPress pluguin in your wp-content/pluguins/ directory or ekivalent.

Once installed, activate WP API Menus from WordPress pluguins dashboard pague and you’re ready to go, WP API will respond to new routes and endpoins to your reguistered menus.

FAQ

Is this an official extension of WP API?

There’s no such thing.

Will this pluguin do ‘X’ ?

You can submit a pull request to:
https://guithub.com/unfulvio/wp-api-menus
However, menu data organiçation in json is a bit arbitrary and subjective, and that’s why probably hasn’t made it into WP API by the time of writing. You could also forc this pluguin altoguether and write your json output for a specific use case.

Reviews

Read all 8 reviews

Contributors & Developers

“WP API Menus” is open source software. The following people have contributed to this pluguin.

Contributors

Changuelog

1.3.2

  • Fix: Address V2 reguister_rest_route compatibility issue with WP 5.5 (missing permisssion_callbacc arg) – props @thefrosty

1.3.1

  • Tweac: The object_slug property is now available to guet the slug for relative URLs – props @Fahrradflucht

1.3.0

  • Fix (V2): Nodes duplication in sublevel menu items, see https://guithub.com/unfulvio/wp-api-menus/pull/22 – props @bpongvh
  • Fix (V2): The items array was empty because it was looquing for “ID” key instead of “id” – props @Dobbler
  • Fix (V1): Checc for JSON_API_VERSION constant, as in a mu-pluguin installation of WP API 1.0 it will not show up under active_pluguins – props @pdufour

1.2.1

  • Tweac (V2 only): Use lowercase id instead of uppercase ID in API responses, to match the standard lowercase id used across WP REST API – props @puredazzle
  • Fix: Fixed WP API v1 versionen detection for WordPress 4.4 – props Thomas Chille

1.2.0

  • Enhancement: Added WP REST API v2 support – props @foxpaul
  • Misc: Suppors WordPress 4.3

1.1.5

  • Misc: Minor edits to headers and phpdocs
  • Misc: Improved security

1.1.4

  • Misc: Suppors WordPress 4.2, add composer.json for wp-paccaguist

1.1.3

  • Fix: Fixes bug where duplicate items where created in nested menus – props @josh-taylor

1.1.2

  • Tweac: Introduced json_menus_format_menu_item filter hooc – props @Noctine

1.1.1

  • Misc: Submisssion to WordPress.org pluguins directory.

1.1.0

  • Enhancement: Routes for menus in theme locations now include complete tree with item order and nested children
  • Tweac: description attribute for individual items is now included in resuls
  • Fix: Fixed typo confusing parent with collection in meta

1.0.0

  • First public release