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

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 ) { function _remove_qs_args_if_not_in_url( $query_string, Array $args_to_check, $url ) {
$parsed_url = @parse_url( $url ); $parsed_url = @parse_url( $url );
parse_str( $parsed_url['query'], $parsed_query ); if ( ! empty( $parsed_url['query'] ) ) {
foreach ( $args_to_check as $qv ) { parse_str( $parsed_url['query'], $parsed_query );
if ( !isset( $parsed_query[$qv] ) ) foreach ( $args_to_check as $qv ) {
$query_string = remove_query_arg( $qv, $query_string ); 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; return $query_string;
} }