From d07a289c1b6bdb250cc85703bc5cde25c001c348 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Fri, 9 Nov 2007 20:12:04 +0000 Subject: [PATCH] get_category_feed_link() from ionfish. fixes #5173 git-svn-id: https://develop.svn.wordpress.org/trunk@6327 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/feed.php | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/wp-includes/feed.php b/wp-includes/feed.php index 6b431b1fab..1fe496c21c 100644 --- a/wp-includes/feed.php +++ b/wp-includes/feed.php @@ -128,17 +128,36 @@ function get_author_rss_link($echo = false, $author_id, $author_nicename) { } -function get_category_rss_link($echo = false, $cat_ID, $category_nicename) { +function get_category_feed_link($cat_id, $feed = 'rss2') { + $cat_id = (int) $cat_id; + + $category = get_category($cat_id); + + if ( empty($category) || is_wp_error($category) ) + return false; + $permalink_structure = get_option('permalink_structure'); if ( '' == $permalink_structure ) { - $link = get_option('home') . '?feed=rss2&cat=' . $cat_ID; + $link = get_option('home') . "?feed=$feed&cat=" . $cat_id; } else { - $link = get_category_link($cat_ID); - $link = trailingslashit($link) . user_trailingslashit('feed', 'feed'); + $link = get_category_link($cat_id); + if( 'rss2' == $feed ) + $feed_link = 'feed'; + else + $feed_link = "feed/$feed"; + + $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed'); } - $link = apply_filters('category_feed_link', $link); + $link = apply_filters('category_feed_link', $link, $feed); + + return $link; +} + + +function get_category_rss_link($echo = false, $cat_ID, $category_nicename) { + $link = get_category_feed_link($cat_ID, $feed = 'rss2'); if ( $echo ) echo $link;