-
-$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();
-
-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_transient( 'update_plugins' );
-
-foreach ( (array)$all_plugins as $plugin_file => $plugin_data) {
-
- //Translate, Apply Markup, Sanitize HTML
- $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true);
- $all_plugins[ $plugin_file ] = $plugin_data;
-
- //Filter into individual sections
- if ( 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;
-}
-
-$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);
-
-//Searching.
-if ( isset($_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) && $status != 'all' ) {
- $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 = get_user_option('plugins_per_page');
-if ( empty($plugins_per_page) )
- $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
-);
-