From 4185956faba4d5d60b13af0b7626d5bd34933011 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 30 Aug 2006 01:02:45 +0000 Subject: [PATCH] Keep the frag at the end. Props mdawaffe. fixes #3078 git-svn-id: https://develop.svn.wordpress.org/trunk@4123 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/functions.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 9ba0ae173c..b9e69ca15e 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -606,6 +606,11 @@ function add_query_arg() { $uri = @func_get_arg(2); } + if ( $frag = strstr($uri, '#') ) + $uri = substr($uri, 0, -strlen($frag)); + else + $frag = ''; + if ( preg_match('|^https?://|i', $uri, $matches) ) { $protocol = $matches[0]; $uri = substr($uri, strlen($protocol)); @@ -645,7 +650,7 @@ function add_query_arg() { $ret .= "$k=$v"; } } - $ret = $protocol . $base . $ret; + $ret = $protocol . $base . $ret . $frag; if ( get_magic_quotes_gpc() ) $ret = stripslashes($ret); // parse_str() adds slashes if magicquotes is on. See: http://php.net/parse_str return trim($ret, '?');