2 require_once('admin.php');
4 if ( isset($_GET['action']) ) {
5 if ('activate' == $_GET['action']) {
6 check_admin_referer('activate-plugin_' . $_GET['plugin']);
7 $current = get_option('active_plugins');
8 $plugin = trim($_GET['plugin']);
9 if ( validate_file($plugin) )
10 wp_die(__('Invalid plugin.'));
11 if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) )
12 wp_die(__('Plugin file does not exist.'));
13 if (!in_array($plugin, $current)) {
14 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
16 @include(ABSPATH . PLUGINDIR . '/' . $plugin);
19 update_option('active_plugins', $current);
20 do_action('activate_' . $plugin);
23 wp_redirect('plugins.php?activate=true'); // overrides the ?error=true one above
24 } elseif ('error_scrape' == $_GET['action']) {
25 $plugin = trim($_GET['plugin']);
26 check_admin_referer('plugin-activation-error_' . $plugin);
27 if ( validate_file($plugin) )
28 wp_die(__('Invalid plugin.'));
29 if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) )
30 wp_die(__('Plugin file does not exist.'));
31 include(ABSPATH . PLUGINDIR . '/' . $plugin);
32 } elseif ('deactivate' == $_GET['action']) {
33 check_admin_referer('deactivate-plugin_' . $_GET['plugin']);
34 $current = get_option('active_plugins');
35 array_splice($current, array_search( $_GET['plugin'], $current), 1 ); // Array-fu!
36 update_option('active_plugins', $current);
37 do_action('deactivate_' . trim( $_GET['plugin'] ));
38 wp_redirect('plugins.php?deactivate=true');
39 } elseif ($_GET['action'] == 'deactivate-all') {
40 check_admin_referer('deactivate-all');
41 $current = get_option('active_plugins');
43 foreach ($current as $plugin) {
44 array_splice($current, array_search($plugin, $current), 1);
45 do_action('deactivate_' . $plugin);
48 update_option('active_plugins', array());
49 wp_redirect('plugins.php?deactivate-all=true');
54 $title = __('Manage Plugins');
55 require_once('admin-header.php');
58 // If any plugins don't exist, axe 'em
60 $check_plugins = get_option('active_plugins');
62 // Sanity check. If the active plugin list is not an array, make it an
64 if ( !is_array($check_plugins) ) {
65 $check_plugins = array();
66 update_option('active_plugins', $check_plugins);
69 // If a plugin file does not exist, remove it from the list of active
71 foreach ($check_plugins as $check_plugin) {
72 if (!file_exists(ABSPATH . PLUGINDIR . '/' . $check_plugin)) {
73 $current = get_option('active_plugins');
74 $key = array_search($check_plugin, $current);
75 if ( false !== $key && NULL !== $key ) {
76 unset($current[$key]);
77 update_option('active_plugins', $current);
83 <?php if ( isset($_GET['error']) ) : ?>
84 <div id="message" class="updated fade"><p><?php _e('Plugin could not be activated because it triggered a <strong>fatal error</strong>.') ?></p>
86 $plugin = trim($_GET['plugin']);
87 if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) && 1 == strtolower(ini_get('display_errors'))) { ?>
88 <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>
93 <?php elseif ( isset($_GET['activate']) ) : ?>
94 <div id="message" class="updated fade"><p><?php _e('Plugin <strong>activated</strong>.') ?></p></div>
95 <?php elseif ( isset($_GET['deactivate']) ) : ?>
96 <div id="message" class="updated fade"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p></div>
97 <?php elseif (isset($_GET['deactivate-all'])) : ?>
98 <div id="message" class="updated fade"><p><?php _e('All plugins <strong>deactivated</strong>.'); ?></p></div>
102 <h2><?php _e('Plugin Management'); ?></h2>
103 <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>
106 if ( get_option('active_plugins') )
107 $current_plugins = get_option('active_plugins');
109 $plugins = get_plugins();
111 if (empty($plugins)) {
113 _e("Couldn’t open plugins directory or there are no plugins available."); // TODO: make more helpful
117 <table class="widefat plugins">
120 <th><?php _e('Plugin'); ?></th>
121 <th style="text-align: center"><?php _e('Version'); ?></th>
122 <th><?php _e('Description'); ?></th>
123 <th style="text-align: center"<?php if ( current_user_can('edit_plugins') ) echo ' colspan="2"'; ?>><?php _e('Action'); ?></th>
129 foreach($plugins as $plugin_file => $plugin_data) {
130 $style = ('class="alternate"' == $style|| 'class="alternate active"' == $style) ? '' : 'alternate';
132 if (!empty($current_plugins) && in_array($plugin_file, $current_plugins)) {
133 $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>";
134 $plugin_data['Title'] = "<strong>{$plugin_data['Title']}</strong>";
135 $style .= $style == 'alternate' ? ' active' : 'active';
137 $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>";
140 $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array());
142 // Sanitize all displayed data
143 $plugin_data['Title'] = wp_kses($plugin_data['Title'], $plugins_allowedtags);
144 $plugin_data['Version'] = wp_kses($plugin_data['Version'], $plugins_allowedtags);
145 $plugin_data['Description'] = wp_kses($plugin_data['Description'], $plugins_allowedtags);
146 $plugin_data['Author'] = wp_kses($plugin_data['Author'], $plugins_allowedtags);
149 $style = 'class="' . $style . '"';
150 if ( is_writable(ABSPATH . PLUGINDIR . '/' . $plugin_file) )
151 $edit = "<a href='plugin-editor.php?file=$plugin_file' title='".__('Open this file in the Plugin Editor')."' class='edit'>".__('Edit')."</a>";
155 $author = ( empty($plugin_data['Author']) ) ? '' : ' <cite>' . sprintf( __('By %s'), $plugin_data['Author'] ) . '.</cite>';
159 <td class='name'>{$plugin_data['Title']}</td>
160 <td class='vers'>{$plugin_data['Version']}</td>
161 <td class='desc'><p>{$plugin_data['Description']}$author</p></td>
162 <td class='togl'>$toggle</td>";
163 if ( current_user_can('edit_plugins') )
168 do_action( 'after_plugin_row', $plugin_file );
173 <td colspan="3"> </td>
174 <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>
182 <p><?php printf(__('If something goes wrong with a plugin and you can’t use WordPress, delete or rename that file in the <code>%s</code> directory and it will be automatically deactivated.'), PLUGINDIR); ?></p>
184 <h2><?php _e('Get More Plugins'); ?></h2>
185 <p><?php _e('You can find additional plugins for your site in the <a href="http://wordpress.org/extend/plugins/">WordPress plugin directory</a>.'); ?></p>
186 <p><?php printf(__('To install a plugin you generally just need to upload the plugin file into your <code>%s</code> directory. Once a plugin is uploaded, you may activate it here.'), PLUGINDIR); ?></p>
191 include('admin-footer.php');