-<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>
-
-<?php
-
-$all_plugins = apply_filters( 'all_plugins', get_plugins() );
-$search_plugins = array();
-$active_plugins = array();
-$inactive_plugins = array();
-$recent_plugins = array();
-$recently_activated = get_option('recently_activated', array());
-$upgrade_plugins = array();
-$network_plugins = array();
-$mustuse_plugins = $dropins_plugins = array();
-if ( ! is_multisite() || current_user_can('manage_network_plugins') ) {
- if ( apply_filters( 'show_advanced_plugins', true, 'mustuse' ) )
- $mustuse_plugins = get_mu_plugins();
- if ( apply_filters( 'show_advanced_plugins', true, 'dropins' ) )
- $dropins_plugins = get_dropins();
-}
-
-set_transient( 'plugin_slugs', array_keys($all_plugins), 86400 );
-
-// Clean out any plugins which were deactivated over a week ago.
-foreach ( $recently_activated as $key => $time )
- if ( $time + (7*24*60*60) < time() ) //1 week
- unset($recently_activated[ $key ]);
-if ( $recently_activated != get_option('recently_activated') ) //If array changed, update it.
- update_option('recently_activated', $recently_activated);
-$current = get_site_transient( 'update_plugins' );
-
-foreach ( array( 'all_plugins', 'mustuse_plugins', 'dropins_plugins' ) as $plugin_array_name) {
- foreach ( (array) $$plugin_array_name as $plugin_file => $plugin_data ) {
- // Translate, Apply Markup, Sanitize HTML
- $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true);
- ${$plugin_array_name}[ $plugin_file ] = $plugin_data;
- }
-}
-unset( $plugin_array_name );
-
-foreach ( (array) $all_plugins as $plugin_file => $plugin_data) {
- // Filter into individual sections
- if ( is_multisite() && is_network_only_plugin( $plugin_file ) && !current_user_can( 'manage_network_plugins' ) ) {
- unset( $all_plugins[ $plugin_file ] );
- continue;
- } elseif ( is_plugin_active_for_network($plugin_file) ) {
- $network_plugins[ $plugin_file ] = $plugin_data;
- } elseif ( is_plugin_active($plugin_file) ) {
- $active_plugins[ $plugin_file ] = $plugin_data;
- } else {
- if ( isset( $recently_activated[ $plugin_file ] ) ) // Was the plugin recently activated?
- $recent_plugins[ $plugin_file ] = $plugin_data;
- $inactive_plugins[ $plugin_file ] = $plugin_data;
- }
-
- if ( isset( $current->response[ $plugin_file ] ) )
- $upgrade_plugins[ $plugin_file ] = $plugin_data;
-}
-
-if ( !current_user_can('update_plugins') )
- $upgrade_plugins = array();
-
-$total_all_plugins = count($all_plugins);
-$total_inactive_plugins = count($inactive_plugins);
-$total_active_plugins = count($active_plugins);
-$total_recent_plugins = count($recent_plugins);
-$total_upgrade_plugins = count($upgrade_plugins);
-$total_network_plugins = count($network_plugins);
-$total_mustuse_plugins = count($mustuse_plugins);
-$total_dropins_plugins = count($dropins_plugins);
-
-// Searching.
-if ( !empty($_GET['s']) ) {
- function _search_plugins_filter_callback($plugin) {
- static $term;
- if ( is_null($term) )
- $term = stripslashes($_GET['s']);
- if ( stripos($plugin['Name'], $term) !== false ||
- stripos($plugin['Description'], $term) !== false ||
- stripos($plugin['Author'], $term) !== false ||
- stripos($plugin['PluginURI'], $term) !== false ||
- stripos($plugin['AuthorURI'], $term) !== false ||
- stripos($plugin['Version'], $term) !== false )
- return true;
- else
- return false;
- }
- $status = 'search';
- $search_plugins = array_filter($all_plugins, '_search_plugins_filter_callback');
- $total_search_plugins = count($search_plugins);
-}
-
-$plugin_array_name = "${status}_plugins";
-if ( empty($$plugin_array_name) && !in_array($status, array('all', 'search')) ) {
- $status = 'all';
- $plugin_array_name = "${status}_plugins";
-}
-
-$plugins = &$$plugin_array_name;
-
-// Paging.
-$total_this_page = "total_{$status}_plugins";
-$total_this_page = $$total_this_page;
-$plugins_per_page = (int) get_user_option( 'plugins_per_page' );
-if ( empty( $plugins_per_page ) || $plugins_per_page < 1 )
- $plugins_per_page = 999;
-$plugins_per_page = apply_filters( 'plugins_per_page', $plugins_per_page );
-
-$start = ($page - 1) * $plugins_per_page;
-
-$page_links = paginate_links( array(
- 'base' => add_query_arg( 'paged', '%#%' ),
- 'format' => '',
- 'prev_text' => __('«'),
- 'next_text' => __('»'),
- 'total' => ceil($total_this_page / $plugins_per_page),
- 'current' => $page
-));
-$page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
- number_format_i18n( $start + 1 ),
- number_format_i18n( min( $page * $plugins_per_page, $total_this_page ) ),
- '<span class="total-type-count">' . number_format_i18n( $total_this_page ) . '</span>',
- $page_links
-);
-
-/**
- * @ignore
- *
- * @param array $plugins
- * @param string $context
- */
-function print_plugins_table($plugins, $context = '') {
- global $page;
- $checkbox = ! in_array( $context, array( 'mustuse', 'dropins' ) ) ? '<input type="checkbox" />' : '';
-?>
-<table class="widefat" cellspacing="0" id="<?php echo $context ?>-plugins-table">
- <thead>
- <tr>
- <th scope="col" class="manage-column check-column"><?php echo $checkbox; ?></th>
- <th scope="col" class="manage-column"><?php _e('Plugin'); ?></th>
- <th scope="col" class="manage-column"><?php _e('Description'); ?></th>
- </tr>
- </thead>
-
- <tfoot>
- <tr>
- <th scope="col" class="manage-column check-column"><?php echo $checkbox; ?></th>
- <th scope="col" class="manage-column"><?php _e('Plugin'); ?></th>
- <th scope="col" class="manage-column"><?php _e('Description'); ?></th>
- </tr>
- </tfoot>
-
- <tbody class="plugins">
-<?php
-
- if ( empty($plugins) ) {
- echo '<tr>
- <td colspan="3">' . __('No plugins to show') . '</td>
- </tr>';
- }
- foreach ( (array)$plugins as $plugin_file => $plugin_data) {
- // preorder
- $actions = array(
- 'network_deactivate' => '', 'deactivate' => '',
- 'network_only' => '', 'activate' => '',
- 'network_activate' => '',
- 'edit' => '',
- 'delete' => '',
- );
-
- if ( 'mustuse' == $context ) {
- $is_active = true;
- } elseif ( 'dropins' == $context ) {
- $dropins = _get_dropins();
- $plugin_name = $plugin_file;
- if ( $plugin_file != $plugin_data['Name'] )
- $plugin_name .= '<br/>' . $plugin_data['Name'];
- if ( true === ( $dropins[ $plugin_file ][1] ) ) { // Doesn't require a constant
- $is_active = true;
- $description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
- } elseif ( constant( $dropins[ $plugin_file ][1] ) ) { // Constant is true
- $is_active = true;
- $description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
- } else {
- $is_active = false;
- $description = '<p><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>';
- }
- if ( $plugin_data['Description'] )
- $description .= '<p>' . $plugin_data['Description'] . '</p>';
- } else {
- $is_active_for_network = is_plugin_active_for_network($plugin_file);
- $is_active = $is_active_for_network || is_plugin_active( $plugin_file );
- if ( $is_active_for_network && !is_super_admin() )
- continue;
-
- if ( $is_active ) {
- if ( $is_active_for_network ) {
- if ( is_super_admin() )
- $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>';
- } else {
- $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>';
- }
- } else {
- if ( is_multisite() && is_network_only_plugin( $plugin_file ) )
- $actions['network_only'] = '<span title="' . __('This plugin can only be activated for all sites in a network') . '">' . __('Network Only') . '</span>';
- else
- $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>';
-
- if ( is_multisite() && current_user_can( 'manage_network_plugins' ) )
- $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>';
-
- if ( current_user_can('delete_plugins') )
- $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>';
- } // end if $is_active
-
- if ( current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) )
- $actions['edit'] = '<a href="plugin-editor.php?file=' . $plugin_file . '" title="' . __('Open this file in the Plugin Editor') . '" class="edit">' . __('Edit') . '</a>';
- } // end if $context
-
- $actions = apply_filters( 'plugin_action_links', array_filter( $actions ), $plugin_file, $plugin_data, $context );
- $actions = apply_filters( "plugin_action_links_$plugin_file", $actions, $plugin_file, $plugin_data, $context );