3 function _walk_bookmarks($bookmarks, $args = '' ) {
5 'show_updated' => 0, 'show_description' => 0,
6 'show_images' => 1, 'before' => '<li>',
7 'after' => '</li>', 'between' => "\n"
10 $r = wp_parse_args( $args, $defaults );
11 extract( $r, EXTR_SKIP );
13 foreach ( (array) $bookmarks as $bookmark ) {
14 if ( !isset($bookmark->recently_updated) )
15 $bookmark->recently_updated = false;
17 if ( $show_updated && $bookmark->recently_updated )
18 $output .= get_option('links_recently_updated_prepend');
21 if ( !empty($bookmark->link_url) )
22 $the_link = clean_url($bookmark->link_url);
24 $rel = $bookmark->link_rel;
26 $rel = ' rel="' . $rel . '"';
28 $desc = attribute_escape(sanitize_bookmark_field('link_description', $bookmark->link_description, $bookmark->link_id, 'display'));
29 $name = attribute_escape(sanitize_bookmark_field('link_name', $bookmark->link_name, $bookmark->link_id, 'display'));
33 if ( '00' != substr($bookmark->link_updated_f, 0, 2) ) {
35 $title .= sprintf(__('Last updated: %s'), date(get_option('links_updated_date_format'), $bookmark->link_updated_f + (get_option('gmt_offset') * 3600)));
40 $title = ' title="' . $title . '"';
42 $alt = ' alt="' . $name . '"';
44 $target = $bookmark->link_target;
46 $target = ' target="' . $target . '"';
48 $output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>';
50 if ( $bookmark->link_image != null && $show_images ) {
51 if ( strpos($bookmark->link_image, 'http') !== false )
52 $output .= "<img src=\"$bookmark->link_image\" $alt $title />";
53 else // If it's a relative path
54 $output .= "<img src=\"" . get_option('siteurl') . "$bookmark->link_image\" $alt $title />";
61 if ( $show_updated && $bookmark->recently_updated )
62 $output .= get_option('links_recently_updated_append');
64 if ( $show_description && '' != $desc )
65 $output .= $between . $desc;
68 $output .= $between . get_linkrating($bookmark);
71 $output .= "$after\n";
77 function wp_list_bookmarks($args = '') {
79 'orderby' => 'name', 'order' => 'ASC',
80 'limit' => -1, 'category' => '',
81 'category_name' => '', 'hide_invisible' => 1,
82 'show_updated' => 0, 'echo' => 1,
83 'categorize' => 1, 'title_li' => __('Bookmarks'),
84 'title_before' => '<h2>', 'title_after' => '</h2>',
85 'category_orderby' => 'name', 'category_order' => 'ASC',
86 'class' => 'linkcat', 'category_before' => '<li id="%id" class="%class">',
87 'category_after' => '</li>'
90 $r = wp_parse_args( $args, $defaults );
91 extract( $r, EXTR_SKIP );
96 //Split the bookmarks into ul's for each category
97 $cats = get_terms('link_category', "category_name=$category_name&include=$category&orderby=$category_orderby&order=$category_order&hierarchical=0");
99 foreach ( (array) $cats as $cat ) {
100 $params = array_merge($r, array('category'=>$cat->term_id));
101 $bookmarks = get_bookmarks($params);
102 if ( empty($bookmarks) )
104 $output .= str_replace(array('%id', '%class'), array("linkcat-$cat->term_id", $class), $category_before);
105 $catname = apply_filters( "link_category", $cat->name );
106 $output .= "$title_before$catname$title_after\n\t<ul>\n";
107 $output .= _walk_bookmarks($bookmarks, $r);
108 $output .= "\n\t</ul>\n$category_after\n";
111 //output one single list using title_li for the title
112 $bookmarks = get_bookmarks($r);
114 if ( !empty($bookmarks) ) {
115 if ( !empty( $title_li ) ){
116 $output .= str_replace(array('%id', '%class'), array("linkcat-$category", $class), $category_before);
117 $output .= "$title_before$title_li$title_after\n\t<ul>\n";
118 $output .= _walk_bookmarks($bookmarks, $r);
119 $output .= "\n\t</ul>\n$category_after\n";
121 $output .= _walk_bookmarks($bookmarks, $r);