<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[13113] trunk:
Add the generator element in feeds through the {rss2|atom|rdf|rss|opml}_head hooks
.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13113">13113</a></dd>
<dt>Author</dt> <dd>westi</dd>
<dt>Date</dt> <dd>2010-02-13 16:45:16 +0000 (Sat, 13 Feb 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add the generator element in feeds through the {rss2|atom|rdf|rss|opml}_head hooks. Fixes <a href="http://trac.wordpress.org/ticket/6947">#6947</a> props sivel.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpappphp">trunk/wp-app.php</a></li>
<li><a href="#trunkwpincludesdefaultfiltersphp">trunk/wp-includes/default-filters.php</a></li>
<li><a href="#trunkwpincludesfeedatomcommentsphp">trunk/wp-includes/feed-atom-comments.php</a></li>
<li><a href="#trunkwpincludesfeedatomphp">trunk/wp-includes/feed-atom.php</a></li>
<li><a href="#trunkwpincludesfeedrdfphp">trunk/wp-includes/feed-rdf.php</a></li>
<li><a href="#trunkwpincludesfeedrssphp">trunk/wp-includes/feed-rss.php</a></li>
<li><a href="#trunkwpincludesfeedrss2commentsphp">trunk/wp-includes/feed-rss2-comments.php</a></li>
<li><a href="#trunkwpincludesfeedrss2php">trunk/wp-includes/feed-rss2.php</a></li>
<li><a href="#trunkwpincludesgeneraltemplatephp">trunk/wp-includes/general-template.php</a></li>
<li><a href="#trunkwplinksopmlphp">trunk/wp-links-opml.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpappphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-app.php (13112 => 13113)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-app.php        2010-02-13 13:35:03 UTC (rev 13112)
+++ trunk/wp-app.php        2010-02-13 16:45:16 UTC (rev 13113)
</span><span class="lines">@@ -1096,7 +1096,6 @@
</span><span class="cx"> <link rel="last" type="<?php echo $this->ATOM_CONTENT_TYPE ?>" href="<?php $this->the_entries_url($last_page) ?>" />
</span><span class="cx"> <link rel="self" type="<?php echo $this->ATOM_CONTENT_TYPE ?>" href="<?php $this->the_entries_url($self_page) ?>" />
</span><span class="cx"> <rights type="text">Copyright <?php echo date('Y'); ?></rights>
</span><del>-<?php the_generator( 'atom' ); ?>
</del><span class="cx"> <?php do_action('app_head'); ?>
</span><span class="cx"> <?php if ( have_posts() ) {
</span><span class="cx">                         while ( have_posts() ) {
</span></span></pre></div>
<a id="trunkwpincludesdefaultfiltersphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/default-filters.php (13112 => 13113)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/default-filters.php        2010-02-13 13:35:03 UTC (rev 13112)
+++ trunk/wp-includes/default-filters.php        2010-02-13 16:45:16 UTC (rev 13113)
</span><span class="lines">@@ -185,6 +185,11 @@
</span><span class="cx"> add_action( 'wp_head', 'rel_canonical' );
</span><span class="cx"> add_action( 'wp_footer', 'wp_print_footer_scripts' );
</span><span class="cx">
</span><ins>+// 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' );
+}
+
</ins><span class="cx"> // WP Cron
</span><span class="cx"> if ( !defined( 'DOING_CRON' ) )
</span><span class="cx">         add_action( 'sanitize_comment_cookies', 'wp_cron' );
</span></span></pre></div>
<a id="trunkwpincludesfeedatomcommentsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/feed-atom-comments.php (13112 => 13113)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/feed-atom-comments.php        2010-02-13 13:35:03 UTC (rev 13112)
+++ trunk/wp-includes/feed-atom-comments.php        2010-02-13 16:45:16 UTC (rev 13113)
</span><span class="lines">@@ -25,7 +25,6 @@
</span><span class="cx">         <subtitle type="text"><?php bloginfo_rss('description'); ?></subtitle>
</span><span class="cx">
</span><span class="cx">         <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastcommentmodified('GMT'), false); ?></updated>
</span><del>-        <?php the_generator( 'atom' ); ?>
</del><span class="cx">
</span><span class="cx"> <?php if ( is_singular() ) { ?>
</span><span class="cx">         <link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php echo get_comments_link(); ?>" />
</span></span></pre></div>
<a id="trunkwpincludesfeedatomphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/feed-atom.php (13112 => 13113)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/feed-atom.php        2010-02-13 13:35:03 UTC (rev 13112)
+++ trunk/wp-includes/feed-atom.php        2010-02-13 16:45:16 UTC (rev 13113)
</span><span class="lines">@@ -20,7 +20,6 @@
</span><span class="cx">         <subtitle type="text"><?php bloginfo_rss("description") ?></subtitle>
</span><span class="cx">
</span><span class="cx">         <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></updated>
</span><del>-        <?php the_generator( 'atom' ); ?>
</del><span class="cx">
</span><span class="cx">         <link rel="alternate" type="text/html" href="<?php bloginfo_rss('url') ?>" />
</span><span class="cx">         <id><?php bloginfo('atom_url'); ?></id>
</span></span></pre></div>
<a id="trunkwpincludesfeedrdfphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/feed-rdf.php (13112 => 13113)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/feed-rdf.php        2010-02-13 13:35:03 UTC (rev 13112)
+++ trunk/wp-includes/feed-rdf.php        2010-02-13 16:45:16 UTC (rev 13113)
</span><span class="lines">@@ -23,7 +23,6 @@
</span><span class="cx">         <link><?php bloginfo_rss('url') ?></link>
</span><span class="cx">         <description><?php bloginfo_rss('description') ?></description>
</span><span class="cx">         <dc:date><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></dc:date>
</span><del>-        <?php the_generator( 'rdf' ); ?>
</del><span class="cx">         <sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
</span><span class="cx">         <sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>
</span><span class="cx">         <sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
</span></span></pre></div>
<a id="trunkwpincludesfeedrssphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/feed-rss.php (13112 => 13113)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/feed-rss.php        2010-02-13 13:35:03 UTC (rev 13112)
+++ trunk/wp-includes/feed-rss.php        2010-02-13 16:45:16 UTC (rev 13113)
</span><span class="lines">@@ -9,7 +9,6 @@
</span><span class="cx"> $more = 1;
</span><span class="cx">
</span><span class="cx"> echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
</span><del>-<?php the_generator( 'comment' ); ?>
</del><span class="cx"> <rss version="0.92">
</span><span class="cx"> <channel>
</span><span class="cx">         <title><?php bloginfo_rss('name'); wp_title_rss(); ?></title>
</span></span></pre></div>
<a id="trunkwpincludesfeedrss2commentsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/feed-rss2-comments.php (13112 => 13113)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/feed-rss2-comments.php        2010-02-13 13:35:03 UTC (rev 13112)
+++ trunk/wp-includes/feed-rss2-comments.php        2010-02-13 16:45:16 UTC (rev 13113)
</span><span class="lines">@@ -29,7 +29,6 @@
</span><span class="cx">         <link><?php (is_single()) ? the_permalink_rss() : bloginfo_rss("url") ?></link>
</span><span class="cx">         <description><?php bloginfo_rss("description") ?></description>
</span><span class="cx">         <lastBuildDate><?php echo mysql2date('r', get_lastcommentmodified('GMT')); ?></lastBuildDate>
</span><del>-        <?php the_generator( 'rss2' ); ?>
</del><span class="cx">         <sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
</span><span class="cx">         <sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>
</span><span class="cx">         <?php do_action('commentsrss2_head'); ?>
</span></span></pre></div>
<a id="trunkwpincludesfeedrss2php"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/feed-rss2.php (13112 => 13113)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/feed-rss2.php        2010-02-13 13:35:03 UTC (rev 13112)
+++ trunk/wp-includes/feed-rss2.php        2010-02-13 16:45:16 UTC (rev 13113)
</span><span class="lines">@@ -26,7 +26,6 @@
</span><span class="cx">         <link><?php bloginfo_rss('url') ?></link>
</span><span class="cx">         <description><?php bloginfo_rss("description") ?></description>
</span><span class="cx">         <lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>
</span><del>-        <?php the_generator( 'rss2' ); ?>
</del><span class="cx">         <language><?php echo get_option('rss_language'); ?></language>
</span><span class="cx">         <sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
</span><span class="cx">         <sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>
</span></span></pre></div>
<a id="trunkwpincludesgeneraltemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/general-template.php (13112 => 13113)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/general-template.php        2010-02-13 13:35:03 UTC (rev 13112)
+++ trunk/wp-includes/general-template.php        2010-02-13 16:45:16 UTC (rev 13113)
</span><span class="lines">@@ -2130,8 +2130,34 @@
</span><span class="cx"> * @param string $type The type of generator to return - (html|xhtml|atom|rss2|rdf|comment|export).
</span><span class="cx"> * @return string The HTML content for the generator.
</span><span class="cx"> */
</span><del>-function get_the_generator( $type ) {
-        switch ($type) {
</del><ins>+function get_the_generator( $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 ) {
</ins><span class="cx">                 case 'html':
</span><span class="cx">                         $gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '">';
</span><span class="cx">                         break;
</span></span></pre></div>
<a id="trunkwplinksopmlphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-links-opml.php (13112 => 13113)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-links-opml.php        2010-02-13 13:35:03 UTC (rev 13112)
+++ trunk/wp-links-opml.php        2010-02-13 16:45:16 UTC (rev 13113)
</span><span class="lines">@@ -26,11 +26,11 @@
</span><span class="cx">         $link_cat = intval($link_cat);
</span><span class="cx"> }
</span><span class="cx"> ?><?php echo '<?xml version="1.0"?'.">\n"; ?>
</span><del>-<?php the_generator( 'comment' ); ?>
</del><span class="cx"> <opml version="1.0">
</span><span class="cx">         <head>
</span><span class="cx">                 <title>Links for <?php echo esc_attr(get_bloginfo('name', 'display').$cat_name); ?></title>
</span><span class="cx">                 <dateCreated><?php echo gmdate("D, d M Y H:i:s"); ?> GMT</dateCreated>
</span><ins>+                <?php do_action('opml_head'); ?>
</ins><span class="cx">         </head>
</span><span class="cx">         <body>
</span><span class="cx"> <?php
</span></span></pre>
</div>
</div>
</body>
</html>