You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Feature] ExtensibilityThe ability to extend blocks or the editing experience[Type] Tracking IssueTactical breakdown of efforts across the codebase and/or tied to Overview issues.
As part of progressing the block-based navigation screen, we should look at the third-party extensibility that is currently available in customizer menu screens and decide what should/could be replicated in the block-based screen.
I chatted with the author of this Nav Menu Roles plugin (@helgatheviking) to start to explore what might be desired for third party extensibility. She mentioned that generally being able to add and save custom fields will be a big help.
I looked at three files implementing the current Menus screen in WP Admin:
wp-admin/nav-menus.php
wp-includes/nav-menu.php
wp-admin/includes/nav-menu.php
I found, as expected a list of checks, filters and actions. Then I ran through the menus endpoint to check which of them are already fired by the REST API and so are already supported, and which depend on server side rendering. They're marked with:
🟩 if the REST API calls or the editor's code in "lib" already fire these filters and actions when building the responses or results
🟥 if these filters and actions depend on things we don't do anymore in the new editor
🟧 if these filters and actions can be supported and are not
⬜ if these filters and actions are not relevant for the Navigation editor (searched how the functions that fire them are used)
Theme supports and permissions
🟧 both supports menus and supports widgets are required
🟧 user needs edit_theme_options permission
As far as I could find these are all the checks for being allowed to do things on that screen.
//wp-admin/nav-menus.php/*Filters the number of locations listed per menu in the drop-down select.*/$locations_listed_per_menu = absint( apply_filters( 'wp_nav_locations_listed_per_menu', 3 ) );
//has_nav_menu/** * Filters whether a nav menu is assigned to the specified location. * * @since 4.3.0 * * @param bool $has_nav_menu Whether there is a menu assigned to a location. * @param string $location Menu location. */returnapply_filters( 'has_nav_menu', $has_nav_menu, $location );
//wp_get_nav_menu_name/** * Filters the navigation menu name being returned. * * @since 4.9.0 * * @param string $menu_name Menu name. * @param string $location Menu location identifier. */returnapply_filters( 'wp_get_nav_menu_name', $menu_name, $location );
//wp_get_nav_menus/** * Filters the navigation menu objects being returned. * * @since 3.0.0 * * @see get_terms() * * @param WP_Term[] $menus An array of menu objects. * @param array $args An array of arguments used to retrieve menu objects. */returnapply_filters( 'wp_get_nav_menus', get_terms( $args ), $args );
//wp_get_nav_menu_items/** * Filters the navigation menu items being returned. * * @since 3.0.0 * * @param array $items An array of menu item post objects. * @param object $menu The menu object. * @param array $args An array of arguments used to retrieve menu item objects. */returnapply_filters( 'wp_get_nav_menu_items', $items, $menu, $args );
wp_get_nav_menu_object
/** * Filters the nav_menu term retrieved for wp_get_nav_menu_object(). * * @since 4.3.0 * * @param WP_Term|false $menu_obj Term from nav_menu taxonomy, or false if nothing had been found. * @param int|string|WP_Term $menu The menu ID, slug, name, or object passed to wp_get_nav_menu_object(). */returnapply_filters( 'wp_get_nav_menu_object', $menu_obj, $menu );
Based on the audit above we need to figure out what to do about the red items and open issues about adding support for the orange ones 😸
Most of the red items are things that depended on the markup generation done server side for the Menus screen, which now gets replaced with a client side react app, so some of these filters cannot be identically supported, eventually replaced with similar extensibility.
The most glaring one is the use of a Walker to render the nested structure of the menu in admin which I can't see how it can be supported in our current Navigation editor.
[Feature] ExtensibilityThe ability to extend blocks or the editing experience[Type] Tracking IssueTactical breakdown of efforts across the codebase and/or tied to Overview issues.
Activity
annezazu commentedon Jul 29, 2020
I chatted with the author of this Nav Menu Roles plugin (@helgatheviking) to start to explore what might be desired for third party extensibility. She mentioned that generally being able to add and save custom fields will be a big help.
draganescu commentedon Aug 20, 2020
Audit Navigation Screen third-party extensibility
I looked at three files implementing the current Menus screen in WP Admin:
wp-admin/nav-menus.phpwp-includes/nav-menu.phpwp-admin/includes/nav-menu.phpI found, as expected a list of checks, filters and actions. Then I ran through the menus endpoint to check which of them are already fired by the REST API and so are already supported, and which depend on server side rendering. They're marked with:
Theme supports and permissions
As far as I could find these are all the checks for being allowed to do things on that screen.
Filters
Actions
Here are the items listed above with code context
Theme supports and permissions
Before we render anything on the current Menus screen in WP Admin we check for:
Filters
Here is a list of filters I found in these files:
Actions
Here is a list of actions I found in these files:
draganescu commentedon Aug 20, 2020
Based on the audit above we need to figure out what to do about the red items and open issues about adding support for the orange ones 😸
Most of the red items are things that depended on the markup generation done server side for the Menus screen, which now gets replaced with a client side react app, so some of these filters cannot be identically supported, eventually replaced with similar extensibility.
The most glaring one is the use of a Walker to render the nested structure of the menu in admin which I can't see how it can be supported in our current Navigation editor.