From 395ee1acad6d616d1c08fb1b2c247f7454340ad8 Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 29 Aug 2007 21:10:20 +0000 Subject: [PATCH] Include tags in feeds. fixes #4537 git-svn-id: http://svn.automattic.com/wordpress/trunk@5979 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/default-filters.php | 6 ++++++ wp-includes/feed.php | 23 ++++++++++++++++++++--- wp-includes/taxonomy.php | 5 ++++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index 39911e96f3..2cc7840051 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -56,6 +56,12 @@ foreach ( $filters as $filter ) { add_filter($filter, 'wp_specialchars'); } +// Format for RSS +$filters = array('term_name_rss'); +foreach ( $filters as $filter ) { + add_filter($filter, 'convert_chars'); +} + // Display filters add_filter('the_title', 'wptexturize'); add_filter('the_title', 'convert_chars'); diff --git a/wp-includes/feed.php b/wp-includes/feed.php index a45dc27769..3784adb04f 100644 --- a/wp-includes/feed.php +++ b/wp-includes/feed.php @@ -146,17 +146,34 @@ function get_category_rss_link($echo = false, $cat_ID, $category_nicename) { function get_the_category_rss($type = 'rss') { $categories = get_the_category(); + $tags = get_the_tags(); $home = get_bloginfo_rss('home'); $the_list = ''; - foreach ( (array) $categories as $category ) { - $cat_name = convert_chars($category->name); + $cat_names = array(); + + $filter = 'rss'; + if ( 'atom' == $type ) + $filter = 'raw'; + + if ( !empty($categories) ) foreach ( (array) $categories as $category ) { + $cat_names[] = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter); + } + + if ( !empty($tags) ) foreach ( (array) $tags as $tag ) { + $cat_names[] = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter); + } + + $cat_names = array_unique($cat_names); + + foreach ( $cat_names as $cat_name ) { if ( 'rdf' == $type ) $the_list .= "\n\t\t\n"; if ( 'atom' == $type ) - $the_list .= sprintf( '', attribute_escape( apply_filters( 'get_bloginfo_rss', get_bloginfo( 'url' ) ) ), attribute_escape( $category->name ) ); + $the_list .= sprintf( '', attribute_escape( apply_filters( 'get_bloginfo_rss', get_bloginfo( 'url' ) ) ), attribute_escape( $cat_name ) ); else $the_list .= "\n\t\t\n"; } + return apply_filters('the_category_rss', $the_list, $type); } diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index ba136ad72a..931b0973e9 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -594,7 +594,10 @@ function sanitize_term_field($field, $value, $term_id, $taxonomy, $context) { $value = attribute_escape($value); } else if ( 'db' == $context ) { $value = apply_filters("pre_term_$field", $value, $taxonomy); - $value = apply_filters("pre_${taxonomy}_$field", $value); + $value = apply_filters("pre_${taxonomy}_$field", $value); + } else if ( 'rss' == $context ) { + $value = apply_filters("term_${field}_rss", $value, $taxonomy); + $value = apply_filters("${taxonomy}_$field_rss", $value); } else { // Use display filters by default. $value = apply_filters("term_$field", $value, $term_id, $taxonomy, $context);