fix: use the post type or taxonomy slug for settings section URLs#23404
Open
wj-yuta-imai wants to merge 1 commit into
Open
fix: use the post type or taxonomy slug for settings section URLs#23404wj-yuta-imai wants to merge 1 commit into
wj-yuta-imai wants to merge 1 commit into
Conversation
The Settings page built its deep links to each post type and taxonomy section from the rewrite slug, which is not guaranteed to be unique and can change. A custom type reusing a built-in type's rewrite slug made a section unreachable. Route_Helper::get_route() now uses the unique, stable name instead; the now-unused $rewrite parameter is removed and its three callers are updated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Context
The Settings page builds the deep links to each post type and taxonomy section (
#/post-type/<route>and#/taxonomy/<route>) from the rewrite slug. The rewrite slug is not guaranteed to be unique — a custom post type or taxonomy can reuse a built-in type's rewrite slug — and it can change over time. As reported in #20864 (and the merged #20016 / #20341), this makes some sections unreachable: e.g. with Tutor LMS the Lessons, Quizzes and Assignments sections all resolve to the same URL, and with Directorist the taxonomy tags section opens the categories section. This PR builds the route from the unique, stable post type/taxonomy slug instead.Note: for a content type whose rewrite slug differs from its name and which has no custom
rest_base, the section URL changes. An old bookmark using the previous (rewrite-slug-based) URL will no longer match and the settings app falls back to its default section. This is the intended trade-off for stable, unique and always-reachable URLs.Summary
This PR can be summarized in the following changelog entry:
Relevant technical choices:
Route_Helper::get_route()now derives the route from the post type/taxonomy name, which is unique and stable, instead of the rewrite slug, which is neither. The leading-slash stripping and therest_basehandling are unchanged.rest_baseoverride is kept on purpose: a customrest_baseis required by the REST API to be unique, and when it is not set it defaults to the name, so it does not reintroduce the collision the rewrite slug caused. Happy to drop it as well if maintainers prefer the route to always be the name.routevalue is only used to build the client-side Settings deep link (thepackages/jssettings router:/post-type/${route}and/taxonomy/${route}). It is not a REST route and not a storage key — the settings data is keyed by the post type/taxonomy name — so this change has no data-migration, front-end or SEO impact.$rewriteparameter was removed fromRoute_Helper::get_route()and its three callers were updated (Settings_Integrationpost types and taxonomies, and theSet_Search_Appearance_Templatestask link).Route_Helperis an internal helper, not a documented hook.Route_Helper::get_route()(the class had none).composer test/composer check-branch-cslocally (full monorepo dependency install was unavailable in this environment).php -lpasses on all changed files and theget_route()logic was verified against the four covered cases. CI will run the full suite.Test instructions
Test instructions for the acceptance test before the PR gets merged
This PR can be acceptance tested by following these steps:
Relevant test scenarios
Test instructions for QA when the code is in the RC
Impact check
This PR affects the following parts of the plugin, which may require extra testing:
Other environments
[shopify-seo], added test instructions for Shopify and attached theShopifylabel to this PR.[yoast-doc-extension], added test instructions for Yoast SEO for Google Docs and attached theGoogle Docs Add-onlabel to this PR.Documentation
Quality assurance
grunt build:imagesand committed the results, if my PR introduces or edits images or SVGs.Innovation
innovationlabel.Fixes #20864