Prevent plugins that generate PHP fatal errors from being activated. ticket #3254
git-svn-id: https://develop.svn.wordpress.org/trunk@4811 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
ffdb5a89ef
commit
320ac834de
@ -11,13 +11,14 @@ if ( isset($_GET['action']) ) {
|
|||||||
if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) )
|
if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) )
|
||||||
wp_die(__('Plugin file does not exist.'));
|
wp_die(__('Plugin file does not exist.'));
|
||||||
if (!in_array($plugin, $current)) {
|
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
|
||||||
|
@include(ABSPATH . PLUGINDIR . '/' . $plugin);
|
||||||
$current[] = $plugin;
|
$current[] = $plugin;
|
||||||
sort($current);
|
sort($current);
|
||||||
update_option('active_plugins', $current);
|
update_option('active_plugins', $current);
|
||||||
include(ABSPATH . PLUGINDIR . '/' . $plugin);
|
|
||||||
do_action('activate_' . $plugin);
|
do_action('activate_' . $plugin);
|
||||||
}
|
}
|
||||||
wp_redirect('plugins.php?activate=true');
|
wp_redirect('plugins.php?activate=true'); // overrides the ?error=true one above
|
||||||
} else if ('deactivate' == $_GET['action']) {
|
} else if ('deactivate' == $_GET['action']) {
|
||||||
check_admin_referer('deactivate-plugin_' . $_GET['plugin']);
|
check_admin_referer('deactivate-plugin_' . $_GET['plugin']);
|
||||||
$current = get_option('active_plugins');
|
$current = get_option('active_plugins');
|
||||||
@ -58,13 +59,12 @@ foreach ($check_plugins as $check_plugin) {
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php if (isset($_GET['activate'])) : ?>
|
<?php if ( isset($_GET['error']) ) : ?>
|
||||||
<div id="message" class="updated fade"><p><?php _e('Plugin <strong>activated</strong>.') ?></p>
|
<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>
|
<?php elseif ( isset($_GET['activate']) ) : ?>
|
||||||
<?php endif; ?>
|
<div id="message" class="updated fade"><p><?php _e('Plugin <strong>activated</strong>.') ?></p></div>
|
||||||
<?php if (isset($_GET['deactivate'])) : ?>
|
<?php elseif ( isset($_GET['deactivate']) ) : ?>
|
||||||
<div id="message" class="updated fade"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p>
|
<div id="message" class="updated fade"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p></div>
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
|
Loading…
Reference in New Issue
Block a user