Implement a layer around dynamic rewrite rules and use them for sitemaps #10802
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.
Summary
This PR can be summarized in the following changelog entry:
Relevant technical choices:
Yoast_Dynamic_Rewrites
is introduced as a layer to handle dynamic rewrites.add_rule()
method, that has the same signature as core'sWP_Rewrite::add_rule()
(and its aliasadd_rewrite_rule()
).rewrite_rules
option, adding all dynamic rewrite rules in there.WP_Rewrite::add_rule()
. This needs to happen so that rewrite rules are also in place when they are not fetched from the option, but being regenerated "live".rewrite_rules
option, stripping those dynamic rules out of it.setup_theme
since this is the first action whereWP_Rewrite
is available.Please read the issue #10801 for more background information.
Test instructions
This PR can be tested by following these steps:
_wpseo_activate()
function inwp-seo-main.php
, temporarily comment out the if-else construct that flushes rewrite rules (starts withis_multisite() && ms_is_switched()
).sitemap_index.xml
and ensure it appears, not giving a 404.Quality assurance
Fixes #10801