WordPress.org

Make WordPress Core

Changeset 11000


Ignore:
Timestamp:
04/19/2009 01:22:02 AM (9 years ago)
Author:
ryan
Message:

Add filter showing all plugins that have an upgrade available. see #9527

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/plugins.php

    r10999 r11000  
    216216$recent_plugins = array();
    217217$recently_activated = (array) get_option('recently_activated');
     218$upgrade_plugins = array();
     219
    218220set_transient( 'plugin_slugs', array_keys($all_plugins), 86400 );
    219221
     
    224226if ( $recently_activated != get_option('recently_activated') ) //If array changed, update it.
    225227    update_option('recently_activated', $recently_activated);
     228$current = get_transient( 'update_plugins' );
    226229
    227230foreach ( (array)$all_plugins as $plugin_file => $plugin_data) {
     
    238241        $inactive_plugins[ $plugin_file ] = $plugin_data;
    239242    }
     243
     244    if ( isset( $current->response[ $plugin_file ] ) )
     245        $upgrade_plugins[ $plugin_file ] = $plugin_data;
    240246}
    241247
     
    244250$total_active_plugins = count($active_plugins);
    245251$total_recent_plugins = count($recent_plugins);
     252$total_upgrade_plugins = count($upgrade_plugins);
    246253
    247254$status = ( isset($_GET['plugin_status']) ) ? $_GET['plugin_status'] : 'all';
    248 if ( !in_array($status, array('all', 'active', 'inactive', 'recent')) )
     255if ( !in_array($status, array('all', 'active', 'inactive', 'recent', 'upgrade')) )
    249256    $status = 'all';
    250257$plugin_array_name = "${status}_plugins";
     
    376383    $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>';
    377384}
     385if ( ! empty($upgrade_plugins) ) {
     386    $class = ( 'upgrade' == $status ) ? ' class="current"' : '';
     387    $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>';
     388}
    378389echo implode( " |</li>\n", $status_links ) . '</li>';
    379390unset( $status_links );
Note: See TracChangeset for help on using the changeset viewer.