Ticket #9236: atom-categories.diff
File atom-categories.diff, 2.9 KB (added by , 16 years ago) |
---|
-
wp-includes/feed.php
321 321 $cat_names = array(); 322 322 323 323 $filter = 'rss'; 324 if ( 'atom' == $type ) 324 325 if ( 'atom' == $type ) { 326 global $wp_rewrite; 325 327 $filter = 'raw'; 328 $url = apply_filters( 'get_bloginfo_rss', get_bloginfo( 'url' ) ); 329 $permastruct['category'] = $wp_rewrite->get_category_permastruct(); 330 $permastruct['tag'] = $wp_rewrite->get_tag_permastruct(); 331 foreach ( array('category' => 'categories', 'tag' => 'tags') as $taxonomy => $var ) { 332 if ( $permastructs[$taxonomy] ) 333 $permastruct = str_replace( "%$taxonomy%", '', $permastructs[$taxonomy] ); 334 else 335 $permastruct = "/$taxonomy/"; 336 $scheme = $url . $permastruct; 337 if ( !empty($$var) ) foreach ( $$var as $term ) { 338 $scheme = sanitize_term_field( 'scheme', $scheme, $term->term_id, $taxonomy, 'attribute' ); 339 $slug = sanitize_term_field( 'slug', $term->slug, $term->term_id, $taxonomy, 'attribute' ); 340 $label = sanitize_term_field( 'name', $term->name, $term->term_id, $taxonomy, 'attribute' ); 341 $the_list .= "\n\t\t" . sprintf( '<category scheme="%1$s" term="%2$s" label="%3$s" />', $scheme, $slug, $label); 342 } 343 } 344 } else { 345 if ( !empty($categories) ) foreach ( (array) $categories as $category ) { 346 $cat_names[] = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter); 347 } 326 348 327 if ( !empty($categories) ) foreach ( (array) $categories as $category) {328 $cat_names[] = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter);329 }349 if ( !empty($tags) ) foreach ( (array) $tags as $tag ) { 350 $cat_names[] = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter); 351 } 330 352 331 if ( !empty($tags) ) foreach ( (array) $tags as $tag ) { 332 $cat_names[] = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter); 353 $cat_names = array_unique($cat_names); 354 355 foreach ( $cat_names as $cat_name ) { 356 if ( 'rdf' == $type ) 357 $the_list .= "\n\t\t<dc:subject><![CDATA[$cat_name]]></dc:subject>\n"; 358 else 359 $the_list .= "\n\t\t<category><![CDATA[" . html_entity_decode( $cat_name ) . "]]></category>\n"; 360 } 333 361 } 334 362 335 $ cat_names = array_unique($cat_names);363 $the_list = trim($the_list) . "\n"; 336 364 337 foreach ( $cat_names as $cat_name ) {338 if ( 'rdf' == $type )339 $the_list .= "\n\t\t<dc:subject><![CDATA[$cat_name]]></dc:subject>\n";340 elseif ( 'atom' == $type )341 $the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', attribute_escape( apply_filters( 'get_bloginfo_rss', get_bloginfo( 'url' ) ) ), attribute_escape( $cat_name ) );342 else343 $the_list .= "\n\t\t<category><![CDATA[" . html_entity_decode( $cat_name ) . "]]></category>\n";344 }345 346 365 return apply_filters('the_category_rss', $the_list, $type); 347 366 } 348 367