Make WordPress Core


Ignore:
Timestamp:
05/06/2011 07:48:13 PM (15 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.