From c4d9df2c9954990cee25024f45798fb453b499f4 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Thu, 2 Mar 2006 05:47:59 +0000 Subject: [PATCH] Allow args to be passed as query string or as associative array. This avoid multiple parse_str calls when passing args along and provides choice on the cheap. git-svn-id: https://develop.svn.wordpress.org/trunk@3594 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/template-functions-bookmarks.php | 5 ++++- wp-includes/template-functions-category.php | 23 ++++++++++++++------ wp-includes/template-functions-post.php | 22 ++++++++++++++----- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/wp-includes/template-functions-bookmarks.php b/wp-includes/template-functions-bookmarks.php index 9901ff9cfd..71d1bf63c3 100644 --- a/wp-includes/template-functions-bookmarks.php +++ b/wp-includes/template-functions-bookmarks.php @@ -250,7 +250,10 @@ function get_links_list($order = 'name', $hide_if_empty = 'obsolete') { function get_bookmarks($args = '') { global $wpdb; - parse_str($args, $r); + if ( is_array($args) ) + $r = &$args; + else + parse_str($args, $r); if ( !isset($r['orderby']) ) $r['orderby'] = 'name'; diff --git a/wp-includes/template-functions-category.php b/wp-includes/template-functions-category.php index 113c296ea3..21840db9a2 100644 --- a/wp-includes/template-functions-category.php +++ b/wp-includes/template-functions-category.php @@ -150,7 +150,11 @@ function category_description($category = 0) { } function wp_dropdown_categories($args = '') { - parse_str($args, $r); + if ( is_array($args) ) + $r = &$args; + else + parse_str($args, $r); + if ( !isset($r['show_option_all'])) $r['show_option_all'] = ''; if ( !isset($r['show_option_none'])) @@ -184,8 +188,7 @@ function wp_dropdown_categories($args = '') { extract($r); - $query = add_query_arg($r, ''); - $categories = get_categories($query); + $categories = get_categories($r); $output = ''; if ( ! empty($categories) ) { @@ -243,7 +246,11 @@ function wp_list_cats($args = '') { } function wp_list_categories($args = '') { - parse_str($args, $r); + if ( is_array($args) ) + $r = &$args; + else + parse_str($args, $r); + if ( !isset($r['optionall'])) $r['optionall'] = 0; if ( !isset($r['all'])) @@ -284,8 +291,7 @@ function wp_list_categories($args = '') { extract($r); - $query = add_query_arg($r, ''); - $categories = get_categories($query); + $categories = get_categories($r); $output = ''; if ( $title_li && $list ) @@ -425,7 +431,10 @@ function &_get_cat_children($category_id, $categories) { function &get_categories($args = '') { global $wpdb, $category_links; - parse_str($args, $r); + if ( is_array($args) ) + $r = &$args; + else + parse_str($args, $r); if ( !isset($r['type']) ) // 'post' or 'link' $r['type'] = 'post'; diff --git a/wp-includes/template-functions-post.php b/wp-includes/template-functions-post.php index 01cd9726f5..51380e584c 100644 --- a/wp-includes/template-functions-post.php +++ b/wp-includes/template-functions-post.php @@ -295,7 +295,11 @@ function &get_page_children($page_id, $pages) { function &get_pages($args = '') { global $wpdb; - parse_str($args, $r); + + if ( is_array($args) ) + $r = &$args; + else + parse_str($args, $r); if ( !isset($r['child_of']) ) $r['child_of'] = 0; @@ -335,7 +339,11 @@ function &get_pages($args = '') { } function wp_dropdown_pages($args = '') { - parse_str($args, $r); + if ( is_array($args) ) + $r = &$args; + else + parse_str($args, $r); + if ( !isset($r['depth']) ) $r['depth'] = 0; if ( !isset($r['child_of']) ) @@ -348,7 +356,7 @@ function wp_dropdown_pages($args = '') { $r['name'] = 'page_id'; extract($r); - $pages = get_pages($args); + $pages = get_pages($r); $output = ''; if ( ! empty($pages) ) { @@ -380,7 +388,11 @@ function _page_dropdown_element($output, $page, $depth, $selected) { } function wp_list_pages($args = '') { - parse_str($args, $r); + if ( is_array($args) ) + $r = &$args; + else + parse_str($args, $r); + if ( !isset($r['depth']) ) $r['depth'] = 0; if ( !isset($r['show_date']) ) @@ -397,7 +409,7 @@ function wp_list_pages($args = '') { $output = ''; // Query pages. - $pages = get_pages($args); + $pages = get_pages($r); if ( !empty($pages) ) { if ( $r['title_li'] )