]> scripts.mit.edu Git - autoinstallsdev/wordpress.git/blob - wp-admin/plugins.php
Wordpress 2.5.1
[autoinstallsdev/wordpress.git] / wp-admin / plugins.php
1 <?php
2 require_once('admin.php');
3
4 if ( isset($_GET['action']) ) {
5         if ( isset($_GET['plugin']) )
6                 $plugin = trim($_GET['plugin']);
7
8         if ( 'activate' == $_GET['action'] ) {
9                 check_admin_referer('activate-plugin_' . $_GET['plugin']);
10                 $result = activate_plugin($_GET['plugin'], 'plugins.php?error=true&plugin=' . $plugin);
11                 if ( is_wp_error( $result ) )
12                         wp_die( $result->get_error_message() );
13                 wp_redirect('plugins.php?activate=true'); // overrides the ?error=true one above
14         } elseif ( 'error_scrape' == $_GET['action'] ) {
15                 check_admin_referer('plugin-activation-error_' . $plugin);
16                 $valid = validate_plugin($plugin);
17                 if ( is_wp_error($valid) )
18                         wp_die($valid);
19                 error_reporting( E_ALL ^ E_NOTICE );
20                 @ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
21                 include(ABSPATH . PLUGINDIR . '/' . $plugin);
22         } elseif ( 'deactivate' == $_GET['action'] ) {
23                 check_admin_referer('deactivate-plugin_' . $_GET['plugin']);
24                 deactivate_plugins($_GET['plugin']);
25                 wp_redirect('plugins.php?deactivate=true');
26         } elseif ( 'deactivate-all' == $_GET['action'] ) {
27                 check_admin_referer('deactivate-all');
28                 deactivate_all_plugins();
29                 wp_redirect('plugins.php?deactivate-all=true');
30         } elseif ('reactivate-all' == $_GET['action']) {
31                 check_admin_referer('reactivate-all');
32                 reactivate_all_plugins('plugins.php?errors=true');
33                 wp_redirect('plugins.php?reactivate-all=true'); // overrides the ?error=true one above
34         }
35
36         exit;
37 }
38
39 $title = __('Manage Plugins');
40 require_once('admin-header.php');
41
42 validate_active_plugins();
43
44 ?>
45
46 <?php if ( isset($_GET['error']) ) : ?>
47         <div id="message" class="updated fade"><p><?php _e('Plugin could not be activated because it triggered a <strong>fatal error</strong>.') ?></p>
48         <?php
49                 $plugin = trim($_GET['plugin']);
50                 if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?>
51         <iframe style="border:0" width="100%" height="70px" src="<?php bloginfo('wpurl'); ?>/wp-admin/plugins.php?action=error_scrape&amp;plugin=<?php echo attribute_escape($plugin); ?>&amp;_wpnonce=<?php echo attribute_escape($_GET['_error_nonce']); ?>"></iframe>
52         <?php
53                 }
54         ?>
55         </div>
56 <?php elseif ( isset($_GET['errors']) ) : ?>
57         <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>
58 <?php elseif ( isset($_GET['activate']) ) : ?>
59         <div id="message" class="updated fade"><p><?php _e('Plugin <strong>activated</strong>.') ?></p></div>
60 <?php elseif ( isset($_GET['deactivate']) ) : ?>
61         <div id="message" class="updated fade"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p></div>
62 <?php elseif (isset($_GET['deactivate-all'])) : ?>
63         <div id="message" class="updated fade"><p><?php _e('All plugins <strong>deactivated</strong>.'); ?></p></div>
64 <?php elseif (isset($_GET['reactivate-all'])) : ?>
65         <div id="message" class="updated fade"><p><?php _e('Plugins <strong>reactivated</strong>.'); ?></p></div>
66 <?php endif; ?>
67
68 <div class="wrap">
69 <h2><?php _e('Plugin Management'); ?></h2>
70 <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>
71 <?php
72
73 $plugins = get_plugins();
74
75 if (empty($plugins)) {
76         echo '<p>';
77         _e("Couldn&#8217;t open plugins directory or there are no plugins available."); // TODO: make more helpful
78         echo '</p>';
79 } else {
80 ?>
81
82 <div class="tablenav">
83         <div class="alignleft">
84         <?php
85         $active = get_option('active_plugins');
86         $inactive = get_option('deactivated_plugins');
87         if ( !empty($active) ) {
88         ?>
89         <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>
90         <?php
91         } elseif ( empty($active) && !empty($inactive) ) {
92         ?>
93         <a class="button-secondary" href="<?php echo wp_nonce_url('plugins.php?action=reactivate-all', 'reactivate-all'); ?>" class="delete"><?php _e('Reactivate Plugins'); ?></a>
94         <?php
95         } // endif active/inactive plugin check
96         ?>
97         </div>
98         <br class="clear" />
99 </div>
100
101 <br class="clear" />
102
103 <table class="widefat">
104         <thead>
105         <tr>
106                 <th><?php _e('Plugin'); ?></th>
107                 <th class="num"><?php _e('Version'); ?></th>
108                 <th><?php _e('Description'); ?></th>
109                 <th class="status"><?php _e('Status') ?></th>
110                 <th class="action-links"><?php _e('Action'); ?></th>
111         </tr>
112         </thead>
113         <tbody id="plugins">
114 <?php
115         foreach($plugins as $plugin_file => $plugin_data) {
116                 $action_links = array();
117                 
118                 $style = '';
119
120                 if ( is_plugin_active($plugin_file) ) {
121                         $action_links[] = "<a href='" . wp_nonce_url("plugins.php?action=deactivate&amp;plugin=$plugin_file", 'deactivate-plugin_' . $plugin_file) . "' title='".__('Deactivate this plugin')."' class='delete'>".__('Deactivate')."</a>";
122                         $style = 'active';
123                 } else {
124                         $action_links[] = "<a href='" . wp_nonce_url("plugins.php?action=activate&amp;plugin=$plugin_file", 'activate-plugin_' . $plugin_file) . "' title='".__('Activate this plugin')."' class='edit'>".__('Activate')."</a>";
125                 }
126                 if ( current_user_can('edit_plugins') && is_writable(ABSPATH . PLUGINDIR . '/' . $plugin_file) )
127                         $action_links[] = "<a href='plugin-editor.php?file=$plugin_file' title='".__('Open this file in the Plugin Editor')."' class='edit'>".__('Edit')."</a>";
128
129                 $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array());
130
131                 // Sanitize all displayed data
132                 $plugin_data['Title']       = wp_kses($plugin_data['Title'], $plugins_allowedtags);
133                 $plugin_data['Version']     = wp_kses($plugin_data['Version'], $plugins_allowedtags);
134                 $plugin_data['Description'] = wp_kses($plugin_data['Description'], $plugins_allowedtags);
135                 $plugin_data['Author']      = wp_kses($plugin_data['Author'], $plugins_allowedtags);
136                 $author = ( empty($plugin_data['Author']) ) ? '' :  ' <cite>' . sprintf( __('By %s'), $plugin_data['Author'] ) . '.</cite>';
137
138                 if ( $style != '' )
139                         $style = ' class="' . $style . '"';
140
141                 $action_links = apply_filters('plugin_action_links', $action_links, $plugin_file, $plugin_info);
142
143                 echo "
144         <tr$style>
145                 <td class='name'>{$plugin_data['Title']}</td>
146                 <td class='vers'>{$plugin_data['Version']}</td>
147                 <td class='desc'><p>{$plugin_data['Description']}$author</p></td>
148                 <td class='status'>";
149                 if ( is_plugin_active($plugin_file) )
150                         echo  __('<span class="active">Active</span>');
151                 else
152                         _e('<span class="inactive">Inactive</span>');
153                 echo "</td>
154                 <td class='togl action-links'>$toggle";  
155                 if ( !empty($action_links) )
156                         echo implode(' | ', $action_links);
157                 echo "</td> 
158         </tr>";
159         do_action( 'after_plugin_row', $plugin_file );
160         }
161 ?>
162         </tbody>
163 </table>
164
165 <?php
166 }
167 ?>
168
169 <p><?php printf(__('If something goes wrong with a plugin and you can&#8217;t use WordPress, delete or rename that file in the <code>%s</code> directory and it will be automatically deactivated.'), PLUGINDIR); ?></p>
170
171 <h2><?php _e('Get More Plugins'); ?></h2>
172 <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>
173 <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>
174
175 </div>
176
177 <?php
178 include('admin-footer.php');
179 ?>