Make WordPress Core


Ignore:
Timestamp:
05/11/2007 03:10:05 AM (20 years ago)
Author:
rob1n
Message:

Use wp_parse_args(). fixes #4237

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/category-template.php

    r5265 r5444  
    170170
    171171function wp_dropdown_categories($args = '') {
    172         if ( is_array($args) )
    173                 $r = &$args;
    174         else
    175                 parse_str($args, $r);
    176 
    177         $defaults = array('show_option_all' => '', 'show_option_none' => '', 'orderby' => 'ID',
    178                 'order' => 'ASC', 'show_last_update' => 0, 'show_count' => 0,
    179                 'hide_empty' => 1, 'child_of' => 0, 'exclude' => '', 'echo' => 1,
    180                 'selected' => 0, 'hierarchical' => 0, 'name' => 'cat',
    181                 'class' => 'postform');
     172        $defaults = array(
     173                'show_option_all' => '', 'show_option_none' => '',
     174                'orderby' => 'ID', 'order' => 'ASC',
     175                'show_last_update' => 0, 'show_count' => 0,
     176                'hide_empty' => 1, 'child_of' => 0,
     177                'exclude' => '', 'echo' => 1,
     178                'selected' => 0, 'hierarchical' => 0,
     179                'name' => 'cat', 'class' => 'postform'
     180        );
     181       
    182182        $defaults['selected'] = ( is_category() ) ? get_query_var('cat') : 0;
    183         $r = array_merge($defaults, $r);
     183       
     184        $r = wp_parse_args( $args, $defaults );
    184185        $r['include_last_update_time'] = $r['show_last_update'];
    185         extract($r);
     186        extract( $r );
    186187
    187188        $categories = get_categories($r);
    … …  
    219220
    220221function wp_list_categories($args = '') {
    221         if ( is_array($args) )
    222                 $r = &$args;
    223         else
    224                 parse_str($args, $r);
    225 
    226         $defaults = array('show_option_all' => '', 'orderby' => 'name',
    227                 'order' => 'ASC', 'show_last_update' => 0, 'style' => 'list',
    228                 'show_count' => 0, 'hide_empty' => 1, 'use_desc_for_title' => 1,
    229                 'child_of' => 0, 'feed' => '', 'feed_image' => '', 'exclude' => '',
    230                 'hierarchical' => true, 'title_li' => __('Categories'));
    231         $r = array_merge($defaults, $r);
    232         if ( !isset($r['pad_counts']) && $r['show_count'] && $r['hierarchical'] )
     222        $defaults = array(
     223                'show_option_all' => '', 'orderby' => 'name',
     224                'order' => 'ASC', 'show_last_update' => 0,
     225                'style' => 'list', 'show_count' => 0,
     226                'hide_empty' => 1, 'use_desc_for_title' => 1,
     227                'child_of' => 0, 'feed' => '',
     228                'feed_image' => '', 'exclude' => '',
     229                'hierarchical' => true, 'title_li' => __('Categories')
     230        );
     231       
     232        $r = wp_parse_args( $args, $defaults );
     233       
     234        if ( !isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) {
    233235                $r['pad_counts'] = true;
    234         if ( isset($r['show_date']) )
     236        }
     237       
     238        if ( isset( $r['show_date'] ) ) {
    235239                $r['include_last_update_time'] = $r['show_date'];
    236         extract($r);
    237 
     240        }
     241       
     242        extract( $r );
     243       
    238244        $categories = get_categories($r);
    239245
Note: See TracChangeset for help on using the changeset viewer.