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:
parent
50daa191c2
commit
9447d32ef4
|
@ -655,9 +655,12 @@ function add_query_arg() {
|
||||||
else
|
else
|
||||||
$frag = '';
|
$frag = '';
|
||||||
|
|
||||||
if ( preg_match( '|^https?://|i', $uri, $matches ) ) {
|
if ( 0 === stripos( 'http://', $uri ) ) {
|
||||||
$protocol = $matches[0];
|
$protocol = 'http://';
|
||||||
$uri = substr( $uri, strlen( $protocol ) );
|
$uri = substr( $uri, 7 );
|
||||||
|
} elseif ( 0 === stripos( 'https://', $uri ) ) {
|
||||||
|
$protocol = 'https://';
|
||||||
|
$uri = substr( $uri, 8 );
|
||||||
} else {
|
} else {
|
||||||
$protocol = '';
|
$protocol = '';
|
||||||
}
|
}
|
||||||
|
@ -671,7 +674,7 @@ function add_query_arg() {
|
||||||
$base = $parts[0] . '?';
|
$base = $parts[0] . '?';
|
||||||
$query = $parts[1];
|
$query = $parts[1];
|
||||||
}
|
}
|
||||||
} elseif ( !empty( $protocol ) || strpos( $uri, '=' ) === false ) {
|
} elseif ( $protocol || strpos( $uri, '=' ) === false ) {
|
||||||
$base = $uri . '?';
|
$base = $uri . '?';
|
||||||
$query = '';
|
$query = '';
|
||||||
} else {
|
} else {
|
||||||
|
@ -688,7 +691,7 @@ function add_query_arg() {
|
||||||
$qs[ $args[0] ] = $args[1];
|
$qs[ $args[0] ] = $args[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ( (array) $qs as $k => $v ) {
|
foreach ( $qs as $k => $v ) {
|
||||||
if ( $v === false )
|
if ( $v === false )
|
||||||
unset( $qs[$k] );
|
unset( $qs[$k] );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue