Changeset 5999
- Timestamp:
- 09/01/2007 03:41:50 AM (17 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/compat.php
r5187 r5999 99 99 } 100 100 101 // From php.net 102 if(!function_exists('http_build_query')) { 103 function http_build_query( $formdata, $numeric_prefix = null, $key = null ) { 104 $res = array(); 105 foreach ((array)$formdata as $k=>$v) { 106 $tmp_key = urlencode(is_int($k) ? $numeric_prefix.$k : $k); 107 if ($key) $tmp_key = $key.'['.$tmp_key.']'; 108 $res[] = ( ( is_array($v) || is_object($v) ) ? http_build_query($v, null, $tmp_key) : $tmp_key."=".urlencode($v) ); 109 } 110 $separator = ini_get('arg_separator.output'); 111 return implode($separator, $res); 112 } 101 if (!function_exists('http_build_query')) { 102 function http_build_query($data, $prefix=null, $sep=null) { 103 return _http_build_query($data, $prefix, $sep); 104 } 105 } 106 107 // from php.net (modified by Mark Jaquith to behave like the native PHP5 function) 108 function _http_build_query($data, $prefix=null, $sep=null, $key='') { 109 $ret = array(); 110 foreach ( (array) $data as $k => $v ) { 111 $k = urlencode($k); 112 if ( is_int($k) && $prefix != null ) 113 $k = $prefix.$k; 114 if ( !empty($key) ) 115 $k = $key . '%5B' . $k . '%5D'; 116 117 if ( $v === NULL ) 118 continue; 119 elseif ( $v === FALSE ) 120 $v = '0'; 121 122 if ( is_array($v) || is_object($v) ) 123 array_push($ret,_http_build_query($v, '', $sep, $k)); 124 else 125 array_push($ret, $k.'='.urlencode($v)); 126 } 127 128 if ( NULL === $sep ) 129 $sep = ini_get('arg_separator.output'); 130 131 return implode($sep, $ret); 113 132 } 114 133 -
trunk/wp-includes/functions.php
r5929 r5999 645 645 } 646 646 647 foreach($qs as $k => $v) { 648 if ( $v !== FALSE ) { 649 if ( $ret != '' ) 650 $ret .= '&'; 651 if ( empty($v) && !preg_match('|[?&]' . preg_quote($k, '|') . '=|', $query) ) 652 $ret .= $k; 653 else 654 $ret .= "$k=$v"; 655 } 656 } 647 foreach ( $qs as $k => $v ) { 648 if ( $v === false ) 649 unset($qs[$k]); 650 } 651 652 if ( ini_get('arg_separator.output') === '&') 653 $ret = http_build_query($qs, '', '&'); 654 else 655 $ret = _http_build_query($qs, NULL, '&'); 657 656 $ret = trim($ret, '?'); 657 $ret = preg_replace('#=(&|$)#', '$1', $ret); 658 658 $ret = $protocol . $base . $ret . $frag; 659 659 $ret = rtrim($ret, '?');
Note: See TracChangeset
for help on using the changeset viewer.