Advertisement
Guest User

wp_list_bookmarks function

a guest
May 16th, 2012
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.22 KB | None | 0 0
  1. function wp_list_bookmarks_jr($args = '') {
  2.     $defaults = array(
  3.         'orderby' => 'name', 'order' => 'ASC',
  4.         'limit' => -1, 'category' => '', 'exclude_category' => '',
  5.         'category_name' => '', 'hide_invisible' => 1,
  6.         'show_updated' => 0, 'echo' => 1,
  7.         'categorize' => 1, 'title_li' => __('Bookmarks'),
  8.         'title_before' => '<h2>', 'title_after' => '</h2>',
  9.         'category_orderby' => 'name', 'category_order' => 'ASC',
  10.         'class' => 'linkcat', 'category_before' => '<li id="%id" class="%class">',
  11.         'category_after' => '</li>'
  12.     );
  13.  
  14.     $r = wp_parse_args( $args, $defaults );
  15.     extract( $r, EXTR_SKIP );
  16.  
  17.     $output = '';
  18.  
  19.     if ( $categorize ) {
  20.         //Split the bookmarks into ul's for each category
  21.         $cats = get_terms('link_category', array('name__like' => $category_name, 'include' => $category, 'exclude' => $exclude_category, 'orderby' => $category_orderby, 'order' => $category_order, 'hierarchical' => 0));
  22.  
  23.         foreach ( (array) $cats as $cat ) {
  24.             $params = array_merge($r, array('category'=>$cat->term_id));
  25.             $bookmarks = get_bookmarks($params);
  26.             if ( empty($bookmarks) )
  27.                 continue;
  28.             $output .= str_replace(array('%id', '%class'), array("linkcat-$cat->term_id", $class), $category_before);
  29.             $catname = apply_filters( "link_category", $cat->name );
  30.             $catdescr = apply_filters("link_category", $cat->description);// getting category description
  31.             $output .= "$title_before$catname$title_after\n<p>$catdescr</p>\t<ul class='xoxo nostyle'>\n";//added my own 'nostyle' class to the ul
  32.             $output .= _walk_bookmarks($bookmarks, $r);
  33.             $output .= "\n\t</ul>\n$category_after\n";
  34.         }
  35.     } else {
  36.         //output one single list using title_li for the title
  37.         $bookmarks = get_bookmarks($r);
  38.  
  39.         if ( !empty($bookmarks) ) {
  40.             if ( !empty( $title_li ) ){
  41.                 $output .= str_replace(array('%id', '%class'), array("linkcat-$category", $class), $category_before);
  42.                 $output .= "$title_before$title_li$title_after\n\t<ul class='xoxo blogroll'>\n";
  43.                 $output .= _walk_bookmarks($bookmarks, $r);
  44.                 $output .= "\n\t</ul>\n$category_after\n";
  45.             } else {
  46.                 $output .= _walk_bookmarks($bookmarks, $r);
  47.             }
  48.         }
  49.     }
  50.  
  51.     $output = apply_filters( 'wp_list_bookmarks', $output );
  52.  
  53.     if ( !$echo )
  54.         return $output;
  55.     echo $output;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement