WordPress.org

Make WordPress Core

Ticket #9510: feed-atom.php.patch

File feed-atom.php.patch, 4.3 KB (added by peaceablewhale, 5 years ago)

atom:id should be changed as well. This patch replaces the feed-atom.php part of the previous patch.

  • feed-atom.php

     
    55 * @package WordPress 
    66 */ 
    77 
     8function get_query_id() { 
     9        global $wp_query; 
     10        return $wp_query->get_queried_object_id(); 
     11} 
     12function echo_feed_id($feed_id) { 
     13        echo "<id>$feed_id</id>\n"; 
     14} 
     15function 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} 
     21function 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 
    825header('Content-Type: ' . feed_content_type('atom') . '; charset=' . get_option('blog_charset'), true); 
    926$more = 1; 
     27$feed_type="atom"; 
    1028 
    1129?> 
    1230<?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?> 
     
    1836  <?php do_action('atom_ns'); ?> 
    1937 > 
    2038        <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 
     40if(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} 
     46elseif(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} 
     52elseif(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} 
     58elseif(is_date()) { 
     59        /* to be done */ 
     60} 
     61elseif(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} 
     67else { 
     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?> 
    2474        <?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  
    3075        <?php do_action('atom_head'); ?> 
     76        <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT')); ?></updated> 
    3177        <?php while (have_posts()) : the_post(); ?> 
    3278        <entry> 
    3379                <author> 
     
    4187                <id><?php the_guid(); ?></id> 
    4288                <updated><?php echo get_post_modified_time('Y-m-d\TH:i:s\Z', true); ?></updated> 
    4389                <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) ?> 
    4591                <summary type="<?php html_type_rss(); ?>"><![CDATA[<?php the_excerpt_rss(); ?>]]></summary> 
    4692<?php if ( !get_option('rss_use_excerpt') ) : ?> 
    4793                <content type="<?php html_type_rss(); ?>" xml:base="<?php the_permalink_rss() ?>"><![CDATA[<?php the_content('', 0, '') ?>]]></content> 
     
    4995<?php atom_enclosure(); ?> 
    5096<?php do_action('atom_entry'); ?> 
    5197                <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()?>"/> 
    5399                <thr:total><?php echo get_comments_number()?></thr:total> 
    54100        </entry> 
    55101        <?php endwhile ; ?>