Include tags in feeds. fixes #4537

git-svn-id: https://develop.svn.wordpress.org/trunk@5979 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2007-08-29 21:10:20 +00:00
parent f6b019c8b6
commit 3910be3880
3 changed files with 30 additions and 4 deletions

View File

@ -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');

View File

@ -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<dc:subject><![CDATA[$cat_name]]></dc:subject>\n";
if ( 'atom' == $type )
$the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', attribute_escape( apply_filters( 'get_bloginfo_rss', get_bloginfo( 'url' ) ) ), attribute_escape( $category->name ) );
$the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', attribute_escape( apply_filters( 'get_bloginfo_rss', get_bloginfo( 'url' ) ) ), attribute_escape( $cat_name ) );
else
$the_list .= "\n\t\t<category><![CDATA[$cat_name]]></category>\n";
}
return apply_filters('the_category_rss', $the_list, $type);
}

View File

@ -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);