mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
Allow redirect_canonical filter to cancel a redirect (just return FALSE). see #5766
git-svn-id: http://svn.automattic.com/wordpress/trunk@6743 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5b22db23d1
commit
302ac4890e
@ -187,22 +187,25 @@ function redirect_canonical($requested_url=null, $do_redirect=true) {
|
|||||||
$redirect_url .= '?' . $redirect['query'];
|
$redirect_url .= '?' . $redirect['query'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $redirect_url && $redirect_url != $requested_url ) {
|
if ( !$redirect_url || $redirect_url == $requested_url )
|
||||||
// var_dump($redirect_url); die();
|
return false;
|
||||||
$redirect_url = apply_filters('redirect_canonical', $redirect_url, $requested_url);
|
|
||||||
if ( $do_redirect) {
|
// Note that you can use the "redirect_canonical" filter to cancel a canonical redirect for whatever reason by returning FALSE
|
||||||
// protect against chained redirects
|
$redirect_url = apply_filters('redirect_canonical', $redirect_url, $requested_url);
|
||||||
if ( !redirect_canonical($redirect_url, false) ) {
|
|
||||||
wp_redirect($redirect_url, 301);
|
if ( !$redirect_url || $redirect_url == $requested_url ) // yes, again -- in case the filter aborted the request
|
||||||
exit();
|
return false;
|
||||||
} else {
|
|
||||||
return false;
|
if ( $do_redirect ) {
|
||||||
}
|
// protect against chained redirects
|
||||||
|
if ( !redirect_canonical($redirect_url, false) ) {
|
||||||
|
wp_redirect($redirect_url, 301);
|
||||||
|
exit();
|
||||||
} else {
|
} else {
|
||||||
return $redirect_url;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return $redirect_url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user