Add query string style API support to wp_get_links(). http://mosquito.wordpress.org/view.php?id=1191

git-svn-id: http://svn.automattic.com/wordpress/trunk@2505 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2005-04-01 05:15:18 +00:00
parent 74328576c6
commit 28da91c8e1
1 changed files with 36 additions and 14 deletions

View File

@ -69,10 +69,15 @@ function wp_get_linksbyname($category) {
** Gets the links associated with category n. ** Gets the links associated with category n.
** Parameters: ** Parameters:
** category (no default) - The category to use. ** category (no default) - The category to use.
** or:
** a query string
**/ **/
function wp_get_links($category) { function wp_get_links($args = '') {
global $wpdb; global $wpdb;
if (!empty($args) && false === strpos($args, '=')) {
// If args is not a query string, it's a category id.
$category = $args;
$cat = $wpdb->get_row("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, " $cat = $wpdb->get_row("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, "
. " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, " . " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, "
. " text_after_all, list_limit FROM $wpdb->linkcategories WHERE cat_id=$category"); . " text_after_all, list_limit FROM $wpdb->linkcategories WHERE cat_id=$category");
@ -85,6 +90,23 @@ function wp_get_links($category) {
bool_from_yn($cat->show_description), bool_from_yn($cat->show_rating), bool_from_yn($cat->show_description), bool_from_yn($cat->show_rating),
$cat->list_limit, bool_from_yn($cat->show_updated)); $cat->list_limit, bool_from_yn($cat->show_updated));
} }
} else {
parse_str($args);
if (! isset($category)) $category = -1;
if (! isset($before)) $before = '';
if (! isset($after)) $after = '<br />';
if (! isset($between)) $between = ' ';
if (! isset($show_images)) $show_images = true;
if (! isset($orderby)) $orderby = 'name';
if (! isset($show_description)) $show_description = true;
if (! isset($show_rating)) $show_rating = false;
if (! isset($limit)) $limit = -1;
if (! isset($show_updated)) $show_updated = 1;
if (! isset($echo)) $echo = true;
get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated, $echo);
}
} // end wp_get_links } // end wp_get_links
/** function get_links() /** function get_links()