Opened 64 minutes ago
Last modified 55 minutes ago
#66657 new defect (bug)
Command Palette: Top-level menus registered without a callback lead to "Cannot load {slug}"
| Reported by: | yashjawale | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Administration | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: |
Description
wp_enqueue_command_palette_assets() builds each top-level "Go to" command URL with menu_page_url( $menu_slug ). When a plugin registers a top-level menu with a null callback (e.g. WooCommerce's woocommerce and woocommerce-marketing), no page hook exists, so admin.php?page={slug} ends in wp_die( 'Cannot load {slug}.' ) (HTTP 500).
The admin menu avoids this because _wp_menu_output() links such items to their first submenu ([4481]). The palette doesn't.
Originally reported in gutenberg repository at https://github.com/WordPress/gutenberg/issues/86646
Steps to reproduce
- Add as a mu-plugin (or activate WooCommerce):
add_action( 'admin_menu', function () { add_menu_page( 'Parent', 'Parent', 'manage_options', 'null-parent', null ); add_submenu_page( 'null-parent', 'Child', 'Child', 'manage_options', 'null-child', function () { echo 'ok'; } ); // Remove the auto-added parent submenu, as WooCommerce does. remove_submenu_page( 'null-parent', 'null-parent' ); } ); - Open the Command Palette and choose "Parent".
Expected: the "Child" screen, as the admin menu link opens.
Actual: "Cannot load null-parent."
Proposed fix
If a top-level slug has submenus but no page hook (get_plugin_page_hook( $slug, 'admin.php' )), use the first accessible submenu's URL, and skip the command if there is none. Menus with their own page are unchanged.
Attachments (2)
Change History (3)
@
56 minutes ago
This ticket was mentioned in PR #15894 on WordPress/wordpress-develop by @yashjawale.
55 minutes ago
#1
- Keywords has-patch added
Top-level menus without a page of their own, registered with a null callback, now get a Command Palette "Go to" command that links to their first accessible submenu, as the admin menu does. Before, the command pointed at admin.php?page={slug}, which fails with "Cannot load {slug}."
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Opus 5.5
Used for: Drafting changes, final edits manually tested & reviewed by me
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Screencast of behavior when selecting WooCommerce parent in command palette