Adding a filter for optional change of public redirect status codes #1985
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.
Adding support for users to change the redirect status code from a
302
to another code of their choice, likely301
.Tasks
Description
Added new filter
faustwp_public_redirect_status_code
, allowing WordPress plugins and themes to choose the HTTP status code to use when generating redirects when the enable public route redirects setting is active.Related Issue(s):
None
Testing
I added this locally and ensured that the redirects were still
302
status codes. I then added this in my theme'sfunctions.php
file to test itThen I tried calling the exact same URL which resulted in a
301
status code with no change to other headers including thex-redirect-by: WP Engine Headless plugin
headerScreenshots
none
Documentation Changes
There is nowhere in the repo docs that cover this functionality but there is the following on the live site:
https://faustjs.org/reference/faust-wordpress-plugin-filters
So I am writing here markdown that will get you close, if not all the way to an update for that page which i do not know how to edit:
faustwp_exclude_from_public_redirect
: Choose the HTTP status code to use when generating redirects when the enable public route redirects setting is active.Parameter: $status_code (int): HTTP Status code to use on redirects. Default:
302
Example Usage
Dependant PRs
none