Make WordPress Core


Ignore:
Timestamp:
11/09/2021 06:58:59 PM (4 years ago)
Author:
TimothyBlynJacobs
Message:

REST API: Introduce Menu management endpoints.

This commit introduces the /wp/v2/menus, /wp/v2/menu-items and /wp/v2/menu-locations REST API endpoints. These endpoints are fully available to users with the edit_theme_options capability, but can be read by any user who can edit a REST API available post type.

The nav_menu taxonomy and nav_menu_item post type now map their capabilities to the edit_theme_options primitive capability. This allows developers to provide more fine-grained access control. However, if a developer is currently dynamically removing the edit_theme_options capability using map_meta_cap, they should use the user_has_cap filter instead.

The wp_update_nav_menu_item() function has been adjusted to return an error if saving the menu item post or assigning the menu item to a menu generate an error.

Lastly, a new menu item type is introduced, block, that can be used to store a Block as a menu item.

Props andraganescu, antonvlasenko, dingo_d, dlh, isabel_brison, kadamwhite, Mamaduka, NateWr, noisysocks, peterwilsoncc, ryelle, schlessera, soean, Spacedmonkey, talldanwp, TimothyBlynJacobs, tobifjellner, westonruter, wpscholar, zieladam.
Fixes #40878.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/taxonomy.php

    r52062 r52079  
    109109        'nav_menu_item',
    110110        array(
    111             'public'            => false,
    112             'hierarchical'      => false,
    113             'labels'            => array(
     111            'public'                => false,
     112            'hierarchical'          => false,
     113            'labels'                => array(
    114114                'name'          => __( 'Navigation Menus' ),
    115115                'singular_name' => __( 'Navigation Menu' ),
    116116            ),
    117             'query_var'         => false,
    118             'rewrite'           => false,
    119             'show_ui'           => false,
    120             '_builtin'          => true,
    121             'show_in_nav_menus' => false,
     117            'query_var'             => false,
     118            'rewrite'               => false,
     119            'show_ui'               => false,
     120            '_builtin'              => true,
     121            'show_in_nav_menus'     => false,
     122            'capabilities'          => array(
     123                'manage_terms' => 'edit_theme_options',
     124                'edit_terms'   => 'edit_theme_options',
     125                'delete_terms' => 'edit_theme_options',
     126                'assign_terms' => 'edit_theme_options',
     127            ),
     128            'show_in_rest'          => true,
     129            'rest_base'             => 'menus',
     130            'rest_controller_class' => 'WP_REST_Menus_Controller',
    122131        )
    123132    );
Note: See TracChangeset for help on using the changeset viewer.