Add a filter to $url in init()#56
Closed
MichaelApproved wants to merge 1 commit into
Closed
Conversation
By allowing developers to filter the $url, we can customize our installation and avoid complicated regex rules. My sites never care about query variables but we always have to account for them in our redirections with complicated regex statements. By filtering the $url, we can chop off the query part of a URL and never have to deal with it in the redirection rule. I initially proposed this change and gave examples here https://wordpress.org/support/topic/making-it-easy-to-redirect-without-regex
|
+1 |
Author
|
My theme code would look something like this add_filter('redirection_url', 'redirection_url_filter_simplify_url', 10);
function redirection_url_filter_simplify_url($url) {
$simple_url = $url;
$simple_url = explode("?", $simple_url);
$simple_url = $simple_url[0];
return $simple_url;
} |
|
That would be nice, allowing |
Author
|
That's right @taeo and another bonus with this filter is that developers could strtolower the entire $url, so it'll be easy to have case insensitive matches without regex. Hope this gets merged. It'll make our life so much simpler. |
|
Waiting for this feature too. +1 |
Merged
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.
By allowing developers to filter the $url, we can customize our installation and avoid complicated regex rules. My sites never care about query variables but we always have to account for them in our redirections with complicated regex statements. By filtering the $url, we can chop off the query part of a URL and never have to deal with it in the redirection rule.
I initially proposed this change and gave examples here https://wordpress.org/support/topic/making-it-easy-to-redirect-without-regex