Permalink
Browse files

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
  • Loading branch information...
1 parent 61bd24d commit 78df039dfd576db239f10323e96fc5b0856301ad @danielbachhuber danielbachhuber committed Oct 25, 2012
Showing with 2 additions and 3 deletions.
  1. +2 −3 safe-redirect-manager.php
@@ -708,10 +708,9 @@ public function action_parse_request() {
}
// Allow redirects to be filtered
- if ( ! $redirects = apply_filters( 'srm_filter_redirects_before_running', $redirects, $requested_path ) )
- return;
+ $redirects = apply_filters( 'srm_registered_redirects', $redirects, $requested_path );
- foreach ( $redirects as $redirect ) {
+ foreach ( (array)$redirects as $redirect ) {
$redirect_from = untrailingslashit( $redirect['redirect_from'] );
if ( empty( $redirect_from ) )

3 comments on commit 78df039

Contributor

jtsternberg replied Oct 26, 2012

Nice! so dumb question, but type-casting the variable in the foreach loop will address the debug issue that occurs when the variable is empty?

Contributor

danielbachhuber replied Oct 26, 2012

Yep. If the variable is false, it will be typecast to an empty array.

Contributor

jtsternberg replied Oct 26, 2012

New trick for me. 👍

Please sign in to comment.