From a43e37b8a1073ceb9a24364376851f33b0aa4a07 Mon Sep 17 00:00:00 2001 From: ryan Date: Sat, 1 Sep 2007 04:43:27 +0000 Subject: [PATCH] get_tag() and get_tag_feed_link() git-svn-id: http://svn.automattic.com/wordpress/trunk@6000 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/category.php | 4 ++++ wp-includes/feed.php | 28 +++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/wp-includes/category.php b/wp-includes/category.php index e4b77d08e2..92ab6d9d8b 100644 --- a/wp-includes/category.php +++ b/wp-includes/category.php @@ -148,6 +148,10 @@ function &get_tags($args = '') { return $tags; } +function &get_tag($tag, $output = OBJECT, $filter = 'raw') { + return get_term($tag, 'post_tag', $output, $filter); +} + // // Cache // diff --git a/wp-includes/feed.php b/wp-includes/feed.php index 3784adb04f..ee180ab861 100644 --- a/wp-includes/feed.php +++ b/wp-includes/feed.php @@ -182,6 +182,32 @@ function the_category_rss($type = 'rss') { echo get_the_category_rss($type); } +function get_tag_feed_link($tag_id, $feed = 'rss2') { + $tag_id = (int) $tag_id; + + $tag = get_tag($tag_id); + + if ( empty($tag) || is_wp_error($tag) ) + return false; + + $permalink_structure = get_option('permalink_structure'); + + if ( '' == $permalink_structure ) { + $link = get_option('home') . "?feed=$feed&tag=" . $tag->slug; + } else { + $link = get_tag_link($tag->term_id); + if ( 'rss2' == $feed ) + $feed_link = 'feed'; + else + $feed_link = "feed/$feed"; + $link = $link . user_trailingslashit($feed_link, 'feed'); + } + + $link = apply_filters('tag_feed_link', $link, $feed); + + return $link; +} + function html_type_rss() { $type = get_bloginfo('html_type'); if (strpos($type, 'xhtml') !== false) @@ -222,4 +248,4 @@ function atom_enclosure() { } } -?> \ No newline at end of file +?>