wp_parse_str() from mdawaffe. fixes #4467

git-svn-id: http://svn.automattic.com/wordpress/branches/2.2@5713 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2007-06-15 17:35:56 +00:00
parent 69c8191502
commit f3612d4293
3 changed files with 32 additions and 36 deletions

View File

@ -1118,4 +1118,11 @@ function wp_make_link_relative( $link ) {
return preg_replace('|https?://[^/]+(/.*)|i', '$1', $link );
}
function wp_parse_str( $string, &$array ) {
parse_str( $string, $array );
if ( get_magic_quotes_gpc() )
$array = stripslashes_deep( $array ); // parse_str() adds slashes if magicquotes is on. See: http://php.net/parse_str
$array = apply_filters( 'wp_parse_str', $array );
}
?>

View File

@ -801,9 +801,7 @@ function add_query_arg() {
$query = $uri;
}
parse_str($query, $qs);
if ( get_magic_quotes_gpc() )
$qs = stripslashes_deep($qs); // parse_str() adds slashes if magicquotes is on. See: http://php.net/parse_str
wp_parse_str($query, $qs);
$qs = urlencode_deep($qs);
if ( is_array(func_get_arg(0)) ) {
$kayvees = func_get_arg(0);
@ -1481,21 +1479,15 @@ function smilies_init() {
}
function wp_parse_args( $args, $defaults = '' ) {
if ( is_array($args) ) :
if ( is_array( $args ) )
$r =& $args;
else :
parse_str( $args, $r );
if ( get_magic_quotes_gpc() )
$r = stripslashes_deep( $r );
endif;
else
wp_parse_str( $args, $r );
if ( is_array($defaults) ) :
extract($defaults);
extract($r);
return compact(array_keys($defaults)); // only those options defined in $defaults
else :
if ( is_array( $defaults ) )
return array_merge( $defaults, $r );
else
return $r;
endif;
}
function wp_maybe_load_widgets() {
@ -1518,4 +1510,4 @@ function wp_ob_end_flush_all()
while ( @ob_end_flush() );
}
?>
?>

View File

@ -957,27 +957,24 @@ function language_attributes() {
echo $output;
}
function paginate_links( $arg = '' ) {
if ( is_array($arg) )
$a = &$arg;
else
parse_str($arg, $a);
function paginate_links( $args = '' ) {
$defaults = array(
'base' => '%_%', // http://example.com/all_posts.php%_% : %_% is replaced by format (below)
'format' => '?page=%#%', // ?page=%#% : %#% is replaced by the page number
'total' => 1,
'current' => 0,
'show_all' => false,
'prev_next' => true,
'prev_text' => __('« Previous'),
'next_text' => __('Next »'),
'end_size' => 1, // How many numbers on either end including the end
'mid_size' => 2, // How many numbers to either side of current not including current
'type' => 'plain',
'add_args' => false // array of query args to aadd
);
// Defaults
$base = '%_%'; // http://example.com/all_posts.php%_% : %_% is replaced by format (below)
$format = '?page=%#%'; // ?page=%#% : %#% is replaced by the page number
$total = 1;
$current = 0;
$show_all = false;
$prev_next = true;
$prev_text = __('« Previous');
$next_text = __('Next »');
$end_size = 1; // How many numbers on either end including the end
$mid_size = 2; // How many numbers to either side of current not including current
$type = 'plain';
$add_args = false; // array of query args to aadd
extract($a);
$args = wp_parse_args( $args, $defaults );
extract($args, EXTR_SKIP);
// Who knows what else people pass in $args
$total = (int) $total;