Skip to content

Commit 1600c46

Browse files
committed
Add the generator element in feeds through the {rss2|atom|rdf|rss|opml}_head hooks. Fixes WordPress#6947 props sivel.
git-svn-id: https://develop.svn.wordpress.org/trunk@13113 602fd350-edb4-49c9-b593-d223f7449a82
1 parent c43fd05 commit 1600c46

10 files changed

Lines changed: 34 additions & 10 deletions

wp-app.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,6 @@ function get_feed($page = 1, $post_type = 'post') {
10961096
<link rel="last" type="<?php echo $this->ATOM_CONTENT_TYPE ?>" href="<?php $this->the_entries_url($last_page) ?>" />
10971097
<link rel="self" type="<?php echo $this->ATOM_CONTENT_TYPE ?>" href="<?php $this->the_entries_url($self_page) ?>" />
10981098
<rights type="text">Copyright <?php echo date('Y'); ?></rights>
1099-
<?php the_generator( 'atom' ); ?>
11001099
<?php do_action('app_head'); ?>
11011100
<?php if ( have_posts() ) {
11021101
while ( have_posts() ) {

wp-includes/default-filters.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@
185185
add_action( 'wp_head', 'rel_canonical' );
186186
add_action( 'wp_footer', 'wp_print_footer_scripts' );
187187

188+
// Feed Generator Tags
189+
foreach ( array( 'rss2_head', 'commentsrss2_head', 'rss_head', 'rdf_header', 'atom_head', 'comments_atom_head', 'opml_head', 'app_head' ) as $action ) {
190+
add_action( $action, 'the_generator' );
191+
}
192+
188193
// WP Cron
189194
if ( !defined( 'DOING_CRON' ) )
190195
add_action( 'sanitize_comment_cookies', 'wp_cron' );

wp-includes/feed-atom-comments.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
<subtitle type="text"><?php bloginfo_rss('description'); ?></subtitle>
2626

2727
<updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastcommentmodified('GMT'), false); ?></updated>
28-
<?php the_generator( 'atom' ); ?>
2928

3029
<?php if ( is_singular() ) { ?>
3130
<link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php echo get_comments_link(); ?>" />

wp-includes/feed-atom.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
<subtitle type="text"><?php bloginfo_rss("description") ?></subtitle>
2121

2222
<updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></updated>
23-
<?php the_generator( 'atom' ); ?>
2423

2524
<link rel="alternate" type="text/html" href="<?php bloginfo_rss('url') ?>" />
2625
<id><?php bloginfo('atom_url'); ?></id>

wp-includes/feed-rdf.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
<link><?php bloginfo_rss('url') ?></link>
2424
<description><?php bloginfo_rss('description') ?></description>
2525
<dc:date><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></dc:date>
26-
<?php the_generator( 'rdf' ); ?>
2726
<sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
2827
<sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>
2928
<sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>

wp-includes/feed-rss.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
$more = 1;
1010

1111
echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
12-
<?php the_generator( 'comment' ); ?>
1312
<rss version="0.92">
1413
<channel>
1514
<title><?php bloginfo_rss('name'); wp_title_rss(); ?></title>

wp-includes/feed-rss2-comments.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
<link><?php (is_single()) ? the_permalink_rss() : bloginfo_rss("url") ?></link>
3030
<description><?php bloginfo_rss("description") ?></description>
3131
<lastBuildDate><?php echo mysql2date('r', get_lastcommentmodified('GMT')); ?></lastBuildDate>
32-
<?php the_generator( 'rss2' ); ?>
3332
<sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
3433
<sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>
3534
<?php do_action('commentsrss2_head'); ?>

wp-includes/feed-rss2.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<link><?php bloginfo_rss('url') ?></link>
2727
<description><?php bloginfo_rss("description") ?></description>
2828
<lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>
29-
<?php the_generator( 'rss2' ); ?>
3029
<language><?php echo get_option('rss_language'); ?></language>
3130
<sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
3231
<sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>

wp-includes/general-template.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,8 +2130,34 @@ function the_generator( $type ) {
21302130
* @param string $type The type of generator to return - (html|xhtml|atom|rss2|rdf|comment|export).
21312131
* @return string The HTML content for the generator.
21322132
*/
2133-
function get_the_generator( $type ) {
2134-
switch ($type) {
2133+
function get_the_generator( $type = '' ) {
2134+
if ( empty( $type ) ) {
2135+
2136+
$current_filter = current_filter();
2137+
if ( empty( $current_filter ) )
2138+
return;
2139+
2140+
switch ( $current_filter ) {
2141+
case 'rss2_head' :
2142+
case 'commentsrss2_head' :
2143+
$type = 'rss2';
2144+
break;
2145+
case 'rss_head' :
2146+
case 'opml_head' :
2147+
$type = 'comment';
2148+
break;
2149+
case 'rdf_header' :
2150+
$type = 'rdf';
2151+
break;
2152+
case 'atom_head' :
2153+
case 'comments_atom_head' :
2154+
case 'app_head' :
2155+
$type = 'atom';
2156+
break;
2157+
}
2158+
}
2159+
2160+
switch ( $type ) {
21352161
case 'html':
21362162
$gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '">';
21372163
break;

wp-links-opml.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
$link_cat = intval($link_cat);
2727
}
2828
?><?php echo '<?xml version="1.0"?'.">\n"; ?>
29-
<?php the_generator( 'comment' ); ?>
3029
<opml version="1.0">
3130
<head>
3231
<title>Links for <?php echo esc_attr(get_bloginfo('name', 'display').$cat_name); ?></title>
3332
<dateCreated><?php echo gmdate("D, d M Y H:i:s"); ?> GMT</dateCreated>
33+
<?php do_action('opml_head'); ?>
3434
</head>
3535
<body>
3636
<?php

0 commit comments

Comments
 (0)