Skip to content

Keep URL-style menu slugs (ACF) as direct admin links - #368

Merged
AllTerrainDeveloper merged 1 commit into
trunkfrom
fix/367-acf-url-style-menu-slugs
Jul 18, 2026
Merged

Keep URL-style menu slugs (ACF) as direct admin links#368
AllTerrainDeveloper merged 1 commit into
trunkfrom
fix/367-acf-url-style-menu-slugs

Conversation

@AllTerrainDeveloper

@AllTerrainDeveloper AllTerrainDeveloper commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

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_pages was routed through the canonical menu_page_url()-style resolution instead of being linked directly.

That check over-matched. URL-style slugs registered via add_menu_page() — ACF's edit.php?post_type=acf-field-groupalso land in $_parent_pages, so the dock started building admin.php?page=edit.php%3Fpost_type%3Dacf-field-group, which core's admin.php dispatcher rejects with exactly the error in the issue screenshot:

Cannot load edit.php?post_type=acf-field-group.

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.php uses: a new helper desktop_mode_is_admin_file_slug() strips the slug's query portion and checks whether the remaining path is a real file under wp-admin/.

  • edit.php?post_type=acf-field-groupedit.php exists under wp-admin/ → stays a direct link, even though registered. (ACF restored)
  • wp-sweep/admin.php → no such file under wp-admin/ → still resolves through its parent to tools.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) and desktop_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.
  • Full suite green: 1209 tests, 3 pre-existing skips.

Docs: docs/plugin-compat-layer.md legacy file-path section updated with the refinement.

🤖 Generated with Claude Code

Open WordPress Playground Preview

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>
@AllTerrainDeveloper

Copy link
Copy Markdown
Collaborator Author

This also fixes Woo Payments URL

@AllTerrainDeveloper
AllTerrainDeveloper merged commit c3bd293 into trunk Jul 18, 2026
5 checks passed
@AllTerrainDeveloper
AllTerrainDeveloper deleted the fix/367-acf-url-style-menu-slugs branch July 18, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't access ACF in v.0.9.5

1 participant