Prevent a notice: don't attempt to parse the query string if it doesn't exist. Props johnjamesjacoby. Fixes #20528.

git-svn-id: http://svn.automattic.com/wordpress/trunk@20669 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
duck_ 2012-05-01 18:26:38 +00:00
parent 81861e8cf8
commit 6fd24edbec
1 changed files with 8 additions and 4 deletions

View File

@ -448,10 +448,14 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
*/
function _remove_qs_args_if_not_in_url( $query_string, Array $args_to_check, $url ) {
$parsed_url = @parse_url( $url );
parse_str( $parsed_url['query'], $parsed_query );
foreach ( $args_to_check as $qv ) {
if ( !isset( $parsed_query[$qv] ) )
$query_string = remove_query_arg( $qv, $query_string );
if ( ! empty( $parsed_url['query'] ) ) {
parse_str( $parsed_url['query'], $parsed_query );
foreach ( $args_to_check as $qv ) {
if ( !isset( $parsed_query[$qv] ) )
$query_string = remove_query_arg( $qv, $query_string );
}
} else {
$query_string = remove_query_arg( $args_to_check, $query_string );
}
return $query_string;
}