Make WordPress Core


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

Use wp_parse_args(). fixes #4237

File:
1 edited

Legend:

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

    r5153 r5444  
    1010function wp_get_links($args = '') {
    1111    global $wpdb;
    12 
    13     if ( empty($args) )
    14         return;
    15 
    16     if ( false === strpos($args, '=') ) {
     12   
     13    if ( strpos( $args, '=' ) === false ) {
    1714        $cat_id = $args;
    18         $args = add_query_arg('category', $cat_id, $args);
    19     }
    20 
    21     parse_str($args);
    22 
    23     if ( !isset($category) )         $category = -1;
    24     if ( !isset($before) )           $before = '';
    25     if ( !isset($after) )            $after = '<br />';
    26     if ( !isset($between) )          $between = ' ';
    27     if ( !isset($show_images) )      $show_images = true;
    28     if ( !isset($orderby) )          $orderby = 'name';
    29     if ( !isset($show_description) ) $show_description = true;
    30     if ( !isset($show_rating) )      $show_rating = false;
    31     if ( !isset($limit) )            $limit = -1;
    32     if ( !isset($show_updated) )     $show_updated = 1;
    33     if ( !isset($echo) )             $echo = true;
     15        $args = add_query_arg( 'category', $cat_id, $args );
     16    }
     17   
     18    $defaults = array(
     19        'category' => -1, 'before' => '',
     20        'after' => '<br />', 'between' => ' ',
     21        'show_images' => true, 'orderby' => 'name',
     22        'show_description' => true, 'show_rating' => false,
     23        'limit' => -1, 'show_updated' => true,
     24        'echo' => true
     25    );
     26   
     27    $r = wp_parse_args( $args, $defaults );
     28    extract( $r );
    3429
    3530    return get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated, $echo);
     
    246241
    247242function _walk_bookmarks($bookmarks, $args = '' ) {
    248     if ( is_array($args) )
    249         $r = &$args;
    250     else
    251         parse_str($args, $r);
    252 
    253     $defaults = array('show_updated' => 0, 'show_description' => 0, 'show_images' => 1, 'before' => '<li>',
    254         'after' => '</li>', 'between' => "\n");
    255     $r = array_merge($defaults, $r);
    256     extract($r);
     243    $defaults = array(
     244        'show_updated' => 0, 'show_description' => 0,
     245        'show_images' => 1, 'before' => '<li>',
     246        'after' => '</li>', 'between' => "\n"
     247    );
     248   
     249    $r = wp_parse_args( $args, $defaults );
     250    extract( $r );
    257251
    258252    foreach ( (array) $bookmarks as $bookmark ) {
     
    321315
    322316function wp_list_bookmarks($args = '') {
    323     if ( is_array($args) )
    324         $r = &$args;
    325     else
    326         parse_str($args, $r);
    327 
    328     $defaults = array('orderby' => 'name', 'order' => 'ASC', 'limit' => -1, 'category' => '',
    329         'category_name' => '', 'hide_invisible' => 1, 'show_updated' => 0, 'echo' => 1,
    330         'categorize' => 1, 'title_li' => __('Bookmarks'), 'title_before' => '<h2>', 'title_after' => '</h2>',
    331         'category_orderby' => 'name', 'category_order' => 'ASC', 'class' => 'linkcat',
    332         'category_before' => '<li id="%id" class="%class">', 'category_after' => '</li>');
    333     $r = array_merge($defaults, $r);
    334     extract($r);
     317    $defaults = array(
     318        'orderby' => 'name', 'order' => 'ASC',
     319        'limit' => -1, 'category' => '',
     320        'category_name' => '', 'hide_invisible' => 1,
     321        'show_updated' => 0, 'echo' => 1,
     322        'categorize' => 1, 'title_li' => __('Bookmarks'),
     323        'title_before' => '<h2>', 'title_after' => '</h2>',
     324        'category_orderby' => 'name', 'category_order' => 'ASC',
     325        'class' => 'linkcat', 'category_before' => '<li id="%id" class="%class">',
     326        'category_after' => '</li>'
     327    );
     328   
     329    $r = wp_parse_args( $args, $defaults );
     330    extract( $r );
    335331
    336332    $output = '';
Note: See TracChangeset for help on using the changeset viewer.