Make WordPress Core

Changeset 15017


Ignore:
Timestamp:
05/28/2010 12:18:00 AM (15 years ago)
Author:
ryan
Message:

Allow plugin activation even if plugin generates extra output. Make warning more informative. fixes #13585

Location:
trunk/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/plugin.php

    r14546 r15017  
    483483        ob_start();
    484484        include(WP_PLUGIN_DIR . '/' . $plugin);
    485         if ( ob_get_length() > 0 ) {
    486             $output = ob_get_clean();
    487             return new WP_Error('unexpected_output', __('The plugin generated unexpected output.'), $output);
    488         }
    489485        do_action( 'activate_plugin', trim( $plugin) );
    490486        if ( $network_wide ) {
     
    498494        do_action( 'activate_' . trim( $plugin ) );
    499495        do_action( 'activated_plugin', trim( $plugin) );
     496        if ( ob_get_length() > 0 ) {
     497            $output = ob_get_clean();
     498            return new WP_Error('unexpected_output', __('The plugin generated unexpected output.'), $output);
     499        }
    500500        ob_end_clean();
    501501    }
  • trunk/wp-admin/plugins.php

    r14989 r15017  
    335335<?php if ( isset($_GET['error']) ) :
    336336
    337     if (isset($_GET['charsout']))
    338         $errmsg = sprintf(__('Plugin could not be activated because it generated %d characters of <strong>unexpected output</strong>.'), $_GET['charsout']);
     337    if ( isset($_GET['charsout']) )
     338        $errmsg = sprintf(__('The plugin generated %d characters of <strong>unexpected output</strong> during activation.  If you notice &#8220;headers already sent&#8221; messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.'), $_GET['charsout']);
    339339    else
    340340        $errmsg = __('Plugin could not be activated because it triggered a <strong>fatal error</strong>.');
    341 
    342341    ?>
    343342    <div id="message" class="updated"><p><?php echo $errmsg; ?></p>
    344343    <?php
    345         if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?>
     344        if ( !isset($_GET['charsout']) && wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?>
    346345    <iframe style="border:0" width="100%" height="70px" src="<?php echo admin_url('plugins.php?action=error_scrape&amp;plugin=' . esc_attr($plugin) . '&amp;_wpnonce=' . esc_attr($_GET['_error_nonce'])); ?>"></iframe>
    347346    <?php
Note: See TracChangeset for help on using the changeset viewer.