Detect plugin output on activation, as well as fatal errors. props miqrogroove. fixes #12089

git-svn-id: https://develop.svn.wordpress.org/trunk@13167 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mark Jaquith
2010-02-16 03:44:20 +00:00
parent 37e62c69f5
commit 49d4b41207
2 changed files with 33 additions and 10 deletions

View File

@@ -358,7 +358,11 @@ function activate_plugin( $plugin, $redirect = '', $network_wide = false) {
if ( !empty($redirect) )
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
ob_start();
@include(WP_PLUGIN_DIR . '/' . $plugin);
include(WP_PLUGIN_DIR . '/' . $plugin);
if ( ob_get_length() > 0 ) {
$output = ob_get_clean();
return new WP_Error('unexpected_output', __('The plugin generated unexpected output.'), $output);
}
do_action( 'activate_plugin', trim( $plugin) );
if ( $network_wide ) {
$current[$plugin] = time();