Keep URL-style menu slugs (ACF) as direct admin links - #368
Merged
Conversation
The WP-Sweep fix (#335 / GH#309) made registered plugin pages win over the direct-file test in both URL resolvers by checking $_parent_pages. But URL-style slugs registered through add_menu_page() — ACF's 'edit.php?post_type=acf-field-group' — also land in $_parent_pages, and the resolver started routing them through admin.php?page=…, which core's dispatcher rejects with "Cannot load edit.php?post_type=acf-field-group." (GH#367). Apply the same tiebreaker classic admin's menu-header.php uses: strip the slug's query portion and check whether the remaining path is a real file under wp-admin/. A real admin file stays a direct link even when registered; a registered non-file slug (WP-Sweep) still resolves through its parent. Fixes #367. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Collaborator
Author
|
This also fixes Woo Payments URL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #367.
What happened
v0.9.5's WP-Sweep fix (#335, for #309) made registered plugin pages win over the direct-file test in the menu-slug URL resolvers: any slug found in
$_parent_pageswas routed through the canonicalmenu_page_url()-style resolution instead of being linked directly.That check over-matched. URL-style slugs registered via
add_menu_page()— ACF'sedit.php?post_type=acf-field-group— also land in$_parent_pages, so the dock started buildingadmin.php?page=edit.php%3Fpost_type%3Dacf-field-group, which core'sadmin.phpdispatcher rejects with exactly the error in the issue screenshot:ACF's submenu entries (Post Types, Taxonomies, …) and the command-palette map were broken the same way. Classic mode was unaffected, which matches the report.
The fix
Mirror the tiebreaker classic admin's own
wp-admin/menu-header.phpuses: a new helperdesktop_mode_is_admin_file_slug()strips the slug's query portion and checks whether the remaining path is a real file underwp-admin/.edit.php?post_type=acf-field-group→edit.phpexists underwp-admin/→ stays a direct link, even though registered. (ACF restored)wp-sweep/admin.php→ no such file underwp-admin/→ still resolves through its parent totools.php?page=wp-sweep/admin.php. (WP-Sweep fix preserved)Applied in both resolvers touched by #335:
desktop_mode_menu_item_url()(dock / window tabs) anddesktop_mode_build_command_menu_map()(command palette).Tests
desktopModeMenuItemUrl.php: registered URL-style top-level slug stays direct; registered URL-style submenu slug stays direct; registered plugin-file slug with a query still routes through its parent (guards the WP-Sweep behavior against the new query-stripping).commandMenuMap.php: ACF-shaped top-level + submenu entries keep direct URLs.Docs:
docs/plugin-compat-layer.mdlegacy file-path section updated with the refinement.🤖 Generated with Claude Code