diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 441a5043a8..513a5dd351 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -667,10 +667,13 @@ function add_query_arg() { } foreach($qs as $k => $v) { - if ( $v != '' ) { + if ( $v !== FALSE ) { if ( $ret != '' ) $ret .= '&'; - $ret .= "$k=$v"; + if ( empty($v) && !preg_match('|[?&]' . preg_quote($k, '|') . '=|', $query) ) + $ret .= $k; + else + $ret .= "$k=$v"; } } $ret = $protocol . $base . $ret . $frag; @@ -692,10 +695,10 @@ remove_query_arg(removekeyarray, [oldquery_or_uri]) function remove_query_arg($key, $query='') { if ( is_array($key) ) { // removing multiple keys foreach ( (array) $key as $k ) - $query = add_query_arg($k, '', $query); + $query = add_query_arg($k, FALSE, $query); return $query; } - return add_query_arg($key, '', $query); + return add_query_arg($key, FALSE, $query); } function add_magic_quotes($array) {