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,6 +250,9 @@ function get_links_list($order = 'name', $hide_if_empty = 'obsolete') {
function get_bookmarks($args = '') { function get_bookmarks($args = '') {
global $wpdb; global $wpdb;
if ( is_array($args) )
$r = &$args;
else
parse_str($args, $r); parse_str($args, $r);
if ( !isset($r['orderby']) ) if ( !isset($r['orderby']) )

View File

@ -150,7 +150,11 @@ function category_description($category = 0) {
} }
function wp_dropdown_categories($args = '') { function wp_dropdown_categories($args = '') {
if ( is_array($args) )
$r = &$args;
else
parse_str($args, $r); 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 = '') {
if ( is_array($args) )
$r = &$args;
else
parse_str($args, $r); 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,6 +431,9 @@ function &_get_cat_children($category_id, $categories) {
function &get_categories($args = '') { function &get_categories($args = '') {
global $wpdb, $category_links; global $wpdb, $category_links;
if ( is_array($args) )
$r = &$args;
else
parse_str($args, $r); parse_str($args, $r);
if ( !isset($r['type']) ) // 'post' or 'link' if ( !isset($r['type']) ) // 'post' or 'link'

View File

@ -295,6 +295,10 @@ function &get_page_children($page_id, $pages) {
function &get_pages($args = '') { function &get_pages($args = '') {
global $wpdb; global $wpdb;
if ( is_array($args) )
$r = &$args;
else
parse_str($args, $r); parse_str($args, $r);
if ( !isset($r['child_of']) ) if ( !isset($r['child_of']) )
@ -335,7 +339,11 @@ function &get_pages($args = '') {
} }
function wp_dropdown_pages($args = '') { function wp_dropdown_pages($args = '') {
if ( is_array($args) )
$r = &$args;
else
parse_str($args, $r); 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 = '') {
if ( is_array($args) )
$r = &$args;
else
parse_str($args, $r); 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'] )