mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Allow plugin activation even if plugin generates extra output. Make warning more informative. fixes #13585
git-svn-id: http://svn.automattic.com/wordpress/trunk@15017 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
549ec140b9
commit
5d5cb6e483
@ -482,10 +482,6 @@ function activate_plugin( $plugin, $redirect = '', $network_wide = false) {
|
||||
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);
|
||||
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();
|
||||
@ -497,6 +493,10 @@ function activate_plugin( $plugin, $redirect = '', $network_wide = false) {
|
||||
}
|
||||
do_action( 'activate_' . trim( $plugin ) );
|
||||
do_action( 'activated_plugin', trim( $plugin) );
|
||||
if ( ob_get_length() > 0 ) {
|
||||
$output = ob_get_clean();
|
||||
return new WP_Error('unexpected_output', __('The plugin generated unexpected output.'), $output);
|
||||
}
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
|
@ -334,15 +334,14 @@ if ( !empty($invalid) )
|
||||
|
||||
<?php if ( isset($_GET['error']) ) :
|
||||
|
||||
if (isset($_GET['charsout']))
|
||||
$errmsg = sprintf(__('Plugin could not be activated because it generated %d characters of <strong>unexpected output</strong>.'), $_GET['charsout']);
|
||||
if ( isset($_GET['charsout']) )
|
||||
$errmsg = sprintf(__('The plugin generated %d characters of <strong>unexpected output</strong> during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.'), $_GET['charsout']);
|
||||
else
|
||||
$errmsg = __('Plugin could not be activated because it triggered a <strong>fatal error</strong>.');
|
||||
|
||||
?>
|
||||
<div id="message" class="updated"><p><?php echo $errmsg; ?></p>
|
||||
<?php
|
||||
if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?>
|
||||
if ( !isset($_GET['charsout']) && wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?>
|
||||
<iframe style="border:0" width="100%" height="70px" src="<?php echo admin_url('plugins.php?action=error_scrape&plugin=' . esc_attr($plugin) . '&_wpnonce=' . esc_attr($_GET['_error_nonce'])); ?>"></iframe>
|
||||
<?php
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user