Make WordPress Core


Ignore:
Timestamp:
07/26/2011 06:39:57 PM (13 years ago)
Author:
ryan
Message:

Consolidate update count code into wp_get_update_data(). Props mitchoyoshitaka. fixes #17694

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/network/menu.php

    r18157 r18468  
    2222$submenu['users.php'][10]  = array( _x('Add New', 'user'), 'create_users', 'user-new.php' );
    2323
    24 if ( current_user_can( 'update_themes' ) ) {
    25     $plugin_update_count = $theme_update_count = $wordpress_update_count = 0;
    26     $update_themes = get_site_transient( 'update_themes' );
    27     if ( !empty($update_themes->response) )
    28         $theme_update_count = count( $update_themes->response );
    29     $menu[15] = array(sprintf( __( 'Themes %s' ), "<span class='update-plugins count-$theme_update_count'><span class='theme-count'>" . number_format_i18n( $theme_update_count ) . "</span></span>" ), 'manage_network_themes', 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'div' );
     24$update_data = wp_get_update_data();
     25
     26if ( $update_data['counts']['themes'] ) {
     27    $menu[15] = array(sprintf( __( 'Themes %s' ), "<span class='update-plugins count-{$update_data['counts']['themes']}'><span class='theme-count'>" . number_format_i18n( $update_data['counts']['themes'] ) . "</span></span>" ), 'manage_network_themes', 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'div' );
    3028} else {
    3129    $menu[15] = array( __( 'Themes' ), 'manage_network_themes', 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'div' );
     
    3634
    3735if ( current_user_can( 'update_plugins' ) ) {
    38     $update_plugins = get_site_transient( 'update_plugins' );
    39     if ( !empty($update_plugins->response) )
    40         $plugin_update_count = count( $update_plugins->response );
    41     $menu[20] = array( sprintf( __( 'Plugins %s' ), "<span class='update-plugins count-$plugin_update_count'><span class='plugin-count'>" . number_format_i18n( $plugin_update_count ) . "</span></span>" ), 'manage_network_plugins', 'plugins.php', '', 'menu-top menu-icon-plugins', 'menu-plugins', 'div');
     36    $menu[20] = array( sprintf( __( 'Plugins %s' ), "<span class='update-plugins count-{$update_data['counts']['plugins']}'><span class='plugin-count'>" . number_format_i18n( $update_data['counts']['plugins'] ) . "</span></span>" ), 'manage_network_plugins', 'plugins.php', '', 'menu-top menu-icon-plugins', 'menu-plugins', 'div');
    4237} else {
    4338    $menu[20] = array( __('Plugins'), 'manage_network_plugins', 'plugins.php', '', 'menu-top menu-icon-plugins', 'menu-plugins', 'div' );
     
    5449}
    5550
    56 if ( current_user_can( 'update_core' ) ) {
    57     $update_wordpress = get_core_updates( array('dismissed' => false) );
    58     if ( !empty($update_wordpress) && !in_array( $update_wordpress[0]->response, array('development', 'latest') ) )
    59         $wordpress_update_count = 1;
    60    
    61     $update_count = $plugin_update_count + $theme_update_count + $wordpress_update_count;
    62     $update_title = array();
    63     if ( $wordpress_update_count )
    64         $update_title[] = sprintf(__('%d WordPress Update'), $wordpress_update_count);
    65     if ( $plugin_update_count )
    66         $update_title[] = sprintf(_n('%d Plugin Update', '%d Plugin Updates', $plugin_update_count), $plugin_update_count);
    67     if ( $theme_update_count )
    68         $update_title[] = sprintf(_n('%d Theme Update', '%d Theme Updates', $theme_update_count), $theme_update_count);
    69    
    70     $update_title = !empty($update_title) ? esc_attr(implode(', ', $update_title)) : '';
    71    
    72     $menu[30] = array( sprintf( __( 'Updates %s' ), "<span class='update-plugins count-$update_count' title='$update_title'><span class='update-count'>" . number_format_i18n($update_count) . "</span></span>" ), 'manage_network', 'upgrade.php', '', 'menu-top menu-icon-tools', 'menu-update', 'div' );
     51if ( $update_data['counts']['total'] ) {
     52    $menu[30] = array( sprintf( __( 'Updates %s' ), "<span class='update-plugins count-{$update_data['counts']['total']}' title='{$update_data['title']}'><span class='update-count'>" . number_format_i18n($update_data['counts']['total']) . "</span></span>" ), 'manage_network', 'upgrade.php', '', 'menu-top menu-icon-tools', 'menu-update', 'div' );
    7353} else {
    7454    $menu[30] = array( __( 'Updates' ), 'manage_network', 'upgrade.php', '', 'menu-top menu-icon-tools', 'menu-update', 'div' );
    7555}
    7656
     57unset($update_data);
     58
    7759$submenu[ 'upgrade.php' ][10] = array( __( 'Available Updates' ), 'update_core',  'update-core.php' );
    7860$submenu[ 'upgrade.php' ][15] = array( __( 'Update Network' ), 'manage_network', 'upgrade.php' );
    79 unset($plugin_update_count, $theme_update_count, $wordpress_update_count, $update_count, $update_title, $update_themes, $update_plugins, $update_wordpress);
    80 
    8161
    8262$menu[99] = array( '', 'read', 'separator-last', '', 'wp-menu-separator-last' );
Note: See TracChangeset for help on using the changeset viewer.