Make WordPress Core


Ignore:
Timestamp:
06/08/2006 06:36:05 PM (19 years ago)
Author:
ryan
Message:

User management improvements from Mark Jaquith and David House. #2793

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.php

    r3855 r3857  
    810810    $ret = '';
    811811    if ( is_array(func_get_arg(0)) ) {
    812         if ( @func_num_args() < 2 )
     812        if ( @func_num_args() < 2 || '' == @func_get_arg(1) )
    813813            $uri = $_SERVER['REQUEST_URI'];
    814814        else
    815815            $uri = @func_get_arg(1);
    816816    } else {
    817         if ( @func_num_args() < 3 )
     817        if ( @func_num_args() < 3 || '' == @func_get_arg(2) )
    818818            $uri = $_SERVER['REQUEST_URI'];
    819819        else
    820820            $uri = @func_get_arg(2);
     821    }
     822
     823    if ( preg_match('|^https?://|i', $uri, $matches) ) {
     824        $protocol = $matches[0];
     825        $uri = substr($uri, strlen($protocol));
     826    } else {
     827        $protocol = '';
    821828    }
    822829
     
    830837            $query = $parts[1];
    831838        }
    832     }
    833     else if ( strstr($uri, '/') ) {
     839    } else if ( strstr($uri, '/') ) {
    834840        $base = $uri . '?';
    835841        $query = '';
     
    854860        }
    855861    }
    856     $ret = $base . $ret;
     862    $ret = $protocol . $base . $ret;
     863    if ( get_magic_quotes_gpc() )
     864        $ret = stripslashes($ret); // parse_str() adds slashes if magicquotes is on.  See: http://php.net/parse_str
    857865    return trim($ret, '?');
    858866}
    859867
    860 function remove_query_arg($key, $query) {
     868/*
     869remove_query_arg: Returns a modified querystring by removing
     870a single key or an array of keys.
     871Omitting oldquery_or_uri uses the $_SERVER value.
     872
     873Parameters:
     874remove_query_arg(removekey, [oldquery_or_uri]) or
     875remove_query_arg(removekeyarray, [oldquery_or_uri])
     876*/
     877
     878function remove_query_arg($key, $query='') {
     879    if ( is_array($key) ) { // removing multiple keys
     880        foreach ( (array) $key as $k )
     881            $query = add_query_arg($k, '', $query);
     882        return $query;
     883    }
    861884    return add_query_arg($key, '', $query);
    862885}
Note: See TracChangeset for help on using the changeset viewer.