3 * Plugins administration panel.
6 * @subpackage Administration
9 /** WordPress Administration Bootstrap */
10 require_once('./admin.php');
11 if ( is_multisite() ) {
12 $menu_perms = get_site_option( 'menu_items', array() );
14 if ( empty($menu_perms['plugins']) && ! is_super_admin() )
15 wp_die( __( 'Cheatin’ uh?' ) );
16 else if ( $menu_perms['plugins'] != 1 && is_super_admin() )
17 add_action( 'admin_notices', '_admin_notice_multisite_activate_plugins_page' );
20 if ( ! current_user_can( 'activate_plugins' ) )
21 wp_die( __( 'You do not have sufficient permissions to manage plugins for this site.' ) );
23 if ( isset($_POST['clear-recent-list']) )
24 $action = 'clear-recent-list';
25 elseif ( !empty($_REQUEST['action']) )
26 $action = $_REQUEST['action'];
27 elseif ( !empty($_REQUEST['action2']) )
28 $action = $_REQUEST['action2'];
32 $plugin = isset($_REQUEST['plugin']) ? $_REQUEST['plugin'] : '';
34 $default_status = get_user_option('plugins_last_view');
35 if ( empty($default_status) )
36 $default_status = 'all';
37 $status = isset($_REQUEST['plugin_status']) ? $_REQUEST['plugin_status'] : $default_status;
38 if ( !in_array($status, array('all', 'active', 'inactive', 'recent', 'upgrade', 'network', 'mustuse', 'dropins', 'search')) )
40 if ( $status != $default_status && 'search' != $status )
41 update_user_meta($current_user->ID, 'plugins_last_view', $status);
43 $page = isset($_REQUEST['paged']) ? $_REQUEST['paged'] : 1;
45 //Clean up request URI from temporary args for screen options/paging uri's to work as expected.
46 $_SERVER['REQUEST_URI'] = remove_query_arg(array('error', 'deleted', 'activate', 'activate-multi', 'deactivate', 'deactivate-multi', '_error_nonce'), $_SERVER['REQUEST_URI']);
48 if ( !empty($action) ) {
49 $network_wide = false;
50 if ( ( isset( $_GET['networkwide'] ) || 'network-activate-selected' == $action ) && is_multisite() && current_user_can( 'manage_network_plugins' ) )
55 if ( ! current_user_can('activate_plugins') )
56 wp_die(__('You do not have sufficient permissions to activate plugins for this site.'));
58 check_admin_referer('activate-plugin_' . $plugin);
60 $result = activate_plugin($plugin, 'plugins.php?error=true&plugin=' . $plugin, $network_wide);
61 if ( is_wp_error( $result ) ) {
62 if ( 'unexpected_output' == $result->get_error_code() ) {
63 $redirect = 'plugins.php?error=true&charsout=' . strlen($result->get_error_data()) . '&plugin=' . $plugin;
64 wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect));
71 $recent = (array)get_option('recently_activated');
72 if ( isset($recent[ $plugin ]) ) {
73 unset($recent[ $plugin ]);
74 update_option('recently_activated', $recent);
76 if ( isset($_GET['from']) && 'import' == $_GET['from'] ) {
77 wp_redirect("import.php?import=" . str_replace('-importer', '', dirname($plugin)) ); // overrides the ?error=true one above and redirects to the Imports page, striping the -importer suffix
79 wp_redirect("plugins.php?activate=true&plugin_status=$status&paged=$page"); // overrides the ?error=true one above
83 case 'activate-selected':
84 case 'network-activate-selected':
85 if ( ! current_user_can('activate_plugins') )
86 wp_die(__('You do not have sufficient permissions to activate plugins for this site.'));
88 check_admin_referer('bulk-manage-plugins');
90 $plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
91 $plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); // Only activate plugins which are not already active.
92 if ( empty($plugins) ) {
93 wp_redirect("plugins.php?plugin_status=$status&paged=$page");
97 activate_plugins($plugins, 'plugins.php?error=true', $network_wide);
99 $recent = (array)get_option('recently_activated');
100 foreach ( $plugins as $plugin => $time)
101 if ( isset($recent[ $plugin ]) )
102 unset($recent[ $plugin ]);
104 update_option('recently_activated', $recent);
106 wp_redirect("plugins.php?activate-multi=true&plugin_status=$status&paged=$page");
109 case 'update-selected' :
111 check_admin_referer( 'bulk-manage-plugins' );
113 if ( isset( $_GET['plugins'] ) )
114 $plugins = explode( ',', $_GET['plugins'] );
115 elseif ( isset( $_POST['checked'] ) )
116 $plugins = (array) $_POST['checked'];
120 $title = __( 'Upgrade Plugins' );
121 $parent_file = 'plugins.php';
123 require_once( './admin-header.php' );
125 echo '<div class="wrap">';
127 echo '<h2>' . esc_html( $title ) . '</h2>';
130 $url = 'update.php?action=update-selected&plugins=' . urlencode( join(',', $plugins) );
131 $url = wp_nonce_url($url, 'bulk-update-plugins');
133 echo "<iframe src='$url' style='width: 100%; height:100%; min-height:850px;'></iframe>";
135 require_once( './admin-footer.php' );
139 if ( ! current_user_can('activate_plugins') )
140 wp_die(__('You do not have sufficient permissions to activate plugins for this site.'));
142 check_admin_referer('plugin-activation-error_' . $plugin);
144 $valid = validate_plugin($plugin);
145 if ( is_wp_error($valid) )
149 if ( defined('E_RECOVERABLE_ERROR') )
150 error_reporting(E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR);
152 error_reporting(E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING);
155 @ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
156 // Go back to "sandbox" scope so we get the same errors as before
157 function plugin_sandbox_scrape( $plugin ) {
158 include( WP_PLUGIN_DIR . '/' . $plugin );
160 plugin_sandbox_scrape( $plugin );
161 do_action('activate_' . $plugin);
165 if ( ! current_user_can('activate_plugins') )
166 wp_die(__('You do not have sufficient permissions to deactivate plugins for this site.'));
168 check_admin_referer('deactivate-plugin_' . $plugin);
169 deactivate_plugins($plugin);
170 update_option('recently_activated', array($plugin => time()) + (array)get_option('recently_activated'));
172 echo "<meta http-equiv='refresh' content='" . esc_attr( "0;url=plugins.php?deactivate=true&plugin_status=$status&paged=$page" ) . "' />";
174 wp_redirect("plugins.php?deactivate=true&plugin_status=$status&paged=$page");
177 case 'deactivate-selected':
178 if ( ! current_user_can('activate_plugins') )
179 wp_die(__('You do not have sufficient permissions to deactivate plugins for this site.'));
181 check_admin_referer('bulk-manage-plugins');
183 $plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
184 $plugins = array_filter($plugins, 'is_plugin_active'); //Do not deactivate plugins which are already deactivated.
185 if ( empty($plugins) ) {
186 wp_redirect("plugins.php?plugin_status=$status&paged=$page");
190 deactivate_plugins($plugins);
192 $deactivated = array();
193 foreach ( $plugins as $plugin )
194 $deactivated[ $plugin ] = time();
196 update_option('recently_activated', $deactivated + (array)get_option('recently_activated'));
197 wp_redirect("plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page");
200 case 'delete-selected':
201 if ( ! current_user_can('delete_plugins') )
202 wp_die(__('You do not have sufficient permissions to delete plugins for this site.'));
204 check_admin_referer('bulk-manage-plugins');
206 //$_POST = from the plugin form; $_GET = from the FTP details screen.
207 $plugins = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array();
208 $plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); //Do not allow to delete Activated plugins.
209 if ( empty($plugins) ) {
210 wp_redirect("plugins.php?plugin_status=$status&paged=$page");
214 include(ABSPATH . 'wp-admin/update.php');
216 $parent_file = 'plugins.php';
218 if ( ! isset($_REQUEST['verify-delete']) ) {
219 wp_enqueue_script('jquery');
220 require_once('./admin-header.php');
224 $files_to_delete = $plugin_info = array();
225 foreach ( (array) $plugins as $plugin ) {
226 if ( '.' == dirname($plugin) ) {
227 $files_to_delete[] = WP_PLUGIN_DIR . '/' . $plugin;
228 if( $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin) ) {
229 $plugin_info[ $plugin ] = $data;
230 $plugin_info[ $plugin ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
233 // Locate all the files in that folder
234 $files = list_files( WP_PLUGIN_DIR . '/' . dirname($plugin) );
236 $files_to_delete = array_merge($files_to_delete, $files);
238 // Get plugins list from that folder
239 if ( $folder_plugins = get_plugins( '/' . dirname($plugin)) ) {
240 foreach( $folder_plugins as $plugin_file => $data ) {
241 $plugin_info[ $plugin_file ] = $data;
242 $plugin_info[ $plugin_file ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
248 $plugins_to_delete = count( $plugin_info );
249 echo '<h2>' . _n( 'Delete Plugin', 'Delete Plugins', $plugins_to_delete ) . '</h2>';
251 <p><?php echo _n( 'You are about to remove the following plugin:', 'You are about to remove the following plugins:', $plugins_to_delete ); ?></p>
254 $data_to_delete = false;
255 foreach ( $plugin_info as $plugin ) {
256 if ( $plugin['is_uninstallable'] ) {
257 /* translators: 1: plugin name, 2: plugin author */
258 echo '<li>', sprintf( __( '<strong>%1$s</strong> by <em>%2$s</em> (will also <strong>delete its data</strong>)' ), $plugin['Name'], $plugin['Author'] ), '</li>';
259 $data_to_delete = true;
261 /* translators: 1: plugin name, 2: plugin author */
262 echo '<li>', sprintf( __('<strong>%1$s</strong> by <em>%2$s</em>' ), $plugin['Name'], $plugin['Author'] ), '</li>';
268 if ( $data_to_delete )
269 _e('Are you sure you wish to delete these files and data?');
271 _e('Are you sure you wish to delete these files?');
273 <form method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>" style="display:inline;">
274 <input type="hidden" name="verify-delete" value="1" />
275 <input type="hidden" name="action" value="delete-selected" />
277 foreach ( (array)$plugins as $plugin )
278 echo '<input type="hidden" name="checked[]" value="' . esc_attr($plugin) . '" />';
280 <?php wp_nonce_field('bulk-manage-plugins') ?>
281 <input type="submit" name="submit" value="<?php $data_to_delete ? esc_attr_e('Yes, Delete these files and data') : esc_attr_e('Yes, Delete these files') ?>" class="button" />
283 <form method="post" action="<?php echo esc_url(wp_get_referer()); ?>" style="display:inline;">
284 <input type="submit" name="submit" value="<?php esc_attr_e('No, Return me to the plugin list') ?>" class="button" />
287 <p><a href="#" onclick="jQuery('#files-list').toggle(); return false;"><?php _e('Click to view entire list of files which will be deleted'); ?></a></p>
288 <div id="files-list" style="display:none;">
291 foreach ( (array)$files_to_delete as $file )
292 echo '<li>' . str_replace(WP_PLUGIN_DIR, '', $file) . '</li>';
298 require_once('./admin-footer.php');
300 } //Endif verify-delete
301 $delete_result = delete_plugins($plugins);
303 set_transient('plugins_delete_result_'.$user_ID, $delete_result); //Store the result in a cache rather than a URL param due to object type & length
304 wp_redirect("plugins.php?deleted=true&plugin_status=$status&paged=$page");
307 case 'clear-recent-list':
308 update_option('recently_activated', array());
313 wp_enqueue_script('plugin-install');
316 add_contextual_help($current_screen,
317 '<p>' . __('Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.') . '</p>' .
318 '<p>' . sprintf(__('You can find additional plugins for your site by using the <a href="%1$s">Plugin Browser/Installer</a> functionality or by browsing the <a href="%2$s" target="_blank">WordPress Plugin Directory</a> directly and installing new plugins manually. To manually install a plugin you generally just need to upload the plugin file into your <code>/wp-content/plugins</code> directory. Once a plugin has been installed, you can activate it here.'), 'plugin-install.php', 'http://wordpress.org/extend/plugins/') . '</p>' .
319 '<p>' . __('Most of the time, plugins play nicely with the core of WordPress and with other plugins. Sometimes, though, a plugin’s code will get in the way of another plugin, causing compatibility issues. If your site starts doing strange things, this may be the problem. Try deactivating all your plugins and re-activating them in various combinations until you isolate which one(s) caused the issue.') . '</p>' .
320 '<p>' . sprintf( __('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.'), WP_PLUGIN_DIR) . '</p>' .
321 '<p><strong>' . __('For more information:') . '</strong></p>' .
322 '<p>' . __('<a href="http://codex.wordpress.org/Managing_Plugins#Plugin_Management" target="_blank">Documentation on Managing Plugins</a>') . '</p>' .
323 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
326 $title = __('Plugins');
328 require_once('./admin-header.php');
330 $invalid = validate_active_plugins();
331 if ( !empty($invalid) )
332 foreach ( $invalid as $plugin_file => $error )
333 echo '<div id="message" class="error"><p>' . sprintf(__('The plugin <code>%s</code> has been <strong>deactivated</strong> due to an error: %s'), esc_html($plugin_file), $error->get_error_message()) . '</p></div>';
336 <?php if ( isset($_GET['error']) ) :
338 if ( isset($_GET['charsout']) )
339 $errmsg = sprintf(__('The plugin generated %d characters of <strong>unexpected output</strong> during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.'), $_GET['charsout']);
341 $errmsg = __('Plugin could not be activated because it triggered a <strong>fatal error</strong>.');
343 <div id="message" class="updated"><p><?php echo $errmsg; ?></p>
345 if ( !isset($_GET['charsout']) && wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?>
346 <iframe style="border:0" width="100%" height="70px" src="<?php echo admin_url('plugins.php?action=error_scrape&plugin=' . esc_attr($plugin) . '&_wpnonce=' . esc_attr($_GET['_error_nonce'])); ?>"></iframe>
351 <?php elseif ( isset($_GET['deleted']) ) :
352 $delete_result = get_transient('plugins_delete_result_'.$user_ID);
353 delete_transient('plugins_delete_result'); //Delete it once we're done.
355 if ( is_wp_error($delete_result) ) : ?>
356 <div id="message" class="updated"><p><?php printf( __('Plugin could not be deleted due to an error: %s'), $delete_result->get_error_message() ); ?></p></div>
358 <div id="message" class="updated"><p><?php _e('The selected plugins have been <strong>deleted</strong>.'); ?></p></div>
360 <?php elseif ( isset($_GET['activate']) ) : ?>
361 <div id="message" class="updated"><p><?php _e('Plugin <strong>activated</strong>.') ?></p></div>
362 <?php elseif (isset($_GET['activate-multi'])) : ?>
363 <div id="message" class="updated"><p><?php _e('Selected plugins <strong>activated</strong>.'); ?></p></div>
364 <?php elseif ( isset($_GET['deactivate']) ) : ?>
365 <div id="message" class="updated"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p></div>
366 <?php elseif (isset($_GET['deactivate-multi'])) : ?>
367 <div id="message" class="updated"><p><?php _e('Selected plugins <strong>deactivated</strong>.'); ?></p></div>
368 <?php elseif ( 'update-selected' == $action ) : ?>
369 <div id="message" class="updated"><p><?php _e('No out of date plugins were selected.'); ?></p></div>
373 <?php screen_icon(); ?>
374 <h2><?php echo esc_html( $title ); if ( current_user_can('install_plugins') ) { ?> <a href="plugin-install.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'plugin'); ?></a><?php } ?></h2>
378 $all_plugins = apply_filters( 'all_plugins', get_plugins() );
379 $search_plugins = array();
380 $active_plugins = array();
381 $inactive_plugins = array();
382 $recent_plugins = array();
383 $recently_activated = get_option('recently_activated', array());
384 $upgrade_plugins = array();
385 $network_plugins = array();
386 $mustuse_plugins = $dropins_plugins = array();
387 if ( ! is_multisite() || current_user_can('manage_network_plugins') ) {
388 if ( apply_filters( 'show_advanced_plugins', true, 'mustuse' ) )
389 $mustuse_plugins = get_mu_plugins();
390 if ( apply_filters( 'show_advanced_plugins', true, 'dropins' ) )
391 $dropins_plugins = get_dropins();
394 set_transient( 'plugin_slugs', array_keys($all_plugins), 86400 );
396 // Clean out any plugins which were deactivated over a week ago.
397 foreach ( $recently_activated as $key => $time )
398 if ( $time + (7*24*60*60) < time() ) //1 week
399 unset($recently_activated[ $key ]);
400 if ( $recently_activated != get_option('recently_activated') ) //If array changed, update it.
401 update_option('recently_activated', $recently_activated);
402 $current = get_site_transient( 'update_plugins' );
404 foreach ( array( 'all_plugins', 'mustuse_plugins', 'dropins_plugins' ) as $plugin_array_name) {
405 foreach ( (array) $$plugin_array_name as $plugin_file => $plugin_data ) {
406 // Translate, Apply Markup, Sanitize HTML
407 $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true);
408 ${$plugin_array_name}[ $plugin_file ] = $plugin_data;
411 unset( $plugin_array_name );
413 foreach ( (array) $all_plugins as $plugin_file => $plugin_data) {
414 // Filter into individual sections
415 if ( is_multisite() && is_network_only_plugin( $plugin_file ) && !current_user_can( 'manage_network_plugins' ) ) {
416 unset( $all_plugins[ $plugin_file ] );
418 } elseif ( is_plugin_active_for_network($plugin_file) ) {
419 $network_plugins[ $plugin_file ] = $plugin_data;
420 } elseif ( is_plugin_active($plugin_file) ) {
421 $active_plugins[ $plugin_file ] = $plugin_data;
423 if ( isset( $recently_activated[ $plugin_file ] ) ) // Was the plugin recently activated?
424 $recent_plugins[ $plugin_file ] = $plugin_data;
425 $inactive_plugins[ $plugin_file ] = $plugin_data;
428 if ( isset( $current->response[ $plugin_file ] ) )
429 $upgrade_plugins[ $plugin_file ] = $plugin_data;
432 if ( !current_user_can('update_plugins') )
433 $upgrade_plugins = array();
435 $total_all_plugins = count($all_plugins);
436 $total_inactive_plugins = count($inactive_plugins);
437 $total_active_plugins = count($active_plugins);
438 $total_recent_plugins = count($recent_plugins);
439 $total_upgrade_plugins = count($upgrade_plugins);
440 $total_network_plugins = count($network_plugins);
441 $total_mustuse_plugins = count($mustuse_plugins);
442 $total_dropins_plugins = count($dropins_plugins);
445 if ( !empty($_GET['s']) ) {
446 function _search_plugins_filter_callback($plugin) {
448 if ( is_null($term) )
449 $term = stripslashes($_GET['s']);
450 if ( stripos($plugin['Name'], $term) !== false ||
451 stripos($plugin['Description'], $term) !== false ||
452 stripos($plugin['Author'], $term) !== false ||
453 stripos($plugin['PluginURI'], $term) !== false ||
454 stripos($plugin['AuthorURI'], $term) !== false ||
455 stripos($plugin['Version'], $term) !== false )
461 $search_plugins = array_filter($all_plugins, '_search_plugins_filter_callback');
462 $total_search_plugins = count($search_plugins);
465 $plugin_array_name = "${status}_plugins";
466 if ( empty($$plugin_array_name) && !in_array($status, array('all', 'search')) ) {
468 $plugin_array_name = "${status}_plugins";
471 $plugins = &$$plugin_array_name;
474 $total_this_page = "total_{$status}_plugins";
475 $total_this_page = $$total_this_page;
476 $plugins_per_page = (int) get_user_option( 'plugins_per_page' );
477 if ( empty( $plugins_per_page ) || $plugins_per_page < 1 )
478 $plugins_per_page = 999;
479 $plugins_per_page = apply_filters( 'plugins_per_page', $plugins_per_page );
481 $start = ($page - 1) * $plugins_per_page;
483 $page_links = paginate_links( array(
484 'base' => add_query_arg( 'paged', '%#%' ),
486 'prev_text' => __('«'),
487 'next_text' => __('»'),
488 'total' => ceil($total_this_page / $plugins_per_page),
491 $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
492 number_format_i18n( $start + 1 ),
493 number_format_i18n( min( $page * $plugins_per_page, $total_this_page ) ),
494 '<span class="total-type-count">' . number_format_i18n( $total_this_page ) . '</span>',
501 * @param array $plugins
502 * @param string $context
504 function print_plugins_table($plugins, $context = '') {
506 $checkbox = ! in_array( $context, array( 'mustuse', 'dropins' ) ) ? '<input type="checkbox" />' : '';
508 <table class="widefat" cellspacing="0" id="<?php echo $context ?>-plugins-table">
511 <th scope="col" class="manage-column check-column"><?php echo $checkbox; ?></th>
512 <th scope="col" class="manage-column"><?php _e('Plugin'); ?></th>
513 <th scope="col" class="manage-column"><?php _e('Description'); ?></th>
519 <th scope="col" class="manage-column check-column"><?php echo $checkbox; ?></th>
520 <th scope="col" class="manage-column"><?php _e('Plugin'); ?></th>
521 <th scope="col" class="manage-column"><?php _e('Description'); ?></th>
525 <tbody class="plugins">
528 if ( empty($plugins) ) {
530 <td colspan="3">' . __('No plugins to show') . '</td>
533 foreach ( (array)$plugins as $plugin_file => $plugin_data) {
536 'network_deactivate' => '', 'deactivate' => '',
537 'network_only' => '', 'activate' => '',
538 'network_activate' => '',
543 if ( 'mustuse' == $context ) {
545 } elseif ( 'dropins' == $context ) {
546 $dropins = _get_dropins();
547 $plugin_name = $plugin_file;
548 if ( $plugin_file != $plugin_data['Name'] )
549 $plugin_name .= '<br/>' . $plugin_data['Name'];
550 if ( true === ( $dropins[ $plugin_file ][1] ) ) { // Doesn't require a constant
552 $description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
553 } elseif ( constant( $dropins[ $plugin_file ][1] ) ) { // Constant is true
555 $description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
558 $description = '<strong>' . $dropins[ $plugin_file ][0] . ' <span class="attention">' . __('Inactive:') . '</span></strong> ' . sprintf( __( 'Requires <code>%s</code> in <code>wp-config.php</code>.' ), "define('" . $dropins[ $plugin_file ][1] . "', true);" ) . '</p>';
560 $description .= '<p>' . $plugin_data['Description'] . '</p>';
562 $is_active_for_network = is_plugin_active_for_network($plugin_file);
563 $is_active = $is_active_for_network || is_plugin_active( $plugin_file );
564 if ( $is_active_for_network && !is_super_admin() )
568 if ( $is_active_for_network ) {
569 if ( is_super_admin() )
570 $actions['network_deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&networkwide=1&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Network Deactivate') . '</a>';
572 $actions['deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Deactivate') . '</a>';
575 if ( is_multisite() && is_network_only_plugin( $plugin_file ) )
576 $actions['network_only'] = '<span title="' . __('This plugin can only be activated for all sites in a network') . '">' . __('Network Only') . '</span>';
578 $actions['activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin') . '" class="edit">' . __('Activate') . '</a>';
580 if ( is_multisite() && current_user_can( 'manage_network_plugins' ) )
581 $actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&networkwide=1&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin for all sites in this network') . '" class="edit">' . __('Network Activate') . '</a>';
583 if ( current_user_can('delete_plugins') )
584 $actions['delete'] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&checked[]=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'bulk-manage-plugins') . '" title="' . __('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>';
585 } // end if $is_active
587 if ( current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) )
588 $actions['edit'] = '<a href="plugin-editor.php?file=' . $plugin_file . '" title="' . __('Open this file in the Plugin Editor') . '" class="edit">' . __('Edit') . '</a>';
591 $actions = apply_filters( 'plugin_action_links', array_filter( $actions ), $plugin_file, $plugin_data, $context );
592 $actions = apply_filters( "plugin_action_links_$plugin_file", $actions, $plugin_file, $plugin_data, $context );
594 $class = $is_active ? 'active' : 'inactive';
595 $checkbox = in_array( $context, array( 'mustuse', 'dropins' ) ) ? '' : "<input type='checkbox' name='checked[]' value='" . esc_attr($plugin_file) . "' />";
596 if ( 'dropins' != $context ) {
597 $description = '<p>' . $plugin_data['Description'] . '</p>';
598 $plugin_name = $plugin_data['Name'];
602 <th scope='row' class='check-column'>$checkbox</th>
603 <td class='plugin-title'><strong>$plugin_name</strong></td>
604 <td class='desc'>$description</td>
606 <tr class='$class second'>
608 <td class='plugin-title'>";
609 echo '<div class="row-actions-visible">';
610 foreach ( $actions as $action => $link ) {
611 $sep = end($actions) == $link ? '' : ' | ';
612 echo "<span class='$action'>$link$sep</span>";
616 $plugin_meta = array();
617 if ( !empty($plugin_data['Version']) )
618 $plugin_meta[] = sprintf(__('Version %s'), $plugin_data['Version']);
619 if ( !empty($plugin_data['Author']) ) {
620 $author = $plugin_data['Author'];
621 if ( !empty($plugin_data['AuthorURI']) )
622 $author = '<a href="' . $plugin_data['AuthorURI'] . '" title="' . __( 'Visit author homepage' ) . '">' . $plugin_data['Author'] . '</a>';
623 $plugin_meta[] = sprintf( __('By %s'), $author );
625 if ( ! empty($plugin_data['PluginURI']) )
626 $plugin_meta[] = '<a href="' . $plugin_data['PluginURI'] . '" title="' . __( 'Visit plugin site' ) . '">' . __('Visit plugin site') . '</a>';
628 $plugin_meta = apply_filters('plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $context);
629 echo implode(' | ', $plugin_meta);
633 do_action( 'after_plugin_row', $plugin_file, $plugin_data, $context );
634 do_action( "after_plugin_row_$plugin_file", $plugin_file, $plugin_data, $context );
640 } //End print_plugins_table()
645 * @param string $context
647 function print_plugin_actions($context, $field_name = 'action' ) {
648 if ( in_array( $context, array( 'mustuse', 'dropins' ) ) )
651 <div class="alignleft actions">
652 <select name="<?php echo $field_name; ?>">
653 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
654 <?php if ( 'active' != $context ) : ?>
655 <option value="activate-selected"><?php _e('Activate'); ?></option>
657 <?php if ( is_multisite() && 'network' != $context ) : ?>
658 <option value="network-activate-selected"><?php _e('Network Activate'); ?></option>
660 <?php if ( 'inactive' != $context && 'recent' != $context ) : ?>
661 <option value="deactivate-selected"><?php _e('Deactivate'); ?></option>
663 <?php if ( current_user_can( 'update_plugins' ) ) : ?>
664 <option value="update-selected"><?php _e( 'Upgrade' ); ?></option>
666 <?php if ( current_user_can('delete_plugins') && ( 'active' != $context ) ) : ?>
667 <option value="delete-selected"><?php _e('Delete'); ?></option>
670 <input type="submit" name="doaction_active" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary action" />
671 <?php if ( 'recent' == $context ) : ?>
672 <input type="submit" name="clear-recent-list" value="<?php esc_attr_e('Clear List') ?>" class="button-secondary" />
679 <form method="get" action="">
680 <p class="search-box">
681 <label class="screen-reader-text" for="plugin-search-input"><?php _e( 'Search Plugins' ); ?>:</label>
682 <input type="text" id="plugin-search-input" name="s" value="<?php _admin_search_query(); ?>" />
683 <input type="submit" value="<?php esc_attr_e( 'Search Installed Plugins' ); ?>" class="button" />
687 <?php do_action( 'pre_current_active_plugins', $all_plugins ) ?>
689 <form method="post" action="<?php echo admin_url('plugins.php') ?>">
690 <?php wp_nonce_field('bulk-manage-plugins') ?>
691 <input type="hidden" name="plugin_status" value="<?php echo esc_attr($status) ?>" />
692 <input type="hidden" name="paged" value="<?php echo esc_attr($page) ?>" />
694 <ul class="subsubsub">
696 $status_links = array();
697 $class = ( 'all' == $status ) ? ' class="current"' : '';
698 $status_links[] = "<li><a href='plugins.php?plugin_status=all' $class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_all_plugins, 'plugins' ), number_format_i18n( $total_all_plugins ) ) . '</a>';
699 if ( ! empty($active_plugins) ) {
700 $class = ( 'active' == $status ) ? ' class="current"' : '';
701 $status_links[] = "<li><a href='plugins.php?plugin_status=active' $class>" . sprintf( _n( 'Active <span class="count">(%s)</span>', 'Active <span class="count">(%s)</span>', $total_active_plugins ), number_format_i18n( $total_active_plugins ) ) . '</a>';
703 if ( ! empty($recent_plugins) ) {
704 $class = ( 'recent' == $status ) ? ' class="current"' : '';
705 $status_links[] = "<li><a href='plugins.php?plugin_status=recent' $class>" . sprintf( _n( 'Recently Active <span class="count">(%s)</span>', 'Recently Active <span class="count">(%s)</span>', $total_recent_plugins ), number_format_i18n( $total_recent_plugins ) ) . '</a>';
707 if ( ! empty($inactive_plugins) ) {
708 $class = ( 'inactive' == $status ) ? ' class="current"' : '';
709 $status_links[] = "<li><a href='plugins.php?plugin_status=inactive' $class>" . sprintf( _n( 'Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', $total_inactive_plugins ), number_format_i18n( $total_inactive_plugins ) ) . '</a>';
711 if ( ! empty($network_plugins) ) {
712 $class = ( 'network' == $status ) ? ' class="current"' : '';
713 $status_links[] = "<li><a href='plugins.php?plugin_status=network' $class>" . sprintf( _n( 'Network <span class="count">(%s)</span>', 'Network <span class="count">(%s)</span>', $total_network_plugins ), number_format_i18n( $total_network_plugins ) ) . '</a>';
715 if ( ! empty($mustuse_plugins) ) {
716 $class = ( 'mustuse' == $status ) ? ' class="current"' : '';
717 $status_links[] = "<li><a href='plugins.php?plugin_status=mustuse' $class>" . sprintf( _n( 'Must-Use <span class="count">(%s)</span>', 'Must-Use <span class="count">(%s)</span>', $total_mustuse_plugins ), number_format_i18n( $total_mustuse_plugins ) ) . '</a>';
719 if ( ! empty($dropins_plugins) ) {
720 $class = ( 'dropins' == $status ) ? ' class="current"' : '';
721 $status_links[] = "<li><a href='plugins.php?plugin_status=dropins' $class>" . sprintf( _n( 'Drop-ins <span class="count">(%s)</span>', 'Drop-ins <span class="count">(%s)</span>', $total_dropins_plugins ), number_format_i18n( $total_dropins_plugins ) ) . '</a>';
723 if ( ! empty($upgrade_plugins) ) {
724 $class = ( 'upgrade' == $status ) ? ' class="current"' : '';
725 $status_links[] = "<li><a href='plugins.php?plugin_status=upgrade' $class>" . sprintf( _n( 'Upgrade Available <span class="count">(%s)</span>', 'Upgrade Available <span class="count">(%s)</span>', $total_upgrade_plugins ), number_format_i18n( $total_upgrade_plugins ) ) . '</a>';
727 if ( ! empty($search_plugins) ) {
728 $class = ( 'search' == $status ) ? ' class="current"' : '';
729 $term = isset($_REQUEST['s']) ? urlencode(stripslashes($_REQUEST['s'])) : '';
730 $status_links[] = "<li><a href='plugins.php?s=$term' $class>" . sprintf( _n( 'Search Results <span class="count">(%s)</span>', 'Search Results <span class="count">(%s)</span>', $total_search_plugins ), number_format_i18n( $total_search_plugins ) ) . '</a>';
732 echo implode( " |</li>\n", $status_links ) . '</li>';
733 unset( $status_links );
738 if ( 'mustuse' == $status )
739 echo '<div class="clear"><p>' . __( 'Files in the <code>/wp-content/mu-plugins</code> directory are executed automatically.' ) . '</p>';
740 elseif ( 'dropins' == $status )
741 echo '<div class="clear"><p>' . __( 'Drop-ins are advanced plugins in the <code>/wp-content</code> directory that replace WordPress functionality when present.' ) . '</p>';
743 if ( !empty( $plugins ) && ( ! in_array( $status, array( 'mustuse', 'dropins' ) ) || $page_links ) ) :
745 <div class="tablenav">
748 echo '<div class="tablenav-pages">', $page_links_text, '</div>';
750 print_plugin_actions($status);
753 <div class="clear"></div>
757 if ( $total_this_page > $plugins_per_page )
758 $plugins = array_slice($plugins, $start, $plugins_per_page);
760 print_plugins_table($plugins, $status);
762 if ( !empty( $plugins ) && ! in_array( $status, array( 'mustuse', 'dropins' ) ) || $page_links ) {
764 <div class="tablenav">
767 echo "<div class='tablenav-pages'>$page_links_text</div>";
769 print_plugin_actions($status, "action2");
772 <?php } elseif ( ! empty( $all_plugins ) ) { ?>
773 <p><?php __( 'No plugins found.' ); ?></p>
777 <?php if ( empty($all_plugins) ) : ?>
779 <p><?php _e('You do not appear to have any plugins available at this time.') ?></p>
785 include('./admin-footer.php');