Catch more blank query string thing cases, without resorting to crazy regex. props filosofo. fixes #8098
git-svn-id: http://svn.automattic.com/wordpress/trunk@9645 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e85e3bb203
commit
7ab338d7f8
|
@ -204,7 +204,7 @@ function redirect_canonical($requested_url=null, $do_redirect=true) {
|
|||
$redirect['query'] = preg_replace( '#((p|page_id|cat|tag)=[^&]*?)(%20| )+$#', '$1', $redirect['query'] );
|
||||
|
||||
// Clean up empty query strings
|
||||
$redirect['query'] = preg_replace( '#(^\??|&)(p|page_id|cat|tag)=?$#', '', $redirect['query'] );
|
||||
$redirect['query'] = trim(preg_replace( '#(^|&)(p|page_id|cat|tag)=?(&|$)#', '&', $redirect['query']), '&');
|
||||
|
||||
// Remove redundant leading ampersands
|
||||
$redirect['query'] = preg_replace( '#^\??&+#', '', $redirect['query'] );
|
||||
|
|
Loading…
Reference in New Issue