Ticket #1526: atom.diff

File atom.diff, 6.4 KB (added by error, 7 years ago)

Atom 1.0 support - CORRECTED

  • wp-includes/feed-functions.php

     
    129129        $category->cat_name = convert_chars($category->cat_name); 
    130130        if ('rdf' == $type) { 
    131131            $the_list .= "\n\t<dc:subject>$category->cat_name</dc:subject>"; 
     132        } elseif ('atom' == $type) { 
     133            $the_list .= "\n\t<category term=\"$category->cat_name\" />"; 
    132134        } else { 
    133135            $the_list .= "\n\t<category>$category->cat_name</category>"; 
    134136        } 
     
    155157        } 
    156158} 
    157159 
    158 ?> 
    159  No newline at end of file 
     160function atom_enclosure() { 
     161        global $id, $post; 
     162        if (!empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password)) return; 
     163 
     164        $custom_fields = get_post_custom(); 
     165        if( is_array( $custom_fields ) ) { 
     166                while( list( $key, $val ) = each( $custom_fields ) ) {  
     167                        if( $key == 'enclosure' ) { 
     168                                if (is_array($val)) { 
     169                                        foreach($val as $enc) { 
     170                                                $enclosure = split( "\n", $enc ); 
     171                                                print "<link rel=\"enclosure\" length=\"".trim( $enclosure[ 1 ] )."\" type=\"".trim( $enclosure[ 2 ] )."\" href=\"".trim( htmlspecialchars($enclosure[ 0 ]) )."\"/>\n"; 
     172                                        } 
     173                                } 
     174                        } 
     175                } 
     176        } 
     177} 
     178 
     179?> 
  • wp-content/themes/classic/header.php

     
    1414 
    1515        <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" /> 
    1616        <link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" /> 
    17         <link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" /> 
     17        <link rel="alternate" type="application/atom+xml" title="Atom 1.0" href="<?php bloginfo('atom_url'); ?>" /> 
    1818         
    1919        <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" /> 
    2020    <?php wp_get_archives('type=monthly&format=link'); ?> 
  • wp-content/themes/default/header.php

     
    1010 
    1111<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" /> 
    1212<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" /> 
     13<link rel="alternate" type="application/atom+xml" title="<?php bloginfo('name'); ?> Atom Feed" href="<?php bloginfo('atom_url'); ?>" /> 
    1314<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" /> 
    1415 
    1516<style type="text/css" media="screen"> 
  • wp-atom.php

     
    1010 
    1111?> 
    1212<?php echo '<?xml version="1.0" encoding="'.get_settings('blog_charset').'"?'.'>'; ?> 
    13 <feed version="0.3" 
    14   xmlns="http://purl.org/atom/ns#" 
     13<feed xmlns="http://www.w3.org/2005/Atom" 
    1514  xmlns:dc="http://purl.org/dc/elements/1.1/" 
    1615  xml:lang="<?php echo get_option('rss_language'); ?>" 
    1716  <?php do_action('atom_ns'); ?> 
    1817  > 
     18        <id><?php bloginfo_rss('atom_url') ?></id> 
    1919        <title><?php bloginfo_rss('name') ?></title> 
    20         <link rel="alternate" type="text/html" href="<?php bloginfo_rss('home') ?>" /> 
    21         <tagline><?php bloginfo_rss("description") ?></tagline> 
    22         <modified><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></modified> 
    23         <copyright>Copyright <?php echo mysql2date('Y', get_lastpostdate('blog'), 0); ?></copyright> 
    24         <generator url="http://wordpress.org/" version="<?php bloginfo_rss('version'); ?>">WordPress</generator> 
     20        <link rel="self" type="application/atom+xml" href="<?php bloginfo_rss('atom_url') ?>" /> 
     21        <link rel="alternate" type="application/rss+xml" href="<?php bloginfo_rss('rss2_url') ?>" /> 
     22        <link rel="alternate" type="text/html"<?php if (defined('WPLANG') && strcmp(constant('WPLANG'), '')) echo ' hreflang="' . WPLANG . '"';?> href="<?php bloginfo_rss('home') ?>" /> 
     23        <subtitle><?php bloginfo_rss("description") ?></subtitle> 
     24        <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></updated> 
     25        <rights>Copyright <?php echo mysql2date('Y', get_lastpostdate('blog'), 0); ?></rights> 
     26        <generator uri="http://wordpress.org/" version="<?php bloginfo_rss('version'); ?>">WordPress <?php bloginfo_rss('version'); ?></generator> 
    2527        <?php do_action('atom_head'); ?> 
    2628        <?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?> 
    2729        <entry> 
    2830                <author> 
    2931                        <name><?php the_author() ?></name> 
    3032                </author> 
    31                 <title type="text/html" mode="escaped"><![CDATA[<?php the_title_rss() ?>]]></title> 
     33        <title type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><?php the_title_rss() ?></div></title> 
    3234                <link rel="alternate" type="text/html" href="<?php permalink_single_rss() ?>" /> 
    3335                <id><?php the_guid(); ?></id> 
    34                 <modified><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></modified> 
    35                 <issued><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></issued> 
    36                 <?php the_category_rss('rdf') ?>  
    37                 <summary type="text/plain" mode="escaped"><![CDATA[<?php the_excerpt_rss(); ?>]]></summary> 
    38 <?php if ( !get_settings('rss_use_excerpt') ) : ?> 
    39                 <content type="<?php bloginfo('html_type'); ?>" mode="escaped" xml:base="<?php permalink_single_rss() ?>"><![CDATA[<?php the_content('', 0, '') ?>]]></content> 
     36                <updated><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></updated> 
     37                <published><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></published> 
     38                <?php the_category_rss('atom') ?>  
     39                <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><?php the_excerpt_rss(); ?></div></summary> 
     40<?php if (!get_settings('rss_use_excerpt') || strstr($_SERVER['HTTP_USER_AGENT'], "Technoratibot") !== FALSE): ?> 
     41<?php // FIXME: Ignore bloginfo('html_type') since it's deliberately set incorrectly; WordPress currently generates ONLY XHTML ?> 
     42                <content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><?php the_content('', 0, '') ?></div></content> 
    4043<?php endif; ?> 
    41 <?php rss_enclosure(); ?> 
     44<?php atom_enclosure(); ?> 
    4245<?php do_action('atom_entry'); ?> 
    4346        </entry> 
    4447        <?php $items_count++; if (($items_count == get_settings('posts_per_rss')) && empty($m)) { break; } } } ?>