Add the generator element in feeds through the {rss2|atom|rdf|rss|opml}_head hooks. Fixes #6947 props sivel.

git-svn-id: http://svn.automattic.com/wordpress/trunk@13113 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
westi 2010-02-13 16:45:16 +00:00
parent df2a293967
commit d8490aeea2
10 changed files with 34 additions and 10 deletions

View File

@ -1096,7 +1096,6 @@ EOD;
<link rel="last" type="<?php echo $this->ATOM_CONTENT_TYPE ?>" href="<?php $this->the_entries_url($last_page) ?>" /> <link rel="last" type="<?php echo $this->ATOM_CONTENT_TYPE ?>" href="<?php $this->the_entries_url($last_page) ?>" />
<link rel="self" type="<?php echo $this->ATOM_CONTENT_TYPE ?>" href="<?php $this->the_entries_url($self_page) ?>" /> <link rel="self" type="<?php echo $this->ATOM_CONTENT_TYPE ?>" href="<?php $this->the_entries_url($self_page) ?>" />
<rights type="text">Copyright <?php echo date('Y'); ?></rights> <rights type="text">Copyright <?php echo date('Y'); ?></rights>
<?php the_generator( 'atom' ); ?>
<?php do_action('app_head'); ?> <?php do_action('app_head'); ?>
<?php if ( have_posts() ) { <?php if ( have_posts() ) {
while ( have_posts() ) { while ( have_posts() ) {

View File

@ -185,6 +185,11 @@ add_action( 'wp_head', 'wp_generator' );
add_action( 'wp_head', 'rel_canonical' ); add_action( 'wp_head', 'rel_canonical' );
add_action( 'wp_footer', 'wp_print_footer_scripts' ); add_action( 'wp_footer', 'wp_print_footer_scripts' );
// Feed Generator Tags
foreach ( array( 'rss2_head', 'commentsrss2_head', 'rss_head', 'rdf_header', 'atom_head', 'comments_atom_head', 'opml_head', 'app_head' ) as $action ) {
add_action( $action, 'the_generator' );
}
// WP Cron // WP Cron
if ( !defined( 'DOING_CRON' ) ) if ( !defined( 'DOING_CRON' ) )
add_action( 'sanitize_comment_cookies', 'wp_cron' ); add_action( 'sanitize_comment_cookies', 'wp_cron' );

View File

@ -25,7 +25,6 @@ echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '" ?' . '>'
<subtitle type="text"><?php bloginfo_rss('description'); ?></subtitle> <subtitle type="text"><?php bloginfo_rss('description'); ?></subtitle>
<updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastcommentmodified('GMT'), false); ?></updated> <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastcommentmodified('GMT'), false); ?></updated>
<?php the_generator( 'atom' ); ?>
<?php if ( is_singular() ) { ?> <?php if ( is_singular() ) { ?>
<link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php echo get_comments_link(); ?>" /> <link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php echo get_comments_link(); ?>" />

View File

@ -20,7 +20,6 @@ echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
<subtitle type="text"><?php bloginfo_rss("description") ?></subtitle> <subtitle type="text"><?php bloginfo_rss("description") ?></subtitle>
<updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></updated> <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></updated>
<?php the_generator( 'atom' ); ?>
<link rel="alternate" type="text/html" href="<?php bloginfo_rss('url') ?>" /> <link rel="alternate" type="text/html" href="<?php bloginfo_rss('url') ?>" />
<id><?php bloginfo('atom_url'); ?></id> <id><?php bloginfo('atom_url'); ?></id>

View File

@ -23,7 +23,6 @@ echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
<link><?php bloginfo_rss('url') ?></link> <link><?php bloginfo_rss('url') ?></link>
<description><?php bloginfo_rss('description') ?></description> <description><?php bloginfo_rss('description') ?></description>
<dc:date><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></dc:date> <dc:date><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></dc:date>
<?php the_generator( 'rdf' ); ?>
<sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod> <sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
<sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency> <sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>
<sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase> <sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>

View File

@ -9,7 +9,6 @@ header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_opt
$more = 1; $more = 1;
echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?> echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
<?php the_generator( 'comment' ); ?>
<rss version="0.92"> <rss version="0.92">
<channel> <channel>
<title><?php bloginfo_rss('name'); wp_title_rss(); ?></title> <title><?php bloginfo_rss('name'); wp_title_rss(); ?></title>

View File

@ -29,7 +29,6 @@ echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>';
<link><?php (is_single()) ? the_permalink_rss() : bloginfo_rss("url") ?></link> <link><?php (is_single()) ? the_permalink_rss() : bloginfo_rss("url") ?></link>
<description><?php bloginfo_rss("description") ?></description> <description><?php bloginfo_rss("description") ?></description>
<lastBuildDate><?php echo mysql2date('r', get_lastcommentmodified('GMT')); ?></lastBuildDate> <lastBuildDate><?php echo mysql2date('r', get_lastcommentmodified('GMT')); ?></lastBuildDate>
<?php the_generator( 'rss2' ); ?>
<sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod> <sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
<sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency> <sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>
<?php do_action('commentsrss2_head'); ?> <?php do_action('commentsrss2_head'); ?>

View File

@ -26,7 +26,6 @@ echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
<link><?php bloginfo_rss('url') ?></link> <link><?php bloginfo_rss('url') ?></link>
<description><?php bloginfo_rss("description") ?></description> <description><?php bloginfo_rss("description") ?></description>
<lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate> <lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>
<?php the_generator( 'rss2' ); ?>
<language><?php echo get_option('rss_language'); ?></language> <language><?php echo get_option('rss_language'); ?></language>
<sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod> <sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
<sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency> <sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>

View File

@ -2130,8 +2130,34 @@ function the_generator( $type ) {
* @param string $type The type of generator to return - (html|xhtml|atom|rss2|rdf|comment|export). * @param string $type The type of generator to return - (html|xhtml|atom|rss2|rdf|comment|export).
* @return string The HTML content for the generator. * @return string The HTML content for the generator.
*/ */
function get_the_generator( $type ) { function get_the_generator( $type = '' ) {
switch ($type) { if ( empty( $type ) ) {
$current_filter = current_filter();
if ( empty( $current_filter ) )
return;
switch ( $current_filter ) {
case 'rss2_head' :
case 'commentsrss2_head' :
$type = 'rss2';
break;
case 'rss_head' :
case 'opml_head' :
$type = 'comment';
break;
case 'rdf_header' :
$type = 'rdf';
break;
case 'atom_head' :
case 'comments_atom_head' :
case 'app_head' :
$type = 'atom';
break;
}
}
switch ( $type ) {
case 'html': case 'html':
$gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '">'; $gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '">';
break; break;

View File

@ -26,11 +26,11 @@ if ((empty ($link_cat)) || ($link_cat == 'all') || ($link_cat == '0')) {
$link_cat = intval($link_cat); $link_cat = intval($link_cat);
} }
?><?php echo '<?xml version="1.0"?'.">\n"; ?> ?><?php echo '<?xml version="1.0"?'.">\n"; ?>
<?php the_generator( 'comment' ); ?>
<opml version="1.0"> <opml version="1.0">
<head> <head>
<title>Links for <?php echo esc_attr(get_bloginfo('name', 'display').$cat_name); ?></title> <title>Links for <?php echo esc_attr(get_bloginfo('name', 'display').$cat_name); ?></title>
<dateCreated><?php echo gmdate("D, d M Y H:i:s"); ?> GMT</dateCreated> <dateCreated><?php echo gmdate("D, d M Y H:i:s"); ?> GMT</dateCreated>
<?php do_action('opml_head'); ?>
</head> </head>
<body> <body>
<?php <?php