Make WordPress Core

Ticket #14754: 14754.2.patch

File 14754.2.patch, 1.8 KB (added by hakre, 14 years ago)

some more lines

  • wp-includes/functions.php

     
    13591359 * @since 1.5.0
    13601360 *
    13611361 * @param mixed $param1 Either newkey or an associative_array
    1362  * @param mixed $param2 Either newvalue or oldquery or uri
    1363  * @param mixed $param3 Optional. Old query or uri
     1362 * @param mixed $param2 Optional. Either newvalue or oldquery_or_uri
     1363 * @param mixed $param3 Optional. oldquery_or_uri
    13641364 * @return string New URL query string.
    13651365 */
    1366 function add_query_arg() {
     1366function add_query_arg($param1, $param2 = false, $param3 = false) {
    13671367        $ret = '';
    1368         if ( is_array( func_get_arg(0) ) ) {
    1369                 if ( @func_num_args() < 2 || false === @func_get_arg( 1 ) )
    1370                         $uri = $_SERVER['REQUEST_URI'];
    1371                 else
    1372                         $uri = @func_get_arg( 1 );
    1373         } else {
    1374                 if ( @func_num_args() < 3 || false === @func_get_arg( 2 ) )
    1375                         $uri = $_SERVER['REQUEST_URI'];
    1376                 else
    1377                         $uri = @func_get_arg( 2 );
    1378         }
     1368        $uri = is_array( $param1 ) ? $param2 : $param3;
     1369        false === $uri && ($uri = $_SERVER['REQUEST_URI']);
    13791370
    13801371        if ( $frag = strstr( $uri, '#' ) )
    13811372                $uri = substr( $uri, 0, -strlen( $frag ) );
     
    14061397                $query = $uri;
    14071398        }
    14081399
     1400        $qs = array();
    14091401        wp_parse_str( $query, $qs );
    14101402        $qs = urlencode_deep( $qs ); // this re-URL-encodes things that were already in the query string
    1411         if ( is_array( func_get_arg( 0 ) ) ) {
    1412                 $kayvees = func_get_arg( 0 );
    1413                 $qs = array_merge( $qs, $kayvees );
     1403        if ( is_array( $param1 ) ) {
     1404                $qs = array_merge( $qs, $param1 );
    14141405        } else {
    1415                 $qs[func_get_arg( 0 )] = func_get_arg( 1 );
     1406                $qs[$param1] = $param2;
    14161407        }
    14171408
    1418         foreach ( (array) $qs as $k => $v ) {
    1419                 if ( $v === false )
    1420                         unset( $qs[$k] );
    1421         }
     1409        $qs = array_filter( $qs );
    14221410
    14231411        $ret = build_query( $qs );
    14241412        $ret = trim( $ret, '?' );