WordPress plugin intelligence profile

WP REST Menus

Add menus endpoints to WP REST API

WP PlugIndex snapshot

Current directory snapshot

Tested up to WordPress 5.9
Current version1.0.4
WordPress coverageTested up to WordPress 5.9
Minimum stackWP 5.0 · PHP 5.6
Directory statusactive
Last directory update17 Feb 20224y ago
Active installations90Adoption metric — not a quality score
WordPress.org rating5.0 / 5 from 4 ratings
Official packageDirect from WordPress.org

Repository metrics are context, not quality scores. Active installations measure adoption and can strongly reflect a plugin’s age and historical popularity. Ratings, recent updates and “Tested up to” metadata also do not guarantee modern code, error-free operation, security, feature completeness or suitability for a particular site. Why active installs don’t tell the whole story →

WP PlugIndex currently records WP REST Menus version 1.0.4 as active, updated 4y ago and tested up to WordPress 5.9.

Overview

About this plugin

This plugin adds new endpoints for WordPress registered menus.

Usefull when building SPAs with Vuejs, React or any front-end framework.

Works with Advacned Custom Fields, WPML, Polylang

The new endpoints available:

Get all menus

GET /menus/v1/menus

// Response sample { term_id: 2, name: "Main Menu", slug: "main-menu", term_group: 0, term_taxonomy_id: 2, taxonomy: "nav_menu", description: "", parent: 0, count: 8, filter: "raw" }, ...

Get a menus items by id (term_id)

GET /menus/v1/menus/<id>

local\/", target: "", attr_title: "", description: "", classes: [ "" ], xfn: "", meta: null }, ...

Get all menu locations

action=locations

GET /menus/v1/menus/locations is deprecated and will be removed in newer versions use: GET /menus/v1/locations

// Response example { slug: "top", description: "Top Menu" }, { slug: "social", description: "Social Links Menu" } ...

Get all menu location items

action=locations

GET /menus/v1/menus/locations/<slug> is deprecated and will be removed in newer versions use: GET /menus/v1/locations/<slug>

local\/", target: "", attr_title: "", description: "", classes: [ "" ], xfn: "", meta: null }, ...

There are two filters availiable:

Fields Filter

fields=ID,title,meta

// Response sample // Response sample { ID: 5, title: "Home", meta: null }, ...

Nested Items Filter

nested=1

// Response sample { ID: 1716, menu_item_parent: "0", object_id: "174", object: "page", title: "Level 1", meta: { vue_component: "LevelComponent", menu-item-field-01: "Field 1 value", menu-item-field-02: "Field 2 value" }, children:[ { ID: 1717, menu_item_parent: "1716", object_id: "744", object: "page", title: "Level 2b", meta: { vue_component: null } }, ... ] }, ...

WP filter hooks

This plugin is quite configurable and provides lots of wp filter hooks from returned data in responses for each endpoint to params validation and endpoint permissions.

add_filter( 'wprm/get_menus/wp_get_nav_menus/args', 'my_wp_get_nav_menus', 10, 1 ); (used in GET /menus/v1/menus)

function my_wp_get_nav_menus( $args ) { // do something with wp_get_nav_menus $args array return $args; }

add_filter( 'wprm/get_menus', 'my_get_menus', 10, 1 ); (used in GET /menus/v1/menus)

function my_get_menus( $menus ) { // do something with $menus array

return $menus; // WP_Error|WP_HTTP_Response|WP_REST_Response|mixed }

add_filter( 'wprm/get_menu_locations', 'my_get_menu_locations', 10, 1 ); (used in GET /menus/v1/locations)

function my_get_menu_locations( $locations ) { // You can modify the $locations array response (get_registered_nav_menus())

return $locations; // WP_Error|WP_HTTP_Response|WP_REST_Response|mixed }

add_filter( 'wprm/get_menu_items', 'my_get_menu_items', 10, 1 ); (used in GET /menus/v1/menus/<id>)

function my_rest_menu_item_fields( $menu ) { // You can modify the $menu items

return $menu; }

add_filter( 'wprm/get_location_menu_items', 'my_get_location_menu_items', 10, 1 ); (used in GET /menus/v1/menus/<id>)

function my_get_location_menu_items( $menu ) { // You can modify the locations $menu items

return $menu; }

add_filter( 'wprm/get_item_fields/filter_fields', 'my_filter_fields', 10, 1 ); (used to filter return field -node edges-)

fields

$fields = array( 'ID', 'title' ); return $fields; }

More filters

apply_filters('wprm/get_menus/permissions', '__return_true', $request ); apply_filters('wprm/get_menu_locations/permissions', '__return_true', $request ); apply_filters('wprm/get_menu_items/permissions', '__return_true', $request ); apply_filters('wprm/get_menu_items/validate/args/id', is_numeric( $param ), $param, $request, $key ); apply_filters('wprm/get_menu_items/validate/args/fields', is_string( $param ), $param, $request, $key ); apply_filters('wprm/get_menu_items/validate/args/nested', absint( $param ), $param, $request, $key ); apply_filters('wprm/get_location_menu_items/permissions', '__return_true', $request ); apply_filters('wprm/get_location_menu_items/validate/args/slug', is_string( $param ), $param, $request, $key ); apply_filters('wprm/get_location_menu_items/validate/args/fields', is_string( $param ), $param, $request, $key ); apply_filters('wprm/get_location_menu_items/validate/args/nested', absint( $param ), $param, $request, $key ); apply_filters('wprm/get_location_menu_items/permissions', '__return_true', $request ); apply_filters('wprm/get_location_menu_items/validate/args/slug', is_string( $param ), $param, $request, $key ); apply_filters('wprm/get_location_menu_items/validate/args/fields', is_string( $param ), $param, $request, $key ); apply_filters('wprm/get_location_menu_items/validate/args/nested', absint( $param ), $param, $request, $key );

Supports custom fields and Advanced Custom Fields

If ACF is installed the response node edge is acf else meta

In newer version these two edges will co exist and the plugin will separate natively registered custom fields ad acf registered ones.

WordPress.org metadata

Plugin tags

Topics listed for this plugin in the WordPress.org directory.

  • wp rest api
  • wp rest menus
  • v2
Compatibility & maintenance

Compatibility & maintenance

Tested up to WordPress 5.9

Not yet marked as tested with WordPress 7.1. WordPress.org currently lists Tested up to 5.9.

Current WordPress releaseWordPress 7.1
WordPress.org Tested up to5.9
Minimum requirementsWordPress 5.0 · PHP 5.6
Update activity17 Feb 20224y ago

“Tested up to” is directory metadata supplied by the plugin author. WP PlugIndex does not turn an older declaration into a claim that the plugin is incompatible.

Changes recorded by WP PlugIndex

Recent tracked changes

No tracked version or compatibility changes have been recorded by WP PlugIndex yet.

Tracking & source

WP PlugIndex tracks public WordPress.org directory metadata and records selected version, compatibility and availability changes as they are detected.

Plugin watchlist

Watch this plugin

Sign in to your WP PlugIndex account or create a free account. Free accounts can watch up to 5 plugins and see what changed.

Watch limit

Watchlist limit reached

You have reached your current active watch limit.