All pastes #949585 Raw Edit

Unnamed

public php v1 · immutable
·published 2008-03-19 22:00 UTC
rendered paste body
/* * function get_links_list() * * added by Dougal * * Output a list of all links, listed by category, using the * settings in $wpdb->linkcategories and output it as a nested * HTML unordered list. * * Parameters: *   order (default 'name')  - Sort link categories by 'name' or 'id' *   hide_if_empty (default true)  - Supress listing empty link categories */function get_links_list($order = 'name', $hide_if_empty = 'obsolete') {	$order = strtolower($order);	// Handle link category sorting	$direction = 'ASC';	if ( '_' == substr($order,0,1) ) {		$direction = 'DESC';		$order = substr($order,1);	}	if ( !isset($direction) )		$direction = '';	$cats = get_categories("type=link&orderby=$order&order=$direction&hierarchical=0");	// Display each category	if ( $cats ) {		foreach ( (array) $cats as $cat ) {			// Handle each category.			// Display the category name			echo '  <li id="linkcat-' . $cat->term_id . '" class="linkcat"><h2>' . apply_filters('link_category', $cat->name ) . "</h2>\n\t<ul>\n";			// Call get_links() with all the appropriate params			get_links($cat->term_id, '<li>', "</li>", "\n", true, 'name', false);			// Close the last category			echo "\n\t</ul>\n</li>\n";		}	}}