WordPress.org

Make WordPress Core

Ticket #1526: wp-atom.patch

File wp-atom.patch, 9.9 KB (added by yngwin, 16 years ago)

new patch correcting Atom support

  • trunk/wp-atom.php

    diff -ru wp-svn/trunk/wp-atom.php wp-work/trunk/wp-atom.php
    old new  
    11<?php
     2// Atom 1.0 feed generator for WordPress
     3// Distributed under the terms of the GNU General Public License v2
    24
    3 if (empty($wp)) {
    4         require_once('wp-config.php');
    5         wp('feed=atom');
     5if (empty($feed)) {
     6        $blog = 1;
     7        $feed = 'atom';
     8        $doing_rss = 1;
     9        require('wp-blog-header.php');
    610}
    711
    812header('Content-type: application/atom+xml; charset=' . get_settings('blog_charset'), true);
    913$more = 1;
    10 
    1114?>
    12 <?php echo '<?xml version="1.0" encoding="'.get_settings('blog_charset').'"?'.'>'; ?>
    13 <feed version="0.3"
    14   xmlns="http://purl.org/atom/ns#"
    15   xmlns:dc="http://purl.org/dc/elements/1.1/"
    16   xml:lang="<?php echo get_option('rss_language'); ?>"
    17   <?php do_action('atom_ns'); ?>
    18   >
    19         <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>
     15<?php echo '<?xml version="1.0" encoding="'.get_settings('blog_charset').'"?'.'>'."\n"; ?>
     16<feed xmlns="http://www.w3.org/2005/Atom"
     17      xml:lang="<?php echo get_option('rss_language'); ?>"
     18      <?php do_action('atom_ns'); ?>>
     19        <title><?php bloginfo_rss('name'); ?></title>
     20        <subtitle><?php bloginfo_rss('description'); ?></subtitle>
     21        <id><?php bloginfo('url'); ?>/</id>
     22        <link rel="self" type="application/atom+xml" href="<?php bloginfo('atom_url'); ?>"/>
     23        <link rel="alternate" type="<?php bloginfo('html_type'); ?>" href="<?php bloginfo_rss('home'); ?>/"/>
     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</generator>
    2527        <?php do_action('atom_head'); ?>
    26         <?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>
     28<?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>
    2729        <entry>
    28                 <author>
    29                         <name><?php the_author() ?></name>
     30                <author>
     31                        <name><?php the_author(); ?></name>
    3032                </author>
    31                 <title type="text/html" mode="escaped"><![CDATA[<?php the_title_rss() ?>]]></title>
    32                 <link rel="alternate" type="text/html" href="<?php permalink_single_rss() ?>" />
    33                 <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>
     33                <title type="html"><![CDATA[ <?php the_title_rss(); ?> ]]></title>
     34                <link rel="alternate" type="<?php bloginfo('html_type'); ?>" href="<?php permalink_single_rss(); ?>"/>
     35                <id><?php permalink_single_rss(); ?></id>
     36                <published><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></published>
     37                <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z',$post->post_modified_gmt); ?></updated>
     38<?php
     39        $categories_path = get_category_link(0);
     40        $categories = get_the_category();
     41        foreach ($categories as $cat) { ?>
     42                <category scheme="<?php echo $categories_path; ?>"
     43                          term="<?php $foo = "/" . str_replace('/','\/',$categories_path) . "/";
     44                                                        echo preg_replace($foo,'',get_category_link($cat->cat_ID)); ?>"
     45                          label="<?php echo $cat->cat_name; ?>"/>
     46<?php } ?>
     47                <summary type="html">
     48                        <![CDATA[ <?php the_excerpt_rss(); ?> ]]>
     49                </summary>
    3850<?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>
     51                <content type="html">
     52                        <![CDATA[ <?php the_content('', 0, '') ?> ]]>
     53                </content>
     54                <?php atom_enclosure(); ?>
     55                <?php do_action('atom_entry'); ?>
    4056<?php endif; ?>
    41 <?php rss_enclosure(); ?>
    42 <?php do_action('atom_entry'); ?>
    4357        </entry>
    44         <?php $items_count++; if (($items_count == get_settings('posts_per_rss')) && empty($m)) { break; } } } ?>
    45 </feed>
     58<?php $items_count++; if (($items_count == get_settings('posts_per_rss')) && empty($m)) { break; } } } ?>
     59</feed>
     60 No newline at end of file
  • trunk/wp-content/themes/classic/header.php

    diff -ru wp-svn/trunk/wp-content/themes/classic/header.php wp-work/trunk/wp-content/themes/classic/header.php
    old new  
    55        <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
    66
    77        <title><?php bloginfo('name'); ?><?php wp_title(); ?></title>
    8        
     8
    99        <meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats please -->
    1010
    1111        <style type="text/css" media="screen">
     
    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'); ?>" />
    18        
     17        <link rel="alternate" type="application/atom+xml" title="Atom 1.0 feed" href="<?php bloginfo('atom_url'); ?>" />
     18
    1919        <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
    2020    <?php wp_get_archives('type=monthly&format=link'); ?>
    2121        <?php //comments_popup_script(); // off by default ?>
  • trunk/wp-content/themes/default/header.php

    diff -ru wp-svn/trunk/wp-content/themes/default/header.php wp-work/trunk/wp-content/themes/default/header.php
    old new  
    99<meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats -->
    1010
    1111<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
     12<link rel="alternate" type="application/atom+xml" title="<?php bloginfo('name'); ?> Atom Feed" href="<?php bloginfo('atom_url'); ?>" />
    1213<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />
    1314<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
    1415
     
    1617/*      To accomodate differing install paths of WordPress, images are referred only here,
    1718        and not in the wp-layout.css file. If you prefer to use only CSS for colors and what
    1819        not, then go right ahead and delete the following lines, and the image files. */
    19                
    20         body { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbgcolor.jpg"); }       
     20
     21        body { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbgcolor.jpg"); }
    2122<?php /* Checks to see whether it needs a sidebar or not */ if ((! $withcomments) && (! is_single())) { ?>
    2223        #page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbg.jpg") repeat-y top; border: none; }
    2324<?php } else { // No sidebar ?>
    24         #page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbgwide.jpg") repeat-y top; border: none; } 
     25        #page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbgwide.jpg") repeat-y top; border: none; }
    2526<?php } ?>
    2627        #header { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickheader.jpg") no-repeat bottom center; }
    2728        #footer { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickfooter.jpg") no-repeat bottom; border: none;}
    2829
    2930/*      Because the template is slightly different, size-wise, with images, this needs to be set here
    3031        If you don't want to use the template's images, you can also delete the following two lines. */
    31                
     32
    3233        #header         { margin: 0 !important; margin: 0 0 0 1px; padding: 1px; height: 198px; width: 758px; }
    33         #headerimg      { margin: 7px 9px 0; height: 192px; width: 740px; } 
     34        #headerimg      { margin: 7px 9px 0; height: 192px; width: 740px; }
    3435
    3536/*      To ease the insertion of a personal header image, I have done it in such a way,
    3637        that you simply drop in an image called 'personalheader.jpg' into your /images/
  • trunk/wp-includes/feed-functions.php

    diff -ru wp-svn/trunk/wp-includes/feed-functions.php wp-work/trunk/wp-includes/feed-functions.php
    old new  
    9999                                 $link = get_author_link(0, $author_id, $author_nicename);
    100100                                 $link = $link . "feed/";
    101101       }
    102                          
     102
    103103                         $link = apply_filters('author_feed_link', $link);
    104104
    105105       if ($echo) echo $link;
     
    142142
    143143        $custom_fields = get_post_custom();
    144144        if( is_array( $custom_fields ) ) {
    145                 while( list( $key, $val ) = each( $custom_fields ) ) { 
     145                while( list( $key, $val ) = each( $custom_fields ) ) {
    146146                        if( $key == 'enclosure' ) {
    147147                                if (is_array($val)) {
    148148                                        foreach($val as $enc) {
     
    155155        }
    156156}
    157157
     158function atom_enclosure() {
     159        global $id, $post;
     160        if (!empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password)) return;
     161
     162        $custom_fields = get_post_custom();
     163        if( is_array( $custom_fields ) ) {
     164                while( list( $key, $val ) = each( $custom_fields ) ) {
     165                        if( $key == 'enclosure' ) {
     166                                if (is_array($val)) {
     167                                        foreach($val as $enc) {
     168                                                $enclosure = split( "\n", $enc );
     169                                                print "<link rel=\"enclosure\" href=\"".trim( htmlspecialchars($enclosure[ 0 ]) )."\" length=\"".trim( $enclosure[ 1 ] )."\" type=\"".trim( $enclosure[ 2 ] )."\"/>\n";
     170                                        }
     171                                }
     172                        }
     173                }
     174        }
     175}
    158176?>
     177 No newline at end of file