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: http://svn.automattic.com/wordpress/trunk@3594 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2006-03-02 05:47:59 +00:00
parent 83a6d4c005
commit 5643e1c1ba
3 changed files with 37 additions and 13 deletions

View File

@ -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';

View File

@ -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';

View File

@ -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'] )