Make WordPress Core

Changeset 3658


Ignore:
Timestamp:
03/24/2006 07:22:22 PM (18 years ago)
Author:
ryan
Message:

Retrieve bookmarks for multiple cats. Props MichaelH. fixes #2592

File:
1 edited

Legend:

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

    r3655 r3658  
    7878        $orderby = substr($orderby, 1);
    7979    }
     80   
     81    if ($category == -1) {  //get_bookmarks uses '' to signify all categories
     82        $category = '';
     83    }
    8084
    8185    $results = get_bookmarks("category=$category&orderby=$orderby&order=$order&show_updated=$show_updated&limit=$limit");
     
    235239    if (!isset($direction)) $direction = '';
    236240
    237     $cats = get_categories("type=link&orderby=$order&order=$direction");
     241    $cats = get_categories("type=link&orderby=$order&order=$direction&hierarchical=0");
    238242
    239243    // Display each category
     
    283287        parse_str($args, $r);
    284288
    285     $defaults = array('orderby' => 'name', 'order' => 'ASC', 'limit' => -1, 'category' => -1,
     289    $defaults = array('orderby' => 'name', 'order' => 'ASC', 'limit' => -1, 'category' => '',
    286290        'category_name' => '', 'hide_invisible' => 1, 'show_updated' => 0, 'include' => '', 'exclude' => '');
    287291    $r = array_merge($defaults, $r);
     
    291295    if ( !empty($include) ) {
    292296    $exclude = '';  //ignore exclude, category, and category_name params if using include
    293     $category = -1;
     297    $category = '';
    294298    $category_name = '';
    295299        $inclinks = preg_split('/[\s,]+/',$include);
     
    328332    $category_query = '';
    329333    $join = '';
    330     if ( $category != -1 && !empty($category) ) {
     334    if ( !empty($category) ) {
     335        $incategories = preg_split('/[\s,]+/',$category);
     336        if ( count($incategories) ) {
     337            foreach ( $incategories as $incat ) {
     338                if (empty($category_query))
     339                    $category_query = ' AND ( category_id = ' . intval($incat) . ' ';
     340                else
     341                    $category_query .= ' OR category_id = ' . intval($incat) . ' ';
     342            }
     343        }
     344    }
     345    if (!empty($category_query)) {
     346        $category_query .= ')';
    331347        $join = " LEFT JOIN $wpdb->link2cat ON ($wpdb->links.link_id = $wpdb->link2cat.link_id) ";
    332 
    333         $category_query = " AND category_id = $category ";
    334348    }
    335349
Note: See TracChangeset for help on using the changeset viewer.