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_settings('active_plugins');
8 if (!in_array($_GET['plugin'], $current)) {
9 $current[] = trim( $_GET['plugin'] );
11 update_option('active_plugins', $current);
12 include(ABSPATH . 'wp-content/plugins/' . trim( $_GET['plugin'] ));
13 do_action('activate_' . trim( $_GET['plugin'] ));
15 wp_redirect('plugins.php?activate=true');
16 } else if ('deactivate' == $_GET['action']) {
17 check_admin_referer('deactivate-plugin_' . $_GET['plugin']);
18 $current = get_settings('active_plugins');
19 array_splice($current, array_search( $_GET['plugin'], $current), 1 ); // Array-fu!
20 update_option('active_plugins', $current);
21 do_action('deactivate_' . trim( $_GET['plugin'] ));
22 wp_redirect('plugins.php?deactivate=true');
27 $title = __('Manage Plugins');
28 require_once('admin-header.php');
31 // If any plugins don't exist, axe 'em
33 $check_plugins = get_settings('active_plugins');
35 // Sanity check. If the active plugin list is not an array, make it an
37 if ( !is_array($check_plugins) ) {
38 $check_plugins = array();
39 update_option('active_plugins', $check_plugins);
42 // If a plugin file does not exist, remove it from the list of active
44 foreach ($check_plugins as $check_plugin) {
45 if (!file_exists(ABSPATH . 'wp-content/plugins/' . $check_plugin)) {
46 $current = get_settings('active_plugins');
47 $key = array_search($check_plugin, $current);
48 if ( false !== $key && NULL !== $key ) {
49 unset($current[$key]);
50 update_option('active_plugins', $current);
56 <?php if (isset($_GET['activate'])) : ?>
57 <div id="message" class="updated fade"><p><?php _e('Plugin <strong>activated</strong>.') ?></p>
60 <?php if (isset($_GET['deactivate'])) : ?>
61 <div id="message" class="updated fade"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p>
66 <h2><?php _e('Plugin Management'); ?></h2>
67 <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>
70 if ( get_settings('active_plugins') )
71 $current_plugins = get_settings('active_plugins');
73 $plugins = get_plugins();
75 if (empty($plugins)) {
77 _e("Couldn't open plugins directory or there are no plugins available."); // TODO: make more helpful
81 <table width="100%" cellpadding="3" cellspacing="3">
83 <th><?php _e('Plugin'); ?></th>
84 <th><?php _e('Version'); ?></th>
85 <th><?php _e('Description'); ?></th>
86 <th><?php _e('Action'); ?></th>
91 function sort_plugins($plug1, $plug2) {
92 return strnatcasecmp($plug1['Name'], $plug2['Name']);
95 uksort($plugins, 'sort_plugins');
97 foreach($plugins as $plugin_file => $plugin_data) {
98 $style = ('class="alternate"' == $style|| 'class="alternate active"' == $style) ? '' : 'alternate';
100 if (!empty($current_plugins) && in_array($plugin_file, $current_plugins)) {
101 $action = "<a href='" . wp_nonce_url("plugins.php?action=deactivate&plugin=$plugin_file", 'deactivate-plugin_' . $plugin_file) . "' title='".__('Deactivate this plugin')."' class='delete'>".__('Deactivate')."</a>";
102 $plugin_data['Title'] = "<strong>{$plugin_data['Title']}</strong>";
103 $style .= $style == 'alternate' ? ' active' : 'active';
105 $action = "<a href='" . wp_nonce_url("plugins.php?action=activate&plugin=$plugin_file", 'activate-plugin_' . $plugin_file) . "' title='".__('Activate this plugin')."' class='edit'>".__('Activate')."</a>";
107 $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()) ); ;
108 if ($style != '') $style = 'class="' . $style . '"';
111 <td class='name'>{$plugin_data['Title']}</td>
112 <td class='vers'>{$plugin_data['Version']}</td>
113 <td class='desc'>{$plugin_data['Description']} <cite>".sprintf(__('By %s'), $plugin_data['Author']).".</cite></td>
114 <td class='togl'>$action</td>
124 <p><?php _e('If something goes wrong with a plugin and you can’t use WordPress, delete or rename that file in the <code>wp-content/plugins</code> directory and it will be automatically deactivated.'); ?></p>
126 <h2><?php _e('Get More Plugins'); ?></h2>
127 <p><?php _e('You can find additional plugins for your site in the <a href="http://wordpress.org/extend/plugins/">WordPress plugin directory</a>. To install a plugin you generally just need to upload the plugin file into your <code>wp-content/plugins</code> directory. Once a plugin is uploaded, you may activate it here.'); ?></p>
132 include('admin-footer.php');