Skip to content

Commit

Permalink
Relocate feed templates to wp-includes. fixes #3846
Browse files Browse the repository at this point in the history
git-svn-id: http://core.svn.wordpress.org/trunk@4927 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
ryan committed Feb 23, 2007
1 parent b0b47ee commit 0fa6741
Show file tree
Hide file tree
Showing 11 changed files with 275 additions and 255 deletions.
45 changes: 2 additions & 43 deletions wp-atom.php
Expand Up @@ -5,47 +5,6 @@
wp('feed=atom');
}

header('Content-type: application/atom+xml; charset=' . get_option('blog_charset'), true);
$more = 1;
require (ABSPATH . WPINC . '/feed-atom.php');

?>
<?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
<feed
xmlns="http://www.w3.org/2005/Atom"
xmlns:thr="http://purl.org/syndication/thread/1.0"
xml:lang="<?php echo get_option('rss_language'); ?>"
xml:base="<?php bloginfo_rss('home') ?>/wp-atom.php"
<?php do_action('atom_ns'); ?>
>
<title type="text"><?php bloginfo_rss('name') ?></title>
<subtitle type="text"><?php bloginfo_rss("description") ?></subtitle>

<updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT')); ?></updated>
<generator uri="http://wordpress.org/" version="<?php bloginfo_rss('version'); ?>">WordPress</generator>

<link rel="alternate" type="text/html" href="<?php bloginfo_rss('home') ?>" />
<id><?php bloginfo('atom_url'); ?></id>
<link rel="self" type="application/atom+xml" href="<?php bloginfo('atom_url'); ?>" />

<?php do_action('atom_head'); ?>
<?php while (have_posts()) : the_post(); ?>
<entry>
<author>
<name><?php the_author() ?></name>
<uri><?php the_author_url()?></uri>
</author>
<title type="<?php html_type_rss(); ?>"><![CDATA[<?php the_title_rss() ?>]]></title>
<link rel="alternate" type="text/html" href="<?php permalink_single_rss() ?>" />
<id><?php the_guid(); ?></id>
<updated><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></updated>
<published><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></published>
<?php the_category_rss('atom') ?>
<summary type="<?php html_type_rss(); ?>"><![CDATA[<?php the_excerpt_rss(); ?>]]></summary>
<?php if ( !get_option('rss_use_excerpt') ) : ?>
<content type="<?php html_type_rss(); ?>" xml:base="<?php permalink_single_rss() ?>"><![CDATA[<?php the_content('', 0, '') ?>]]></content>
<?php endif; ?>
<?php rss_enclosure(); ?>
<?php do_action('atom_entry'); ?>
</entry>
<?php endwhile ; ?>
</feed>
?>
83 changes: 2 additions & 81 deletions wp-commentsrss2.php
Expand Up @@ -5,85 +5,6 @@
wp('feed=rss2&withcomments=1');
}

header('Content-type: text/xml;charset=' . get_option('blog_charset'), true);
require (ABSPATH . WPINC . '/feed-rss2-comments.php');

echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>';
?>
<!-- generator="wordpress/<?php echo $wp_version ?>" -->
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<?php
$i = 0;
if (have_posts()) :
while (have_posts()) : the_post();
if ($i < 1) {
$i++;
?>
<title><?php if (is_single() || is_page() ) { printf(__('Comments on: %s'), get_the_title_rss()); } else { printf(__('Comments for %s'), get_bloginfo_rss("name")); } ?></title>
<link><?php (is_single()) ? permalink_single_rss() : bloginfo_rss("url") ?></link>
<description><?php bloginfo_rss("description") ?></description>
<pubDate><?php echo gmdate('r'); ?></pubDate>
<generator>http://wordpress.org/?v=<?php echo $wp_version ?></generator>

<?php
if (is_single() || is_page()) {
$comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email,
comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID,
$wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments
LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE comment_post_ID = '" . get_the_ID() . "'
AND $wpdb->comments.comment_approved = '1' AND $wpdb->posts.post_status = 'publish'
AND post_date_gmt < '" . gmdate("Y-m-d H:i:59") . "'
ORDER BY comment_date_gmt ASC" );
} else { // if no post id passed in, we'll just ue the last 10 comments.
$comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email,
comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID,
$wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments
LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE $wpdb->posts.post_status = 'publish'
AND $wpdb->comments.comment_approved = '1' AND post_date_gmt < '" . gmdate("Y-m-d H:i:s") . "'
ORDER BY comment_date_gmt DESC LIMIT " . get_option('posts_per_rss') );
}
// this line is WordPress' motor, do not delete it.
if ($comments) {
foreach ($comments as $comment) {
$GLOBALS['comment'] =& $comment;
// Some plugins may need to know the metadata
// associated with this comment's post:
get_post_custom($comment->comment_post_ID);
?>
<item>
<title><?php if ( ! (is_single() || is_page()) ) {
$title = get_the_title($comment->comment_post_ID);
$title = apply_filters('the_title', $title);
$title = apply_filters('the_title_rss', $title);
printf(__('Comment on %1$s by %2$s'), $title, get_comment_author_rss());
} else {
printf(__('By: %s'), get_comment_author_rss());
} ?></title>
<link><?php comment_link() ?></link>
<author><?php echo get_comment_author_rss() ?></author>
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_comment_time('Y-m-d H:i:s', true), false); ?></pubDate>
<guid><?php comment_link() ?></guid>
<?php
if (!empty($comment->post_password) && $_COOKIE['wp-postpass'] != $comment->post_password) {
?>
<description><?php _e('Protected Comments: Please enter your password to view comments.'); ?></description>
<content:encoded><![CDATA[<?php echo get_the_password_form() ?>]]></content:encoded>
<?php
} else {
?>
<description><?php comment_text_rss() ?></description>
<content:encoded><![CDATA[<?php comment_text() ?>]]></content:encoded>
<?php
} // close check for password
do_action('commentrss2_item', $comment->comment_ID, $comment->comment_post_ID);
?>
</item>
<?php
}
}
}
endwhile; endif;
?>
</channel>
</rss>
?>
45 changes: 45 additions & 0 deletions wp-includes/feed-atom.php
@@ -0,0 +1,45 @@
<?php
header('Content-type: application/atom+xml; charset=' . get_option('blog_charset'), true);
$more = 1;

?>
<?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
<feed
xmlns="http://www.w3.org/2005/Atom"
xmlns:thr="http://purl.org/syndication/thread/1.0"
xml:lang="<?php echo get_option('rss_language'); ?>"
xml:base="<?php bloginfo_rss('home') ?>/wp-atom.php"
<?php do_action('atom_ns'); ?>
>
<title type="text"><?php bloginfo_rss('name') ?></title>
<subtitle type="text"><?php bloginfo_rss("description") ?></subtitle>

<updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT')); ?></updated>
<generator uri="http://wordpress.org/" version="<?php bloginfo_rss('version'); ?>">WordPress</generator>

<link rel="alternate" type="text/html" href="<?php bloginfo_rss('home') ?>" />
<id><?php bloginfo('atom_url'); ?></id>
<link rel="self" type="application/atom+xml" href="<?php bloginfo('atom_url'); ?>" />

<?php do_action('atom_head'); ?>
<?php while (have_posts()) : the_post(); ?>
<entry>
<author>
<name><?php the_author() ?></name>
<uri><?php the_author_url()?></uri>
</author>
<title type="<?php html_type_rss(); ?>"><![CDATA[<?php the_title_rss() ?>]]></title>
<link rel="alternate" type="text/html" href="<?php permalink_single_rss() ?>" />
<id><?php the_guid(); ?></id>
<updated><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></updated>
<published><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></published>
<?php the_category_rss('atom') ?>
<summary type="<?php html_type_rss(); ?>"><![CDATA[<?php the_excerpt_rss(); ?>]]></summary>
<?php if ( !get_option('rss_use_excerpt') ) : ?>
<content type="<?php html_type_rss(); ?>" xml:base="<?php permalink_single_rss() ?>"><![CDATA[<?php the_content('', 0, '') ?>]]></content>
<?php endif; ?>
<?php rss_enclosure(); ?>
<?php do_action('atom_entry'); ?>
</entry>
<?php endwhile ; ?>
</feed>
51 changes: 51 additions & 0 deletions wp-includes/feed-rdf.php
@@ -0,0 +1,51 @@
<?php
header('Content-type: application/rdf+xml; charset=' . get_option('blog_charset'), true);
$more = 1;

?>
<?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
<!-- generator="wordpress/<?php echo $wp_version ?>" -->
<rdf:RDF
xmlns="http://purl.org/rss/1.0/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:admin="http://webns.net/mvcb/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
<?php do_action('rdf_ns'); ?>
>
<channel rdf:about="<?php bloginfo_rss("url") ?>">
<title><?php bloginfo_rss('name') ?></title>
<link><?php bloginfo_rss('url') ?></link>
<description><?php bloginfo_rss('description') ?></description>
<dc:date><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></dc:date>
<admin:generatorAgent rdf:resource="http://wordpress.org/?v=<?php echo $wp_version ?>"/>
<sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>1</sy:updateFrequency>
<sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
<?php do_action('rdf_header'); ?>
<items>
<rdf:Seq>
<?php while (have_posts()): the_post(); ?>
<rdf:li rdf:resource="<?php permalink_single_rss() ?>"/>
<?php endwhile; ?>
</rdf:Seq>
</items>
</channel>
<?php rewind_posts(); while (have_posts()): the_post(); ?>
<item rdf:about="<?php permalink_single_rss() ?>">
<title><?php the_title_rss() ?></title>
<link><?php permalink_single_rss() ?></link>
<dc:date><?php echo mysql2date('Y-m-d\TH:i:s\Z', $post->post_date_gmt, false); ?></dc:date>
<dc:creator><?php the_author() ?></dc:creator>
<?php the_category_rss('rdf') ?>
<?php if (get_option('rss_use_excerpt')) : ?>
<description><?php the_excerpt_rss() ?></description>
<?php else : ?>
<description><?php the_content_rss('', 0, '', get_option('rss_excerpt_length'), 2) ?></description>
<content:encoded><![CDATA[<?php the_content('', 0, '') ?>]]></content:encoded>
<?php endif; ?>
<?php do_action('rdf_item'); ?>
</item>
<?php endwhile; ?>
</rdf:RDF>
31 changes: 31 additions & 0 deletions wp-includes/feed-rss.php
@@ -0,0 +1,31 @@
<?php
header('Content-type: text/xml; charset=' . get_option('blog_charset'), true);
$more = 1;

?>
<?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
<!-- generator="wordpress/<?php echo $wp_version ?>" -->
<rss version="0.92">
<channel>
<title><?php bloginfo_rss('name') ?></title>
<link><?php bloginfo_rss('url') ?></link>
<description><?php bloginfo_rss('description') ?></description>
<lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>
<docs>http://backend.userland.com/rss092</docs>
<language><?php echo get_option('rss_language'); ?></language>
<?php do_action('rss_head'); ?>

<?php while (have_posts()) : the_post(); ?>
<item>
<title><?php the_title_rss() ?></title>
<?php if (get_option('rss_use_excerpt')) { ?>
<description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
<?php } else { // use content ?>
<description><?php the_content_rss('', 0, '', get_option('rss_excerpt_length')) ?></description>
<?php } ?>
<link><?php permalink_single_rss() ?></link>
<?php do_action('rss_item'); ?>
</item>
<?php endwhile; ?>
</channel>
</rss>
83 changes: 83 additions & 0 deletions wp-includes/feed-rss2-comments.php
@@ -0,0 +1,83 @@
<?php
header('Content-type: text/xml;charset=' . get_option('blog_charset'), true);

echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>';
?>
<!-- generator="wordpress/<?php echo $wp_version ?>" -->
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<?php
$i = 0;
if (have_posts()) :
while (have_posts()) : the_post();
if ($i < 1) {
$i++;
?>
<title><?php if (is_single() || is_page() ) { printf(__('Comments on: %s'), get_the_title_rss()); } else { printf(__('Comments for %s'), get_bloginfo_rss("name")); } ?></title>
<link><?php (is_single()) ? permalink_single_rss() : bloginfo_rss("url") ?></link>
<description><?php bloginfo_rss("description") ?></description>
<pubDate><?php echo gmdate('r'); ?></pubDate>
<generator>http://wordpress.org/?v=<?php echo $wp_version ?></generator>

<?php
if (is_single() || is_page()) {
$comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email,
comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID,
$wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments
LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE comment_post_ID = '" . get_the_ID() . "'
AND $wpdb->comments.comment_approved = '1' AND $wpdb->posts.post_status = 'publish'
AND post_date_gmt < '" . gmdate("Y-m-d H:i:59") . "'
ORDER BY comment_date_gmt ASC" );
} else { // if no post id passed in, we'll just ue the last 10 comments.
$comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email,
comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID,
$wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments
LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE $wpdb->posts.post_status = 'publish'
AND $wpdb->comments.comment_approved = '1' AND post_date_gmt < '" . gmdate("Y-m-d H:i:s") . "'
ORDER BY comment_date_gmt DESC LIMIT " . get_option('posts_per_rss') );
}
// this line is WordPress' motor, do not delete it.
if ($comments) {
foreach ($comments as $comment) {
$GLOBALS['comment'] =& $comment;
// Some plugins may need to know the metadata
// associated with this comment's post:
get_post_custom($comment->comment_post_ID);
?>
<item>
<title><?php if ( ! (is_single() || is_page()) ) {
$title = get_the_title($comment->comment_post_ID);
$title = apply_filters('the_title', $title);
$title = apply_filters('the_title_rss', $title);
printf(__('Comment on %1$s by %2$s'), $title, get_comment_author_rss());
} else {
printf(__('By: %s'), get_comment_author_rss());
} ?></title>
<link><?php comment_link() ?></link>
<author><?php echo get_comment_author_rss() ?></author>
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_comment_time('Y-m-d H:i:s', true), false); ?></pubDate>
<guid><?php comment_link() ?></guid>
<?php
if (!empty($comment->post_password) && $_COOKIE['wp-postpass'] != $comment->post_password) {
?>
<description><?php _e('Protected Comments: Please enter your password to view comments.'); ?></description>
<content:encoded><![CDATA[<?php echo get_the_password_form() ?>]]></content:encoded>
<?php
} else {
?>
<description><?php comment_text_rss() ?></description>
<content:encoded><![CDATA[<?php comment_text() ?>]]></content:encoded>
<?php
} // close check for password
do_action('commentrss2_item', $comment->comment_ID, $comment->comment_post_ID);
?>
</item>
<?php
}
}
}
endwhile; endif;
?>
</channel>
</rss>

0 comments on commit 0fa6741

Please sign in to comment.