<!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>[15017] trunk/wp-admin:
  Allow plugin activation even if plugin generates extra output.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/15017">15017</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-05-28 00:18:00 +0000 (Fri, 28 May 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Allow plugin activation even if plugin generates extra output.  Make warning more informative. fixes <a href="http://trac.wordpress.org/ticket/13585">#13585</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludespluginphp">trunk/wp-admin/includes/plugin.php</a></li>
<li><a href="#trunkwpadminpluginsphp">trunk/wp-admin/plugins.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludespluginphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/plugin.php (15016 => 15017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/plugin.php        2010-05-28 00:01:59 UTC (rev 15016)
+++ trunk/wp-admin/includes/plugin.php        2010-05-28 00:18:00 UTC (rev 15017)
</span><span class="lines">@@ -482,10 +482,6 @@
</span><span class="cx">                         wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error
</span><span class="cx">                 ob_start();
</span><span class="cx">                 include(WP_PLUGIN_DIR . '/' . $plugin);
</span><del>-                if ( ob_get_length() &gt; 0 ) {
-                        $output = ob_get_clean();
-                        return new WP_Error('unexpected_output', __('The plugin generated unexpected output.'), $output);
-                }
</del><span class="cx">                 do_action( 'activate_plugin', trim( $plugin) );
</span><span class="cx">                 if ( $network_wide ) {
</span><span class="cx">                         $current[$plugin] = time();
</span><span class="lines">@@ -497,6 +493,10 @@
</span><span class="cx">                 }
</span><span class="cx">                 do_action( 'activate_' . trim( $plugin ) );
</span><span class="cx">                 do_action( 'activated_plugin', trim( $plugin) );
</span><ins>+                if ( ob_get_length() &gt; 0 ) {
+                        $output = ob_get_clean();
+                        return new WP_Error('unexpected_output', __('The plugin generated unexpected output.'), $output);
+                }
</ins><span class="cx">                 ob_end_clean();
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpadminpluginsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/plugins.php (15016 => 15017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/plugins.php        2010-05-28 00:01:59 UTC (rev 15016)
+++ trunk/wp-admin/plugins.php        2010-05-28 00:18:00 UTC (rev 15017)
</span><span class="lines">@@ -334,15 +334,14 @@
</span><span class="cx"> 
</span><span class="cx"> &lt;?php if ( isset($_GET['error']) ) :
</span><span class="cx"> 
</span><del>-        if (isset($_GET['charsout']))
-                $errmsg = sprintf(__('Plugin could not be activated because it generated %d characters of &lt;strong&gt;unexpected output&lt;/strong&gt;.'), $_GET['charsout']);
</del><ins>+        if ( isset($_GET['charsout']) )
+                $errmsg = sprintf(__('The plugin generated %d characters of &lt;strong&gt;unexpected output&lt;/strong&gt; during activation.  If you notice &amp;#8220;headers already sent&amp;#8221; messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.'), $_GET['charsout']);
</ins><span class="cx">         else
</span><span class="cx">                 $errmsg = __('Plugin could not be activated because it triggered a &lt;strong&gt;fatal error&lt;/strong&gt;.');
</span><del>-
</del><span class="cx">         ?&gt;
</span><span class="cx">         &lt;div id=&quot;message&quot; class=&quot;updated&quot;&gt;&lt;p&gt;&lt;?php echo $errmsg; ?&gt;&lt;/p&gt;
</span><span class="cx">         &lt;?php
</span><del>-                if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?&gt;
</del><ins>+                if ( !isset($_GET['charsout']) &amp;&amp; wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?&gt;
</ins><span class="cx">         &lt;iframe style=&quot;border:0&quot; width=&quot;100%&quot; height=&quot;70px&quot; src=&quot;&lt;?php echo admin_url('plugins.php?action=error_scrape&amp;amp;plugin=' . esc_attr($plugin) . '&amp;amp;_wpnonce=' . esc_attr($_GET['_error_nonce'])); ?&gt;&quot;&gt;&lt;/iframe&gt;
</span><span class="cx">         &lt;?php
</span><span class="cx">                 }
</span></span></pre>
</div>
</div>

</body>
</html>