Advertisements

wp_list_bookmarks

Definition:
function wp_list_bookmarks($args = '') {}

Retrieve or echo all of the bookmarks.
List of default arguments are as follows: ‘orderby’ – Default is ‘name’ (string). How to order the links by. String is based off of the bookmark scheme. ‘order’ – Default is ‘ASC’ (string). Either ‘ASC’ or ‘DESC’. Orders in either ascending or descending order. ‘limit’ – Default is -1 (integer) or show all. The amount of bookmarks to display. ‘category’ – Default is empty string (string). Include the links in what category ID(s). ‘category_name’ – Default is empty string (string). Get links by category name. ‘hide_invisible’ – Default is 1 (integer). Whether to show (default) or hide links marked as ‘invisible’. ‘show_updated’ – Default is 0 (integer). Will show the time of when the bookmark was last updated. ‘echo’ – Default is 1 (integer). Whether to echo (default) or return the formatted bookmarks. ‘categorize’ – Default is 1 (integer). Whether to show links listed by category (default) or show links in one column. ‘show_description’ – Default is 0 (integer). Whether to show the description of the bookmark.

Parameters

  • string|array $args: Optional. Overwrite the defaults of the function

Return values

returns:Will only return if echo option is set to not echo. Default is not return anything.

Defined filters

  • link_category
    apply_filters( "link_category", $cat->name )
  • wp_list_bookmarks
    apply_filters( 'wp_list_bookmarks', $output )

Source code

function wp_list_bookmarks($args = '') {

	$defaults = array(

		'orderby' => 'name', 'order' => 'ASC',

		'limit' => -1, 'category' => '', 'exclude_category' => '',

		'category_name' => '', 'hide_invisible' => 1,

		'show_updated' => 0, 'echo' => 1,

		'categorize' => 1, 'title_li' => __('Bookmarks'),

		'title_before' => '<h2>', 'title_after' => '</h2>',

		'category_orderby' => 'name', 'category_order' => 'ASC',

		'class' => 'linkcat', 'category_before' => '<li id="%id" class="%class">',

		'category_after' => '</li>'

	);



	$r = wp_parse_args( $args, $defaults );

	extract( $r, EXTR_SKIP );



	$output = '';



	if ( $categorize ) {

		//Split the bookmarks into ul's for each category

		$cats = get_terms('link_category', array('name__like' => $category_name, 'include' => $category, 'exclude' => $exclude_category, 'orderby' => $category_orderby, 'order' => $category_order, 'hierarchical' => 0));



		foreach ( (array) $cats as $cat ) {

			$params = array_merge($r, array('category'=>$cat->term_id));

			$bookmarks = get_bookmarks($params);

			if ( empty($bookmarks) )

				continue;

			$output .= str_replace(array('%id', '%class'), array("linkcat-$cat->term_id", $class), $category_before);

			$catname = apply_filters( "link_category", $cat->name );

			$output .= "$title_before$catname$title_after\n\t<ul class='xoxo blogroll'>\n";

			$output .= _walk_bookmarks($bookmarks, $r);

			$output .= "\n\t</ul>\n$category_after\n";

		}

	} else {

		//output one single list using title_li for the title

		$bookmarks = get_bookmarks($r);



		if ( !empty($bookmarks) ) {

			if ( !empty( $title_li ) ){

				$output .= str_replace(array('%id', '%class'), array("linkcat-$category", $class), $category_before);

				$output .= "$title_before$title_li$title_after\n\t<ul class='xoxo blogroll'>\n";

				$output .= _walk_bookmarks($bookmarks, $r);

				$output .= "\n\t</ul>\n$category_after\n";

			} else {

				$output .= _walk_bookmarks($bookmarks, $r);

			}

		}

	}



	$output = apply_filters( 'wp_list_bookmarks', $output );



	if ( !$echo )

		return $output;

	echo $output;

}

3853

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: