X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/cc7b1505cd9fafd87c3672f669e13e98b0c544f7..7688c6ba71852cd89123b62b2d57683535e4702a:/wp-admin/plugins.php diff --git a/wp-admin/plugins.php b/wp-admin/plugins.php index 9424b398..b9e6e7b2 100644 --- a/wp-admin/plugins.php +++ b/wp-admin/plugins.php @@ -4,22 +4,49 @@ require_once('admin.php'); if ( isset($_GET['action']) ) { if ('activate' == $_GET['action']) { check_admin_referer('activate-plugin_' . $_GET['plugin']); - $current = get_settings('active_plugins'); - if (!in_array($_GET['plugin'], $current)) { - $current[] = trim( $_GET['plugin'] ); + $current = get_option('active_plugins'); + $plugin = trim($_GET['plugin']); + if ( validate_file($plugin) ) + wp_die(__('Invalid plugin.')); + if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) ) + wp_die(__('Plugin file does not exist.')); + if (!in_array($plugin, $current)) { + 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; sort($current); update_option('active_plugins', $current); - include(ABSPATH . 'wp-content/plugins/' . trim( $_GET['plugin'] )); - do_action('activate_' . trim( $_GET['plugin'] )); + do_action('activate_' . $plugin); + ob_end_clean(); } - wp_redirect('plugins.php?activate=true'); - } else if ('deactivate' == $_GET['action']) { + 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_settings('active_plugins'); + $current = get_option('active_plugins'); array_splice($current, array_search( $_GET['plugin'], $current), 1 ); // Array-fu! update_option('active_plugins', $current); do_action('deactivate_' . trim( $_GET['plugin'] )); wp_redirect('plugins.php?deactivate=true'); + } elseif ($_GET['action'] == 'deactivate-all') { + check_admin_referer('deactivate-all'); + $current = get_option('active_plugins'); + + foreach ($current as $plugin) { + array_splice($current, array_search($plugin, $current), 1); + do_action('deactivate_' . $plugin); + } + + update_option('active_plugins', array()); + wp_redirect('plugins.php?deactivate-all=true'); } exit; } @@ -30,20 +57,20 @@ require_once('admin-header.php'); // Clean up options // If any plugins don't exist, axe 'em -$check_plugins = get_settings('active_plugins'); +$check_plugins = get_option('active_plugins'); // Sanity check. If the active plugin list is not an array, make it an // empty array. if ( !is_array($check_plugins) ) { $check_plugins = array(); - update_option('active_plugins', $check_plugins); + update_option('active_plugins', $check_plugins); } // If a plugin file does not exist, remove it from the list of active // plugins. foreach ($check_plugins as $check_plugin) { - if (!file_exists(ABSPATH . 'wp-content/plugins/' . $check_plugin)) { - $current = get_settings('active_plugins'); + if (!file_exists(ABSPATH . PLUGINDIR . '/' . $check_plugin)) { + $current = get_option('active_plugins'); $key = array_search($check_plugin, $current); if ( false !== $key && NULL !== $key ) { unset($current[$key]); @@ -53,13 +80,22 @@ foreach ($check_plugins as $check_plugin) { } ?> - -

activated.') ?>

-
- - -

deactivated.') ?>

-
+ +

fatal error.') ?>

+ + + +
+ +

activated.') ?>

+ +

deactivated.') ?>

+ +

deactivated.'); ?>

@@ -67,64 +103,87 @@ foreach ($check_plugins as $check_plugin) {

'; - _e("Couldn't open plugins directory or there are no plugins available."); // TODO: make more helpful + _e("Couldn’t open plugins directory or there are no plugins available."); // TODO: make more helpful echo '

'; } else { ?> - +
+ - + - + + $plugin_data) { $style = ('class="alternate"' == $style|| 'class="alternate active"' == $style) ? '' : 'alternate'; if (!empty($current_plugins) && in_array($plugin_file, $current_plugins)) { - $action = "".__('Deactivate').""; + $toggle = "".__('Deactivate').""; $plugin_data['Title'] = "{$plugin_data['Title']}"; $style .= $style == 'alternate' ? ' active' : 'active'; } else { - $action = "".__('Activate').""; + $toggle = "".__('Activate').""; } - $plugin_data['Description'] = wp_kses($plugin_data['Description'], array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array()) ); ; - if ($style != '') $style = 'class="' . $style . '"'; + + $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array()); + + // Sanitize all displayed data + $plugin_data['Title'] = wp_kses($plugin_data['Title'], $plugins_allowedtags); + $plugin_data['Version'] = wp_kses($plugin_data['Version'], $plugins_allowedtags); + $plugin_data['Description'] = wp_kses($plugin_data['Description'], $plugins_allowedtags); + $plugin_data['Author'] = wp_kses($plugin_data['Author'], $plugins_allowedtags); + + if ( $style != '' ) + $style = 'class="' . $style . '"'; + if ( is_writable(ABSPATH . PLUGINDIR . '/' . $plugin_file) ) + $edit = "".__('Edit').""; + else + $edit = ''; + + $author = ( empty($plugin_data['Author']) ) ? '' : ' ' . sprintf( __('By %s'), $plugin_data['Author'] ) . '.'; + echo " - - + + "; + if ( current_user_can('edit_plugins') ) + echo " + "; + echo" "; + do_action( 'after_plugin_row', $plugin_file ); } ?> + + + + +
>
{$plugin_data['Title']} {$plugin_data['Version']}{$plugin_data['Description']} ".sprintf(__('By %s'), $plugin_data['Author']).".$action

{$plugin_data['Description']}$author

$toggle$edit
 
-

wp-content/plugins directory and it will be automatically deactivated.'); ?>

+

%s directory and it will be automatically deactivated.'), PLUGINDIR); ?>

-

WordPress plugin directory. To install a plugin you generally just need to upload the plugin file into your wp-content/plugins directory. Once a plugin is uploaded, you may activate it here.'); ?>

+

WordPress plugin directory.'); ?>

+

%s directory. Once a plugin is uploaded, you may activate it here.'), PLUGINDIR); ?>