Display fatal errors that prevent plugins from being activated. fixes #4508

git-svn-id: http://svn.automattic.com/wordpress/trunk@5753 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
markjaquith 2007-06-25 18:57:54 +00:00
parent ed549303d7
commit 2fd0094ce3
1 changed files with 19 additions and 3 deletions

View File

@ -11,7 +11,7 @@ if ( isset($_GET['action']) ) {
if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) )
wp_die(__('Plugin file does not exist.'));
if (!in_array($plugin, $current)) {
wp_redirect('plugins.php?error=true'); // we'll override this later if the plugin can be included without fatal error
wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), 'plugins.php?error=true&plugin=' . $plugin)); // we'll override this later if the plugin can be included without fatal error
ob_start();
@include(ABSPATH . PLUGINDIR . '/' . $plugin);
$current[] = $plugin;
@ -21,6 +21,14 @@ if ( isset($_GET['action']) ) {
ob_end_clean();
}
wp_redirect('plugins.php?activate=true'); // overrides the ?error=true one above
} elseif ('error_scrape' == $_GET['action']) {
$plugin = trim($_GET['plugin']);
check_admin_referer('plugin-activation-error_' . $plugin);
if ( validate_file($plugin) )
wp_die(__('Invalid plugin.'));
if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) )
wp_die(__('Plugin file does not exist.'));
include(ABSPATH . PLUGINDIR . '/' . $plugin);
} elseif ('deactivate' == $_GET['action']) {
check_admin_referer('deactivate-plugin_' . $_GET['plugin']);
$current = get_option('active_plugins');
@ -73,7 +81,15 @@ foreach ($check_plugins as $check_plugin) {
?>
<?php if ( isset($_GET['error']) ) : ?>
<div id="message" class="updated fade"><p><?php _e('Plugin could not be activated because it triggered a <strong>fatal error</strong>.') ?></p></div>
<div id="message" class="updated fade"><p><?php _e('Plugin could not be activated because it triggered a <strong>fatal error</strong>.') ?></p>
<?php
$plugin = trim($_GET['plugin']);
if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) && 1 == strtolower(ini_get('display_errors'))) { ?>
<iframe style="border:0" width="100%" height="70px" src="<?php bloginfo('wpurl'); ?>/wp-admin/plugins.php?action=error_scrape&amp;plugin=<?php echo attribute_escape($plugin); ?>&amp;_wpnonce=<?php echo attribute_escape($_GET['_error_nonce']); ?>"></iframe>
<?php
}
?>
</div>
<?php elseif ( isset($_GET['activate']) ) : ?>
<div id="message" class="updated fade"><p><?php _e('Plugin <strong>activated</strong>.') ?></p></div>
<?php elseif ( isset($_GET['deactivate']) ) : ?>