diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2008-04-04 16:44:15 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2008-04-04 16:44:15 +0000 |
commit | 7740e89de3e1bc0cc636120e3ca8ab9e97e4d3cc (patch) | |
tree | c6fd23b598f3994eddb18cb1c0f2e8d95ff054fa /wp-admin/plugins.php | |
parent | f650f48c048bfbbb2ae702b6425d87e39358d748 (diff) | |
download | wordpress-mu-7740e89de3e1bc0cc636120e3ca8ab9e97e4d3cc.tar.gz wordpress-mu-7740e89de3e1bc0cc636120e3ca8ab9e97e4d3cc.tar.xz wordpress-mu-7740e89de3e1bc0cc636120e3ca8ab9e97e4d3cc.zip |
Merged with WordPress 2.5, unstable, only for testing
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1218 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-admin/plugins.php')
-rw-r--r-- | wp-admin/plugins.php | 164 |
1 files changed, 79 insertions, 85 deletions
diff --git a/wp-admin/plugins.php b/wp-admin/plugins.php index 8593424..1cd1a89 100644 --- a/wp-admin/plugins.php +++ b/wp-admin/plugins.php @@ -9,100 +9,67 @@ if( $menu_perms[ 'plugins' ] != 1 ) return; if ( isset($_GET['action']) ) { - if ('activate' == $_GET['action']) { - check_admin_referer('activate-plugin_' . $_GET['plugin']); - $current = get_option('active_plugins'); + if ( isset($_GET['plugin']) ) $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); - do_action('activate_' . $plugin); - ob_end_clean(); - } + + if ( 'activate' == $_GET['action'] ) { + check_admin_referer('activate-plugin_' . $_GET['plugin']); + $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']) { - $plugin = trim($_GET['plugin']); + } elseif ( 'error_scrape' == $_GET['action'] ) { 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.')); + $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']) { + } elseif ( 'deactivate' == $_GET['action'] ) { check_admin_referer('deactivate-plugin_' . $_GET['plugin']); - $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'] )); + deactivate_plugins($_GET['plugin']); wp_redirect('plugins.php?deactivate=true'); - } elseif ($_GET['action'] == 'deactivate-all') { + } elseif ( 'deactivate-all' == $_GET['action'] ) { 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()); + 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 +validate_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); -} - -// 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 . PLUGINDIR . '/' . $check_plugin)) { - $current = get_option('active_plugins'); - $key = array_search($check_plugin, $current); - if ( false !== $key && NULL !== $key ) { - unset($current[$key]); - update_option('active_plugins', $current); - } - } -} ?> <?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> <?php $plugin = trim($_GET['plugin']); - if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) && 1 == strtolower(ini_get('display_errors'))) { ?> + if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?> <iframe style="border:0" width="100%" height="70px" src="<?php bloginfo('wpurl'); ?>/wp-admin/plugins.php?action=error_scrape&plugin=<?php echo attribute_escape($plugin); ?>&_wpnonce=<?php echo attribute_escape($_GET['_error_nonce']); ?>"></iframe> <?php } ?> </div> +<?php elseif ( isset($_GET['errors']) ) : ?> + <div id="message" class="updated fade"><p><?php _e('Some plugins could not be reactivated because they triggered a <strong>fatal error</strong>.') ?></p></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']) ) : ?> <div id="message" class="updated fade"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p></div> <?php elseif (isset($_GET['deactivate-all'])) : ?> <div id="message" class="updated fade"><p><?php _e('All plugins <strong>deactivated</strong>.'); ?></p></div> +<?php elseif (isset($_GET['reactivate-all'])) : ?> + <div id="message" class="updated fade"><p><?php _e('Plugins <strong>reactivated</strong>.'); ?></p></div> <?php endif; ?> <div class="wrap"> @@ -110,9 +77,6 @@ foreach ($check_plugins as $check_plugin) { <p><?php _e('Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.'); ?></p> <?php -if ( get_option('active_plugins') ) - $current_plugins = get_option('active_plugins'); - $plugins = get_plugins(); if (empty($plugins)) { @@ -121,26 +85,50 @@ if (empty($plugins)) { echo '</p>'; } else { ?> -<table class="widefat plugins"> + +<div class="tablenav"> + <div class="alignleft"> + <?php + $active = get_option('active_plugins'); + $inactive = get_option('deactivated_plugins'); + if ( !empty($active) ) { + ?> + <a class="button-secondary" href="<?php echo wp_nonce_url('plugins.php?action=deactivate-all', 'deactivate-all'); ?>" class="delete"><?php _e('Deactivate All Plugins'); ?></a> + <?php + } elseif ( empty($active) && !empty($inactive) ) { + ?> + <a class="button-secondary" href="<?php echo wp_nonce_url('plugins.php?action=reactivate-all', 'reactivate-all'); ?>" class="delete"><?php _e('Reactivate Plugins'); ?></a> + <?php + } // endif active/inactive plugin check + ?> + </div> + <br class="clear" /> +</div> + +<br class="clear" /> + +<table class="widefat"> <thead> <tr> <th><?php _e('Plugin'); ?></th> - <th style="text-align: center"><?php _e('Version'); ?></th> + <th class="num"><?php _e('Version'); ?></th> <th><?php _e('Description'); ?></th> + <th class="status"><?php _e('Status') ?></th> + <th class="action-links"><?php _e('Action'); ?></th> </tr> </thead> + <tbody id="plugins"> <?php - $style = ''; - foreach($plugins as $plugin_file => $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)) { - $toggle = "<a href='" . wp_nonce_url("plugins.php?action=deactivate&plugin=$plugin_file", 'deactivate-plugin_' . $plugin_file) . "' title='".__('Deactivate this plugin')."' class='delete'>".__('Deactivate')."</a>"; - $plugin_data['Title'] = "<strong>{$plugin_data['Title']}</strong>"; - $style .= $style == 'alternate' ? ' active' : 'active'; + if ( is_plugin_active($plugin_file) ) { + $action_links[] = "<a href='" . wp_nonce_url("plugins.php?action=deactivate&plugin=$plugin_file", 'deactivate-plugin_' . $plugin_file) . "' title='".__('Deactivate this plugin')."' class='delete'>".__('Deactivate')."</a>"; + $style = 'active'; } else { - $toggle = "<a href='" . wp_nonce_url("plugins.php?action=activate&plugin=$plugin_file", 'activate-plugin_' . $plugin_file) . "' title='".__('Activate this plugin')."' class='edit'>".__('Activate')."</a>"; + $action_links[] = "<a href='" . wp_nonce_url("plugins.php?action=activate&plugin=$plugin_file", 'activate-plugin_' . $plugin_file) . "' title='".__('Activate this plugin')."' class='edit'>".__('Activate')."</a>"; } $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array()); @@ -150,29 +138,35 @@ if (empty($plugins)) { $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']) ) ? '' : ' <cite>' . sprintf( __('By %s'), $plugin_data['Author'] ) . '.</cite>'; if ( $style != '' ) - $style = 'class="' . $style . '"'; - $author = ( empty($plugin_data['Author']) ) ? '' : ' <cite>' . sprintf( __('By %s'), $plugin_data['Author'] ) . '.</cite>'; + $style = ' class="' . $style . '"'; + + $action_links = apply_filters('plugin_action_links', $action_links, $plugin_file, $plugin_info); echo " - <tr $style> + <tr$style> <td class='name'>{$plugin_data['Title']}</td> <td class='vers'>{$plugin_data['Version']}</td> <td class='desc'><p>{$plugin_data['Description']}$author</p></td> - <td class='togl'>$toggle</td>"; - echo" + <td class='status'>"; + if ( is_plugin_active($plugin_file) ) + echo __('<span class="active">Active</span>'); + else + _e('<span class="inactive">Inactive</span>'); + echo "</td> + <td class='togl action-links'>$toggle"; + if ( !empty($action_links) ) + echo implode(' | ', $action_links); + echo "</td> </tr>"; do_action( 'after_plugin_row', $plugin_file ); } ?> - -<tr> - <td colspan="3"> </td> - <td colspan="2" style="width:12em;"><a href="<?php echo wp_nonce_url('plugins.php?action=deactivate-all', 'deactivate-all'); ?>" class="delete"><?php _e('Deactivate All Plugins'); ?></a></td> -</tr> - + </tbody> </table> + <?php } ?> |