X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/022dfbbbe3215917d84708eb09acca93b21ae9e0..refs/tags/wordpress-2.5.1:/wp-admin/plugins.php?ds=sidebyside diff --git a/wp-admin/plugins.php b/wp-admin/plugins.php index 21db39d0..f0b75ad5 100644 --- a/wp-admin/plugins.php +++ b/wp-admin/plugins.php @@ -2,64 +2,67 @@ require_once('admin.php'); if ( isset($_GET['action']) ) { - if ('activate' == $_GET['action']) { + if ( isset($_GET['plugin']) ) + $plugin = trim($_GET['plugin']); + + 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'] ); - sort($current); - update_option('active_plugins', $current); - include(ABSPATH . 'wp-content/plugins/' . trim( $_GET['plugin'] )); - do_action('activate_' . trim( $_GET['plugin'] )); - } - wp_redirect('plugins.php?activate=true'); - } else if ('deactivate' == $_GET['action']) { + $result = activate_plugin($_GET['plugin'], 'plugins.php?error=true&plugin=' . $plugin); + if ( is_wp_error( $result ) ) + wp_die( $result->get_error_message() ); + wp_redirect('plugins.php?activate=true'); // overrides the ?error=true one above + } elseif ( 'error_scrape' == $_GET['action'] ) { + check_admin_referer('plugin-activation-error_' . $plugin); + $valid = validate_plugin($plugin); + if ( is_wp_error($valid) ) + wp_die($valid); + error_reporting( E_ALL ^ E_NOTICE ); + @ini_set('display_errors', true); //Ensure that Fatal errors are displayed. + include(ABSPATH . PLUGINDIR . '/' . $plugin); + } elseif ( 'deactivate' == $_GET['action'] ) { check_admin_referer('deactivate-plugin_' . $_GET['plugin']); - $current = get_settings('active_plugins'); - array_splice($current, array_search( $_GET['plugin'], $current), 1 ); // Array-fu! - update_option('active_plugins', $current); - do_action('deactivate_' . trim( $_GET['plugin'] )); + deactivate_plugins($_GET['plugin']); wp_redirect('plugins.php?deactivate=true'); + } elseif ( 'deactivate-all' == $_GET['action'] ) { + check_admin_referer('deactivate-all'); + deactivate_all_plugins(); + wp_redirect('plugins.php?deactivate-all=true'); + } elseif ('reactivate-all' == $_GET['action']) { + check_admin_referer('reactivate-all'); + reactivate_all_plugins('plugins.php?errors=true'); + wp_redirect('plugins.php?reactivate-all=true'); // overrides the ?error=true one above } + exit; } $title = __('Manage Plugins'); require_once('admin-header.php'); -// Clean up options -// If any plugins don't exist, axe 'em - -$check_plugins = get_settings('active_plugins'); +validate_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); -} - -// 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'); - $key = array_search($check_plugin, $current); - if ( false !== $key && NULL !== $key ) { - unset($current[$key]); - update_option('active_plugins', $current); - } - } -} ?> - -

activated.') ?>

-
- - -

deactivated.') ?>

-
+ +

fatal error.') ?>

+ + + +
+ +

fatal error.') ?>

+ +

activated.') ?>

+ +

deactivated.') ?>

+ +

deactivated.'); ?>

+ +

reactivated.'); ?>

@@ -67,58 +70,107 @@ 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'; + $action_links = array(); + + $style = ''; - if (!empty($current_plugins) && in_array($plugin_file, $current_plugins)) { - $action = "".__('Deactivate').""; - $plugin_data['Title'] = "{$plugin_data['Title']}"; - $style .= $style == 'alternate' ? ' active' : 'active'; + if ( is_plugin_active($plugin_file) ) { + $action_links[] = "".__('Deactivate').""; + $style = 'active'; } else { - $action = "".__('Activate').""; + $action_links[] = "".__('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 . '"'; + if ( current_user_can('edit_plugins') && is_writable(ABSPATH . PLUGINDIR . '/' . $plugin_file) ) + $action_links[] = "".__('Edit').""; + + $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); + $author = ( empty($plugin_data['Author']) ) ? '' : ' ' . sprintf( __('By %s'), $plugin_data['Author'] ) . '.'; + + if ( $style != '' ) + $style = ' class="' . $style . '"'; + + $action_links = apply_filters('plugin_action_links', $action_links, $plugin_file, $plugin_info); + 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

"; + if ( is_plugin_active($plugin_file) ) + echo __('Active'); + else + _e('Inactive'); + echo "
+ -

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); ?>