Ticket #2587: 2587.wp_list_bookmarks.diff

File 2587.wp_list_bookmarks.diff, 2.7 KB (added by westi, 6 years ago)

Implement the rest of wp_list_bookmarks

  • wp-includes/bookmark-template.php

     
    316316        else 
    317317                parse_str($args, $r); 
    318318 
    319         $defaults = array('orderby' => 'name', 'order' => 'ASC', 'limit' => -1, 'category' => 0, 
     319        $defaults = array('orderby' => 'name', 'order' => 'ASC', 'limit' => -1, 'category' => '', 
    320320                'category_name' => '', 'hide_invisible' => 1, 'show_updated' => 0, 'echo' => 1, 
    321321                'categorize' => 1, 'title_li' => __('Bookmarks'), 'title_before' => '<h2>', 'title_after' => '</h2>', 
    322322                'category_orderby' => 'name', 'category_order' => 'ASC'); 
    323323        $r = array_merge($defaults, $r); 
    324324        extract($r); 
    325325 
    326         // TODO: The rest of it. 
    327         // If $categorize, group links by category with the category name being the 
    328         // title of each li, otherwise just list them with title_li as the li title. 
    329         // If $categorize and $category or $category_name, list links for the given category 
    330         // with the category name as the title li.  If not $categorize, use title_li. 
    331         // When using each category's name as a title li, use before and after args for specifying 
    332         // any markup.  We don't want to hardcode h2. 
    333  
    334326        $output = ''; 
    335327 
    336328        if ( $categorize ) { 
    337                 $cats = get_categories("type=link&orderby=$category_orderby&order=$category_order&hierarchical=0"); 
     329                //Split the bookmarks into ul's for each category 
     330                $cats = get_categories("type=link&category_name=$category_name&include=$category&orderby=$category_orderby&order=$category_order&hierarchical=0"); 
     331 
    338332                foreach ( (array) $cats as $cat ) { 
    339                         $r['category'] = $cat->cat_ID; 
    340                         $bookmarks = get_bookmarks($r); 
     333                        $bookmarks = get_bookmarks("limit=$limit&category={$cat->cat_ID}&show_updated=$show_updated&orderby=$orderby&order=$order&hide_invisible=$hide_inivisible&show_updated=$show_updated"); 
    341334                        if ( empty($bookmarks) ) 
    342335                                continue; 
    343336                        $output .= "<li id='linkcat-$cat->cat_ID' class='linkcat'>$title_before$cat->cat_name$title_after\n\t<ul>\n"; 
    344337                        $output .= _walk_bookmarks($bookmarks, $r); 
    345338                        $output .= "\n\t</ul>\n</li>\n"; 
    346339                } 
     340        } else { 
     341                //output one single list using title_li for the title 
     342                $bookmarks = get_bookmarks("limit=$limit&category=$category&show_updated=$show_updated&orderby=$orderby&order=$order&hide_invisible=$hide_inivisible&show_updated=$show_updated"); 
     343                 
     344                if ( !empty($bookmarks) ) { 
     345                        $output .= "<li id='linkuncat' class='linkcat'>$title_before$title_li$title_after\n\t<ul>\n"; 
     346                        $output .= _walk_bookmarks($bookmarks, $r); 
     347                        $output .= "\n\t</ul>\n</li>\n"; 
     348                } 
    347349        } 
    348350 
    349351        if ( !$echo ) 
     
    351353        echo $output; 
    352354} 
    353355 
    354 ?> 
    355  No newline at end of file 
     356?>