Ticket #9510: feed-atom.php.patch
| File feed-atom.php.patch, 4.3 KB (added by peaceablewhale, 4 years ago) |
|---|
-
feed-atom.php
5 5 * @package WordPress 6 6 */ 7 7 8 function get_query_id() { 9 global $wp_query; 10 return $wp_query->get_queried_object_id(); 11 } 12 function echo_feed_id($feed_id) { 13 echo "<id>$feed_id</id>\n"; 14 } 15 function echo_feed_subtitle() { 16 $feed_subtitle=get_bloginfo_rss("description"); 17 if(!empty($feed_subtitle)) { 18 echo '<subtitle type="text">'.$feed_subtitle.'</subtitle>'."\n"; 19 } 20 } 21 function echo_feed_links($selfLink,$alternateLink,$repliesLink) { 22 echo '<link rel="self" type="application/atom+xml" href="'.$selfLink.'" />'."\n".'<link rel="alternate" type="text/html" href="'.$alternateLink.'" />'."\n".'<link rel="replies" type="application/atom+xml" href="'.$repliesLink.'" />'."\n"; 23 } 24 8 25 header('Content-Type: ' . feed_content_type('atom') . '; charset=' . get_option('blog_charset'), true); 9 26 $more = 1; 27 $feed_type="atom"; 10 28 11 29 ?> 12 30 <?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?> … … 18 36 <?php do_action('atom_ns'); ?> 19 37 > 20 38 <title type="text"><?php bloginfo_rss('name'); wp_title_rss(); ?></title> 21 <subtitle type="text"><?php bloginfo_rss("description") ?></subtitle> 22 23 <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT')); ?></updated> 39 <?php 40 if(is_category()) { 41 $cat_id=get_query_id(); 42 $canonical_feed_link=get_category_feed_link($cat_id); 43 echo_feed_id($canonical_feed_link); 44 echo_feed_links($canonical_feed_link,get_category_link($cat_id),get_category_comments_feed_link($cat_id,$feed_type)); 45 } 46 elseif(is_tag()) { 47 $tag_id=get_query_id(); 48 $canonical_feed_link=get_tag_feed_link($tag_id); 49 echo_feed_id($canonical_feed_link); 50 echo_feed_links($canonical_feed_link,get_tag_link($tag_id),get_tag_comments_feed_link($tag_id,$feed_type)); 51 } 52 elseif(is_author()) { 53 $author_id=get_query_id(); 54 $canonical_feed_link=get_author_feed_link($author_id); 55 echo_feed_id($canonical_feed_link); 56 echo_feed_links($canonical_feed_link,get_author_posts_url($author_id),get_author_comments_feed_link($author_id,$feed_type)); 57 } 58 elseif(is_date()) { 59 /* to be done */ 60 } 61 elseif(is_search()) { 62 $search_query=get_search_query(); 63 $canonical_feed_link=get_search_feed_link($search_query,$feed_type); 64 echo_feed_id($canonical_feed_link); 65 echo_feed_links($canonical_feed_link,get_search_link($search_query),get_search_comments_feed_link($search_query,$feed_type)); 66 } 67 else { 68 $canonical_feed_link=get_bloginfo('atom_url'); 69 echo_feed_subtitle(); 70 echo_feed_id($canonical_feed_link); 71 echo_feed_links($canonical_feed_link,get_bloginfo_rss('url').'/',get_bloginfo_rss('comments_atom_url')); 72 } 73 ?> 24 74 <?php the_generator( 'atom' ); ?> 25 26 <link rel="alternate" type="text/html" href="<?php bloginfo_rss('home') ?>" />27 <id><?php bloginfo('atom_url'); ?></id>28 <link rel="self" type="application/atom+xml" href="<?php self_link(); ?>" />29 30 75 <?php do_action('atom_head'); ?> 76 <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT')); ?></updated> 31 77 <?php while (have_posts()) : the_post(); ?> 32 78 <entry> 33 79 <author> … … 41 87 <id><?php the_guid(); ?></id> 42 88 <updated><?php echo get_post_modified_time('Y-m-d\TH:i:s\Z', true); ?></updated> 43 89 <published><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></published> 44 <?php the_category_rss( 'atom') ?>90 <?php the_category_rss($feed_type) ?> 45 91 <summary type="<?php html_type_rss(); ?>"><![CDATA[<?php the_excerpt_rss(); ?>]]></summary> 46 92 <?php if ( !get_option('rss_use_excerpt') ) : ?> 47 93 <content type="<?php html_type_rss(); ?>" xml:base="<?php the_permalink_rss() ?>"><![CDATA[<?php the_content('', 0, '') ?>]]></content> … … 49 95 <?php atom_enclosure(); ?> 50 96 <?php do_action('atom_entry'); ?> 51 97 <link rel="replies" type="text/html" href="<?php the_permalink_rss() ?>#comments" thr:count="<?php echo get_comments_number()?>"/> 52 <link rel="replies" type="application/atom+xml" href="<?php echo get_post_comments_feed_link(0, 'atom') ?>" thr:count="<?php echo get_comments_number()?>"/>98 <link rel="replies" type="application/atom+xml" href="<?php echo get_post_comments_feed_link(0,$feed_type) ?>" thr:count="<?php echo get_comments_number()?>"/> 53 99 <thr:total><?php echo get_comments_number()?></thr:total> 54 100 </entry> 55 101 <?php endwhile ; ?>
