Allow filtering of redirects #26

Merged
merged 2 commits into from Oct 25, 2012

Projects

None yet

3 participants

@jtsternberg
Contributor

lines 710-712: Adds a filter around the $redirect to allow setting up redirect conditions programmatically. Allows you to do things like only redirect if the user is not an admin.. or only redirect on Tuesdays, or if the redirect is to '/about' and the user is registered, redirect somewhere else, etc

(moved the filter out of the loop)

jtsternberg added some commits Oct 25, 2012
@jtsternberg jtsternberg safe-redirect-manager.php
- lines 712-715: Adds a filter around the $redirect to allow setting up redirect conditions programmatically. Allows you to do things like only redirect if the user is not an admin.. or only redirect on Tuesdays, or if the redirect is to '/about' and the user is registered, redirect somewhere else, etc
a40cc8f
@jtsternberg jtsternberg (fixing white space) and removing the filter from the loop to right a…
…bove the loop so it doesn't get called many times.
d649a8b
@danielbachhuber danielbachhuber merged commit 61bd24d into tlovett1:master Oct 25, 2012
@danielbachhuber danielbachhuber added a commit that referenced this pull request Oct 25, 2012
@danielbachhuber danielbachhuber A more concise name for the filter. Also, we don't need a conditional…
… check because if false or an empty array is returned the foreach loop won't execute

See #26
78df039
Contributor

Looks good. I've made a couple minor changes, updated the readme, and updated WordPress.com VIP with the current working version.

Contributor

Awesome, thanks!

  • jtsternberg

On Oct 25, 2012, at 5:30 PM, Daniel Bachhuber notifications@github.com
wrote:

Looks good. I've made a couple minor changes, updated the readme, and
updated WordPress.com VIP with the current working version.


Reply to this email directly or view it on
GitHubhttps://github.com/tlovett1/Safe-Redirect-Manager/pull/26#issuecomment-9794924.

Owner

Thanks for the push jsternberg!

Just in case you guys weren't aware, casting $redirects to array could result in the body of the loop being executed if someone adds a filter to $redirects that returns false. (array) false = array( 0 => false ). Not sure if that is the behavior you are looking for.

Contributor

Ah, I wasn't aware. Justin's first approach is probably better then

On Oct 25, 2012, at 21:46, Taylor Lovett notifications@github.com wrote:

Thanks for the push jsternberg!

Just in case you guys weren't aware, casting $redirects to array could result in the body of the loop being executed if someone adds a filter to $redirects that returns false. (array) false = array( 0 => false ). Not sure if that is the behavior you are looking for.


Reply to this email directly or view it on GitHub.

Contributor

Ah that explains why it returned a white screen for me the way I originally had my filter set up (returning false). Changed it to return and it worked fine.

Owner

The white screen was a result of the array casting + #28

I committed a fix to issue 28, but unfortunately my Git skills are low and I couldn't figure out how to attach my code to that issue.

Contributor

Thanks @tlovett1. I'll merge to shared plugins on Monday.

Just like Subversion, you can reference issues and pull requests in commits with "See #N" or similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment