Use array_merge() to set defaults.

git-svn-id: http://svn.automattic.com/wordpress/trunk@3595 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2006-03-02 06:37:00 +00:00
parent 5643e1c1ba
commit 7f125c5135
3 changed files with 32 additions and 129 deletions

View File

@ -255,23 +255,13 @@ function get_bookmarks($args = '') {
else
parse_str($args, $r);
if ( !isset($r['orderby']) )
$r['orderby'] = 'name';
if ( !isset($r['order']) )
$r['order'] = 'ASC';
if ( !isset($r['limit']) )
$r['limit'] = -1;
if ( !isset($r['category']) )
$r['category'] = -1;
if ( !isset($r['category_name']) )
$r['category_name'] = '';
if ( !isset($r['hide_invisible']) )
$r['hide_invisible'] = 1;
if ( !isset($r['show_updated']) )
$r['show_updated'] = 0;
$defaults = array('orderby' => 'name', 'order' => 'ASC', 'limit' => -1, 'category' => -1,
'category_name' => '', 'hide_invisible' => 1, 'show_updated' => 0);
$r = array_merge($defaults, $r);
extract($r);
$exclusions = '';
if ( !empty($r['exclude']) ) {
if ( !empty($exclude) ) {
$exlinks = preg_split('/[\s,]+/',$r['exclude']);
if ( count($exlinks) ) {
foreach ( $exlinks as $exlink ) {
@ -280,8 +270,6 @@ function get_bookmarks($args = '') {
}
}
extract($r);
if ( ! empty($category_name) ) {
if ( $cat_id = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$category_name' LIMIT 1") )
$category = $cat_id;

View File

@ -155,37 +155,13 @@ function wp_dropdown_categories($args = '') {
else
parse_str($args, $r);
if ( !isset($r['show_option_all']))
$r['show_option_all'] = '';
if ( !isset($r['show_option_none']))
$r['show_option_none'] = '';
if ( !isset($r['orderby']) )
$r['orderby'] = 'ID';
if ( !isset($r['order']) )
$r['order'] = 'ASC';
if ( !isset($r['show_last_update']) )
$r['show_last_update'] = 0;
if ( !isset($r['show_counts']) )
$r['show_counts'] = 0;
if ( !isset($r['hide_empty']) )
$r['hide_empty'] = 1;
if ( !isset($r['child_of']) )
$r['child_of'] = 0;
if ( !isset($r['exclude']) )
$r['exclude'] = '';
if ( !isset($r['echo']) )
$r['echo'] = 1;
if ( !isset($r['selected']) )
$r['selected'] = 0;
if ( !isset($r['hierarchical']) )
$r['hierarchical'] = 0;
if ( !isset($r['name']) )
$r['name'] = 'cat';
if ( !isset($r['class']) )
$r['class'] = 'postform';
$defaults = array('show_option_all' => '', 'show_option_none' => '', 'orderby' => 'ID',
'order' => 'ASC', 'show_last_update' => 0, 'show_counts' => 0,
'hide_empty' => 1, 'child_of' => 0, 'exclude' => '', 'echo' => 1,
'selected' => 0, 'hierarchical' => 0, 'name' => 'cat',
'class' => 'postform');
$r = array_merge($defaults, $r);
$r['include_last_update_time'] = $r['show_last_update'];
extract($r);
$categories = get_categories($r);
@ -251,44 +227,17 @@ function wp_list_categories($args = '') {
else
parse_str($args, $r);
if ( !isset($r['optionall']))
$r['optionall'] = 0;
if ( !isset($r['all']))
$r['all'] = 'All';
if ( !isset($r['sort_column']) )
$r['sort_column'] = 'ID';
if ( !isset($r['sort_order']) )
$r['sort_order'] = 'asc';
if ( !isset($r['file']) )
$r['file'] = '';
if ( !isset($r['list']) )
$r['list'] = true;
if ( !isset($r['optiondates']) )
$r['optiondates'] = 0;
if ( !isset($r['optioncount']) )
$r['optioncount'] = 0;
if ( !isset($r['hide_empty']) )
$r['hide_empty'] = 1;
if ( !isset($r['use_desc_for_title']) )
$r['use_desc_for_title'] = 1;
if ( !isset($r['child_of']) )
$r['child_of'] = 0;
if ( !isset($r['feed']) )
$r['feed'] = '';
if ( !isset($r['feed_image']) )
$r['feed_image'] = '';
if ( !isset($r['exclude']) )
$r['exclude'] = '';
if ( !isset($r['hierarchical']) )
$r['hierarchical'] = false;
if ( !isset($r['title_li']) )
$r['title_li'] = '';
if ( !isset($r['orderby']) )
$defaults = array('optionall' => 0, 'all' => 'All', 'sort_column' => 'ID',
'sort_order' => 'asc', 'list' => true, 'optiondates' => 0,
'optioncount' => 0, 'hide_empty' => 1, 'use_desc_for_title' => 1,
'child_of' => 0, 'feed' => '', 'feed_image' => '', 'exclude' => '',
'hierarchical' => false, 'title_li' => '');
$r = array_merge($defaults, $r);
if ( ! isset($r['orderby']) )
$r['orderby'] = $r['sort_column'];
if ( !isset($r['order']) )
if ( ! isset($r['order']) )
$r['order'] = $r['sort_order'];
$r['include_last_update_time'] = $r['optiondates'];
extract($r);
$categories = get_categories($r);
@ -436,23 +385,10 @@ function &get_categories($args = '') {
else
parse_str($args, $r);
if ( !isset($r['type']) ) // 'post' or 'link'
$r['type'] = 'post';
if ( !isset($r['child_of']) )
$r['child_of'] = 0;
if ( !isset($r['orderby']) )
$r['orderby'] = 'name';
if ( !isset($r['order']) )
$r['order'] = 'ASC';
if ( !isset($r['hide_empty']) )
$r['hide_empty'] = true;
if ( !isset($r['include_last_update_time']) )
$r['include_last_update_time'] = false;
if ( !isset($r['hierarchical']) )
$r['hierarchical'] = 1;
$defaults = array('type' => 'post', 'child_of' => 0, 'orderby' => 'name', 'order' => 'ASC',
'hide_empty' => true, 'include_last_update_time' => false, 'hierarchical' => 1);
$r = array_merge($defaults, $r);
$r['orderby'] = "cat_" . $r['orderby'];
extract($r);
$exclusions = '';

View File

@ -301,14 +301,9 @@ function &get_pages($args = '') {
else
parse_str($args, $r);
if ( !isset($r['child_of']) )
$r['child_of'] = 0;
if ( !isset($r['sort_column']) )
$r['sort_column'] = 'post_title';
if ( !isset($r['sort_order']) )
$r['sort_order'] = 'ASC';
if ( !isset($r['hierarchical']) )
$r['hierarchical'] = 1;
$defaults = array('child_of' => 0, 'sort_order' => 'ASC', 'sort_column' => 'post_title',
'hierarchical' => 1);
$r = array_merge($defaults, $r);
$exclusions = '';
if ( !empty($r['exclude']) ) {
@ -344,16 +339,9 @@ function wp_dropdown_pages($args = '') {
else
parse_str($args, $r);
if ( !isset($r['depth']) )
$r['depth'] = 0;
if ( !isset($r['child_of']) )
$r['child_of'] = 0;
if ( !isset($r['echo']) )
$r['echo'] = 1;
if ( !isset($r['selected']) )
$r['selected'] = 0;
if ( !isset($r['name']) )
$r['name'] = 'page_id';
$defaults = array('depth' => 0, 'child_of' => 0, 'selected' => 0, 'echo' => 1,
'name' => 'page_id');
$r = array_merge($defaults, $r);
extract($r);
$pages = get_pages($r);
@ -393,18 +381,9 @@ function wp_list_pages($args = '') {
else
parse_str($args, $r);
if ( !isset($r['depth']) )
$r['depth'] = 0;
if ( !isset($r['show_date']) )
$r['show_date'] = '';
if ( !isset($r['date_format']) )
$r['date_format'] = get_settings('date_format');
if ( !isset($r['child_of']) )
$r['child_of'] = 0;
if ( !isset($r['title_li']) )
$r['title_li'] = __('Pages');
if ( !isset($r['echo']) )
$r['echo'] = 1;
$defaults = array('depth' => 0, 'show_date' => '', 'date_format' => get_settings('date_format'),
'child_of' => 0, 'title_li' => __('Pages'), 'echo' => 1);
$r = array_merge($defaults, $r);
$output = '';