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,10 +187,16 @@ function redirect_canonical($requested_url=null, $do_redirect=true) {
|
||||
$redirect_url .= '?' . $redirect['query'];
|
||||
}
|
||||
|
||||
if ( $redirect_url && $redirect_url != $requested_url ) {
|
||||
// var_dump($redirect_url); die();
|
||||
if ( !$redirect_url || $redirect_url == $requested_url )
|
||||
return false;
|
||||
|
||||
// Note that you can use the "redirect_canonical" filter to cancel a canonical redirect for whatever reason by returning FALSE
|
||||
$redirect_url = apply_filters('redirect_canonical', $redirect_url, $requested_url);
|
||||
if ( $do_redirect) {
|
||||
|
||||
if ( !$redirect_url || $redirect_url == $requested_url ) // yes, again -- in case the filter aborted the request
|
||||
return false;
|
||||
|
||||
if ( $do_redirect ) {
|
||||
// protect against chained redirects
|
||||
if ( !redirect_canonical($redirect_url, false) ) {
|
||||
wp_redirect($redirect_url, 301);
|
||||
@ -201,9 +207,6 @@ function redirect_canonical($requested_url=null, $do_redirect=true) {
|
||||
} else {
|
||||
return $redirect_url;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user