Simplify protocol stripping in add_query_arg() by avoiding a regular expression. Don't cast a known array to an array. fixes #21332.

git-svn-id: https://develop.svn.wordpress.org/trunk@21865 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2012-09-16 16:16:26 +00:00
parent 50daa191c2
commit 9447d32ef4
1 changed files with 8 additions and 5 deletions

View File

@ -655,9 +655,12 @@ function add_query_arg() {
else
$frag = '';
if ( preg_match( '|^https?://|i', $uri, $matches ) ) {
$protocol = $matches[0];
$uri = substr( $uri, strlen( $protocol ) );
if ( 0 === stripos( 'http://', $uri ) ) {
$protocol = 'http://';
$uri = substr( $uri, 7 );
} elseif ( 0 === stripos( 'https://', $uri ) ) {
$protocol = 'https://';
$uri = substr( $uri, 8 );
} else {
$protocol = '';
}
@ -671,7 +674,7 @@ function add_query_arg() {
$base = $parts[0] . '?';
$query = $parts[1];
}
} elseif ( !empty( $protocol ) || strpos( $uri, '=' ) === false ) {
} elseif ( $protocol || strpos( $uri, '=' ) === false ) {
$base = $uri . '?';
$query = '';
} else {
@ -688,7 +691,7 @@ function add_query_arg() {
$qs[ $args[0] ] = $args[1];
}
foreach ( (array) $qs as $k => $v ) {
foreach ( $qs as $k => $v ) {
if ( $v === false )
unset( $qs[$k] );
}