1 | <?php |
---|
2 | require_once('admin.php'); |
---|
3 | |
---|
4 | if ( isset($_GET['action']) ) { |
---|
5 | check_admin_referer(); |
---|
6 | |
---|
7 | if ('activate' == $_GET['action']) { |
---|
8 | $current = get_settings('active_plugins'); |
---|
9 | if (!in_array($_GET['plugin'], $current)) { |
---|
10 | $current[] = trim( $_GET['plugin'] ); |
---|
11 | } |
---|
12 | sort($current); |
---|
13 | update_option('active_plugins', $current); |
---|
14 | header('Location: plugins.php?activate=true'); |
---|
15 | } |
---|
16 | |
---|
17 | if ('deactivate' == $_GET['action']) { |
---|
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 | header('Location: plugins.php?deactivate=true'); |
---|
22 | } |
---|
23 | } |
---|
24 | |
---|
25 | $title = __('Manage Plugins'); |
---|
26 | require_once('admin-header.php'); |
---|
27 | |
---|
28 | // Clean up options |
---|
29 | // If any plugins don't exist, axe 'em |
---|
30 | |
---|
31 | $check_plugins = get_settings('active_plugins'); |
---|
32 | |
---|
33 | // Sanity check. If the active plugin list is not an array, make it an |
---|
34 | // empty array. |
---|
35 | if ( !is_array($check_plugins) ) { |
---|
36 | $check_plugins = array(); |
---|
37 | update_option('active_plugins', $check_plugins); |
---|
38 | } |
---|
39 | |
---|
40 | // If a plugin file does not exist, remove it from the list of active |
---|
41 | // plugins. |
---|
42 | foreach ($check_plugins as $check_plugin) { |
---|
43 | if (!file_exists(ABSPATH . 'wp-content/plugins/' . $check_plugin)) { |
---|
44 | $current = get_settings('active_plugins'); |
---|
45 | unset($current[$_GET['plugin']]); |
---|
46 | update_option('active_plugins', $current); |
---|
47 | } |
---|
48 | } |
---|
49 | ?> |
---|
50 | |
---|
51 | <?php if (isset($_GET['activate'])) : ?> |
---|
52 | <div class="updated"><p><?php _e('Plugin <strong>activated</strong>.') ?></p> |
---|
53 | </div> |
---|
54 | <?php endif; ?> |
---|
55 | <?php if (isset($_GET['deactivate'])) : ?> |
---|
56 | <div class="updated"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p> |
---|
57 | </div> |
---|
58 | <?php endif; ?> |
---|
59 | |
---|
60 | <div class="wrap"> |
---|
61 | <h2><?php _e('Plugin Management'); ?></h2> |
---|
62 | <p><?php _e('Plugins are files you usually download separately from WordPress that add functionality. To install a plugin you generally just need to put the plugin file into your <code>wp-content/plugins</code> directory. Once a plugin is installed, you may activate it or deactivate it here. If something goes wrong with a plugin and you can’t use WordPress, delete that plugin from the <code>wp-content/plugins</code> directory and it will be automatically deactivated.'); ?></p> |
---|
63 | <?php |
---|
64 | |
---|
65 | if ( get_settings('active_plugins') ) |
---|
66 | $current_plugins = get_settings('active_plugins'); |
---|
67 | |
---|
68 | $plugins = get_plugins(); |
---|
69 | |
---|
70 | if (empty($plugins)) { |
---|
71 | _e("<p>Couldn't open plugins directory or there are no plugins available.</p>"); // TODO: make more helpful |
---|
72 | } else { |
---|
73 | ?> |
---|
74 | <table width="100%" cellpadding="3" cellspacing="3"> |
---|
75 | <tr> |
---|
76 | <th><?php _e('Plugin'); ?></th> |
---|
77 | <th><?php _e('Version'); ?></th> |
---|
78 | <th><?php _e('Author'); ?></th> |
---|
79 | <th><?php _e('Description'); ?></th> |
---|
80 | <th><?php _e('Action'); ?></th> |
---|
81 | </tr> |
---|
82 | <?php |
---|
83 | $style = ''; |
---|
84 | foreach($plugins as $plugin_name => $plugin_data) { |
---|
85 | $plugin_file = $plugin_data['Filename']; |
---|
86 | |
---|
87 | $style = ('class="alternate"' == $style|| 'class="alternate active"' == $style) ? '' : 'alternate'; |
---|
88 | |
---|
89 | if (!empty($current_plugins) && in_array($plugin_file, $current_plugins)) { |
---|
90 | $action = "<a href='plugins.php?action=deactivate&plugin=$plugin_file' title='".__('Deactivate this plugin')."' class='delete'>".__('Deactivate')."</a>"; |
---|
91 | $plugin_data['Title'] = "<strong>{$plugin_data['Title']}</strong>"; |
---|
92 | $style .= $style == 'alternate' ? ' active' : 'active'; |
---|
93 | } else { |
---|
94 | $action = "<a href='plugins.php?action=activate&plugin=$plugin_file' title='".__('Activate this plugin')."' class='edit'>".__('Activate')."</a>"; |
---|
95 | } |
---|
96 | $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()) ); ; |
---|
97 | if ($style != '') $style = 'class="' . $style . '"'; |
---|
98 | echo " |
---|
99 | <tr $style> |
---|
100 | <td class=\"name\">{$plugin_data['Title']}</td> |
---|
101 | <td class=\"vers\">{$plugin_data['Version']}</td> |
---|
102 | <td class=\"auth\">{$plugin_data['Author']}</td> |
---|
103 | <td class=\"desc\">{$plugin_data['Description']}</td> |
---|
104 | <td class=\"togl\">$action</td> |
---|
105 | </tr>"; |
---|
106 | } |
---|
107 | ?> |
---|
108 | |
---|
109 | </table> |
---|
110 | <?php |
---|
111 | } |
---|
112 | ?> |
---|
113 | |
---|
114 | <h2><?php _e('Get More Plugins'); ?></h2> |
---|
115 | <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> |
---|
116 | |
---|
117 | </div> |
---|
118 | |
---|
119 | <?php |
---|
120 | include('admin-footer.php'); |
---|
121 | ?> |
---|