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 = '') { function get_bookmarks($args = '') {
global $wpdb; global $wpdb;
parse_str($args, $r); if ( is_array($args) )
$r = &$args;
else
parse_str($args, $r);
if ( !isset($r['orderby']) ) if ( !isset($r['orderby']) )
$r['orderby'] = 'name'; $r['orderby'] = 'name';

View File

@ -150,7 +150,11 @@ function category_description($category = 0) {
} }
function wp_dropdown_categories($args = '') { 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'])) if ( !isset($r['show_option_all']))
$r['show_option_all'] = ''; $r['show_option_all'] = '';
if ( !isset($r['show_option_none'])) if ( !isset($r['show_option_none']))
@ -184,8 +188,7 @@ function wp_dropdown_categories($args = '') {
extract($r); extract($r);
$query = add_query_arg($r, ''); $categories = get_categories($r);
$categories = get_categories($query);
$output = ''; $output = '';
if ( ! empty($categories) ) { if ( ! empty($categories) ) {
@ -243,7 +246,11 @@ function wp_list_cats($args = '') {
} }
function wp_list_categories($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'])) if ( !isset($r['optionall']))
$r['optionall'] = 0; $r['optionall'] = 0;
if ( !isset($r['all'])) if ( !isset($r['all']))
@ -284,8 +291,7 @@ function wp_list_categories($args = '') {
extract($r); extract($r);
$query = add_query_arg($r, ''); $categories = get_categories($r);
$categories = get_categories($query);
$output = ''; $output = '';
if ( $title_li && $list ) if ( $title_li && $list )
@ -425,7 +431,10 @@ function &_get_cat_children($category_id, $categories) {
function &get_categories($args = '') { function &get_categories($args = '') {
global $wpdb, $category_links; 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' if ( !isset($r['type']) ) // 'post' or 'link'
$r['type'] = 'post'; $r['type'] = 'post';

View File

@ -295,7 +295,11 @@ function &get_page_children($page_id, $pages) {
function &get_pages($args = '') { function &get_pages($args = '') {
global $wpdb; global $wpdb;
parse_str($args, $r);
if ( is_array($args) )
$r = &$args;
else
parse_str($args, $r);
if ( !isset($r['child_of']) ) if ( !isset($r['child_of']) )
$r['child_of'] = 0; $r['child_of'] = 0;
@ -335,7 +339,11 @@ function &get_pages($args = '') {
} }
function wp_dropdown_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']) ) if ( !isset($r['depth']) )
$r['depth'] = 0; $r['depth'] = 0;
if ( !isset($r['child_of']) ) if ( !isset($r['child_of']) )
@ -348,7 +356,7 @@ function wp_dropdown_pages($args = '') {
$r['name'] = 'page_id'; $r['name'] = 'page_id';
extract($r); extract($r);
$pages = get_pages($args); $pages = get_pages($r);
$output = ''; $output = '';
if ( ! empty($pages) ) { if ( ! empty($pages) ) {
@ -380,7 +388,11 @@ function _page_dropdown_element($output, $page, $depth, $selected) {
} }
function wp_list_pages($args = '') { function wp_list_pages($args = '') {
parse_str($args, $r); if ( is_array($args) )
$r = &$args;
else
parse_str($args, $r);
if ( !isset($r['depth']) ) if ( !isset($r['depth']) )
$r['depth'] = 0; $r['depth'] = 0;
if ( !isset($r['show_date']) ) if ( !isset($r['show_date']) )
@ -397,7 +409,7 @@ function wp_list_pages($args = '') {
$output = ''; $output = '';
// Query pages. // Query pages.
$pages = get_pages($args); $pages = get_pages($r);
if ( !empty($pages) ) { if ( !empty($pages) ) {
if ( $r['title_li'] ) if ( $r['title_li'] )