WordPress.org

Make WordPress Core

Changeset 17822


Ignore:
Timestamp:
05/06/2011 07:48:13 PM (7 years ago)
Author:
ryan
Message:

Don't fetch update info our show update bubbles if the user does not have install caps. Props nacin. fixes #16532

Location:
trunk/wp-admin
Files:
2 edited

Legend:

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

    r17588 r17822  
    3333if ( ! is_multisite() || is_super_admin() ) {
    3434    $plugin_update_count = $theme_update_count = $wordpress_update_count = 0;
    35     $update_plugins = get_site_transient( 'update_plugins' );
    36     if ( !empty($update_plugins->response) && current_user_can('update_plugins') )
    37         $plugin_update_count = count( $update_plugins->response );
    38     $update_themes = get_site_transient( 'update_themes' );
    39     if ( !empty($update_themes->response) && current_user_can('update_themes') )
    40         $theme_update_count = count( $update_themes->response );
    41     $update_wordpress = get_core_updates( array('dismissed' => false) );
    42     if ( !empty($update_wordpress) && !in_array( $update_wordpress[0]->response, array('development', 'latest') ) && current_user_can('update_core') )
    43         $wordpress_update_count = 1;
     35
     36    if ( current_user_can( 'update_plugins' ) ) {
     37        $update_plugins = get_site_transient( 'update_plugins' );
     38        if ( ! empty( $update_plugins->response ) )
     39            $plugin_update_count = count( $update_plugins->response );
     40    }
     41
     42    if ( current_user_can( 'update_themes' ) ) {
     43        $update_themes = get_site_transient( 'update_themes' );
     44        if ( !empty($update_themes->response) )
     45            $theme_update_count = count( $update_themes->response );
     46    }
     47
     48    if ( current_user_can( 'update_core' ) ) {
     49        $update_wordpress = get_core_updates( array('dismissed' => false) );
     50        if ( !empty($update_wordpress) && !in_array( $update_wordpress[0]->response, array('development', 'latest') ) && current_user_can('update_core') )
     51            $wordpress_update_count = 1;
     52    }
    4453
    4554    $total_update_count = $plugin_update_count + $theme_update_count + $wordpress_update_count;
     
    5968}
    6069
    61 unset($plugin_update_count, $theme_update_count, $wordpress_update_count, $update_themes, $update_plugins, $update_wordpress);
     70unset($theme_update_count, $wordpress_update_count, $update_themes, $update_plugins, $update_wordpress);
    6271
    6372$menu[4] = array( '', 'read', 'separator1', '', 'wp-menu-separator' );
     
    164173}
    165174
    166 $update_plugins = get_site_transient( 'update_plugins' );
    167 $update_count = 0;
    168 if ( !empty($update_plugins->response) )
    169     $update_count = count( $update_plugins->response );
    170 
    171175$menu_perms = get_site_option('menu_items', array());
    172176if ( ! is_multisite() || is_super_admin() || ! empty( $menu_perms['plugins'] ) ) {
    173     $count = "<span class='update-plugins count-$update_count'><span class='plugin-count'>" . number_format_i18n($update_count) . "</span></span>";
     177    $count = "<span class='update-plugins count-$plugin_update_count'><span class='plugin-count'>" . number_format_i18n($plugin_update_count) . "</span></span>";
    174178    if ( is_multisite() || ! current_user_can( 'update_plugins' ) )
    175179        $count = '';
     
    182186        }
    183187}
    184 unset($menu_perms, $update_plugins, $update_count);
     188unset($menu_perms, $update_plugins, $plugin_update_count);
    185189
    186190if ( current_user_can('list_users') )
  • trunk/wp-admin/network/menu.php

    r17048 r17822  
    2222$submenu['users.php'][10]  = array( _x('Add New', 'user'), 'create_users', 'user-new.php' );
    2323
    24 $plugin_update_count = $theme_update_count = $wordpress_update_count = 0;
    25 $update_themes = get_site_transient( 'update_themes' );
    26 if ( !empty($update_themes->response) )
    27     $theme_update_count = count( $update_themes->response );
    28 $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');
     24if ( 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' );
     30} else {
     31    $menu[15] = array( __( 'Themes' ), 'manage_network_themes', 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'div' );
     32}
    2933$submenu['themes.php'][5]  = array( __('Themes'), 'manage_network_themes', 'themes.php' );
    3034$submenu['themes.php'][10] = array( _x('Add New', 'theme'), 'install_themes', 'theme-install.php' );
    3135$submenu['themes.php'][15] = array( _x('Editor', 'theme editor'), 'edit_themes', 'theme-editor.php' );
    3236
    33 $update_plugins = get_site_transient( 'update_plugins' );
    34 if ( !empty($update_plugins->response) )
    35     $plugin_update_count = count( $update_plugins->response );
    36 $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');
     37if ( 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');
     42} else {
     43    $menu[20] = array( __('Plugins'), 'manage_network_plugins', 'plugins.php', '', 'menu-top menu-icon-plugins', 'menu-plugins', 'div' );
     44}
    3745$submenu['plugins.php'][5]  = array( __('Plugins'), 'manage_network_plugins', 'plugins.php' );
    3846$submenu['plugins.php'][10] = array( _x('Add New', 'plugin editor'), 'install_plugins', 'plugin-install.php' );
     
    4654}
    4755
    48 $update_wordpress = get_core_updates( array('dismissed' => false) );
    49 if ( !empty($update_wordpress) && !in_array( $update_wordpress[0]->response, array('development', 'latest') ) )
    50     $wordpress_update_count = 1;
     56if ( 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 Themes 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' );
     73} else {
     74    $menu[30] = array( __( 'Updates' ), 'manage_network', 'upgrade.php', '', 'menu-top menu-icon-tools', 'menu-update', 'div' );
     75}
    5176
    52 $update_count = $plugin_update_count + $theme_update_count + $wordpress_update_count;
    53 $update_title = array();
    54 if ( $wordpress_update_count )
    55     $update_title[] = sprintf(__('%d WordPress Update'), $wordpress_update_count);
    56 if ( $plugin_update_count )
    57     $update_title[] = sprintf(_n('%d Plugin Update', '%d Plugin Updates', $plugin_update_count), $plugin_update_count);
    58 if ( $theme_update_count )
    59     $update_title[] = sprintf(_n('%d Theme Update', '%d Themes Updates', $theme_update_count), $theme_update_count);
    60 
    61 $update_title = !empty($update_title) ? esc_attr(implode(', ', $update_title)) : '';
    62 
    63 $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');
    6477$submenu[ 'upgrade.php' ][10] = array( __( 'Updates' ), 'update_core',  'update-core.php' );
    6578$submenu[ 'upgrade.php' ][15] = array( __( 'Update Network' ), 'manage_network', 'upgrade.php' );
Note: See TracChangeset for help on using the changeset viewer.