Ticket #17694: 17694.2.diff
File 17694.2.diff, 13.1 KB (added by , 14 years ago) |
---|
-
wp-admin/network/menu.php
21 21 $submenu['users.php'][5] = array( __('All Users'), 'manage_network_users', 'users.php' ); 22 22 $submenu['users.php'][10] = array( _x('Add New', 'user'), 'create_users', 'user-new.php' ); 23 23 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 26 if ( $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' ); 30 28 } else { 31 29 $menu[15] = array( __( 'Themes' ), 'manage_network_themes', 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'div' ); 32 30 } … … 35 33 $submenu['themes.php'][15] = array( _x('Editor', 'theme editor'), 'edit_themes', 'theme-editor.php' ); 36 34 37 35 if ( 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'); 42 37 } else { 43 38 $menu[20] = array( __('Plugins'), 'manage_network_plugins', 'plugins.php', '', 'menu-top menu-icon-plugins', 'menu-plugins', 'div' ); 44 39 } … … 53 48 $submenu['settings.php'][10] = array( __('Network Setup'), 'manage_network_options', 'setup.php' ); 54 49 } 55 50 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 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' ); 51 if ( $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' ); 73 53 } else { 74 54 $menu[30] = array( __( 'Updates' ), 'manage_network', 'upgrade.php', '', 'menu-top menu-icon-tools', 'menu-update', 'div' ); 75 55 } 76 56 57 unset($update_data); 58 77 59 $submenu[ 'upgrade.php' ][10] = array( __( 'Available Updates' ), 'update_core', 'update-core.php' ); 78 60 $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 61 81 82 62 $menu[99] = array( '', 'read', 'separator-last', '', 'wp-menu-separator-last' ); 83 63 84 64 require_once(ABSPATH . 'wp-admin/includes/menu.php'); -
wp-admin/menu.php
30 30 $submenu[ 'index.php' ][5] = array( __('My Sites'), 'read', 'my-sites.php' ); 31 31 } 32 32 33 if ( ! is_multisite() || is_super_admin() ) {34 $ plugin_update_count = $theme_update_count = $wordpress_update_count = 0;33 if ( ! is_multisite() || is_super_admin() ) 34 $update_data = wp_get_update_data(); 35 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 }53 54 $total_update_count = $plugin_update_count + $theme_update_count + $wordpress_update_count;55 $update_title = array();56 if ( $wordpress_update_count )57 $update_title[] = sprintf(__('%d WordPress Update'), $wordpress_update_count);58 if ( $plugin_update_count )59 $update_title[] = sprintf(_n('%d Plugin Update', '%d Plugin Updates', $plugin_update_count), $plugin_update_count);60 if ( $theme_update_count )61 $update_title[] = sprintf(_n('%d Theme Update', '%d Themes Updates', $theme_update_count), $theme_update_count);62 63 $update_title = !empty($update_title) ? esc_attr(implode(', ', $update_title)) : '';64 }65 66 36 if ( ! is_multisite() ) { 67 $submenu[ 'index.php' ][10] = array( sprintf( __('Updates %s'), "<span class='update-plugins count- $total_update_count' title='$update_title'><span class='update-count'>" . number_format_i18n($total_update_count) . "</span></span>" ), 'update_core', 'update-core.php');37 $submenu[ 'index.php' ][10] = 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>" ), 'update_core', 'update-core.php'); 68 38 } 69 39 70 unset($theme_update_count, $wordpress_update_count, $update_themes, $update_plugins, $update_wordpress);71 72 40 $menu[4] = array( '', 'read', 'separator1', '', 'wp-menu-separator' ); 73 41 74 42 $menu[5] = array( __('Posts'), 'edit_posts', 'edit.php', '', 'open-if-no-js menu-top menu-icon-post', 'menu-posts', 'div' ); … … 176 144 177 145 $menu_perms = get_site_option('menu_items', array()); 178 146 if ( ! is_multisite() || is_super_admin() || ! empty( $menu_perms['plugins'] ) ) { 179 $count = "<span class='update-plugins count-$plugin_update_count'><span class='plugin-count'>" . number_format_i18n($plugin_update_count) . "</span></span>"; 147 if ( !isset( $update_data ) ) 148 $update_data = wp_get_update_data(); 149 150 $count = "<span class='update-plugins count-{$update_data['counts']['plugins']}'><span class='plugin-count'>" . number_format_i18n($update_data['counts']['plugins']) . "</span></span>"; 180 151 if ( is_multisite() || ! current_user_can( 'update_plugins' ) ) 181 152 $count = ''; 182 153 $menu[65] = array( sprintf( __('Plugins %s'), $count ), 'activate_plugins', 'plugins.php', '', 'menu-top menu-icon-plugins', 'menu-plugins', 'div' ); … … 189 160 $submenu['plugins.php'][15] = array( _x('Editor', 'plugin editor'), 'edit_plugins', 'plugin-editor.php' ); 190 161 } 191 162 } 192 unset($menu_perms, $update_ plugins, $plugin_update_count);163 unset($menu_perms, $update_data); 193 164 194 165 if ( current_user_can('list_users') ) 195 166 $menu[70] = array( __('Users'), 'list_users', 'users.php', '', 'menu-top menu-icon-users', 'menu-users', 'div' ); -
wp-includes/admin-bar.php
264 264 * @since 3.1.0 265 265 */ 266 266 function wp_admin_bar_updates_menu( $wp_admin_bar ) { 267 if ( !current_user_can('install_plugins') )268 return;269 267 270 $plugin_update_count = $theme_update_count = $wordpress_update_count = 0; 271 $update_plugins = get_site_transient( 'update_plugins' ); 272 if ( !empty($update_plugins->response) ) 273 $plugin_update_count = count( $update_plugins->response ); 274 $update_themes = get_site_transient( 'update_themes' ); 275 if ( !empty($update_themes->response) ) 276 $theme_update_count = count( $update_themes->response ); 277 /* @todo get_core_updates() is only available on admin page loads 278 $update_wordpress = get_core_updates( array('dismissed' => false) ); 279 if ( !empty($update_wordpress) && !in_array( $update_wordpress[0]->response, array('development', 'latest') ) ) 280 $wordpress_update_count = 1; 281 */ 268 $update_data = wp_get_update_data(); 282 269 283 $update_count = $plugin_update_count + $theme_update_count + $wordpress_update_count; 284 285 if ( !$update_count ) 270 if ( !$update_data['counts']['total'] ) 286 271 return; 287 272 288 $update_title = array(); 289 if ( $wordpress_update_count ) 290 $update_title[] = sprintf(__('%d WordPress Update'), $wordpress_update_count); 291 if ( $plugin_update_count ) 292 $update_title[] = sprintf(_n('%d Plugin Update', '%d Plugin Updates', $plugin_update_count), $plugin_update_count); 293 if ( $theme_update_count ) 294 $update_title[] = sprintf(_n('%d Theme Update', '%d Themes Updates', $theme_update_count), $theme_update_count); 295 296 $update_title = !empty($update_title) ? esc_attr(implode(', ', $update_title)) : ''; 297 298 $update_title = "<span title='$update_title'>"; 299 $update_title .= sprintf( __('Updates %s'), "<span id='ab-updates' class='update-count'>" . number_format_i18n($update_count) . '</span>' ); 273 $update_title = "<span title='{$update_data['title']}'>"; 274 $update_title .= sprintf( __('Updates %s'), "<span id='ab-updates' class='update-count'>" . number_format_i18n($update_data['counts']['total']) . '</span>' ); 300 275 $update_title .= '</span>'; 301 276 302 277 $wp_admin_bar->add_menu( array( 'id' => 'updates', 'title' => $update_title, 'href' => network_admin_url( 'update-core.php' ) ) ); -
wp-includes/update.php
281 281 set_site_transient( 'update_themes', $new_update ); 282 282 } 283 283 284 /* 285 * Collect counts and UI strings for available updates 286 * 287 * @package WordPress 288 * @since 3.3.0 289 * 290 * @return array 291 */ 292 function wp_get_update_data() { 293 $counts = array( 'plugins' => 0, 'themes' => 0, 'wordpress' => 0 ); 294 295 if ( current_user_can( 'update_plugins' ) ) { 296 $update_plugins = get_site_transient( 'update_plugins' ); 297 if ( ! empty( $update_plugins->response ) ) 298 $counts['plugins'] = count( $update_plugins->response ); 299 } 300 301 if ( current_user_can( 'update_themes' ) ) { 302 $update_themes = get_site_transient( 'update_themes' ); 303 if ( !empty($update_themes->response) ) 304 $counts['themes'] = count( $update_themes->response ); 305 } 306 307 if ( function_exists( 'get_core_updates' ) && current_user_can( 'update_core' ) ) { 308 $update_wordpress = get_core_updates( array('dismissed' => false) ); 309 if ( !empty($update_wordpress) && !in_array( $update_wordpress[0]->response, array('development', 'latest') ) && current_user_can('update_core') ) 310 $counts['wordpress'] = 1; 311 } 312 313 $counts['total'] = $counts['plugins'] + $counts['themes'] + $counts['wordpress']; 314 $update_title = array(); 315 if ( $counts['wordpress'] ) 316 $update_title[] = sprintf(__('%d WordPress Update'), $counts['wordpress']); 317 if ( $counts['plugins'] ) 318 $update_title[] = sprintf(_n('%d Plugin Update', '%d Plugin Updates', $counts['plugins']), $counts['plugins']); 319 if ( $counts['themes'] ) 320 $update_title[] = sprintf(_n('%d Theme Update', '%d Themes Updates', $counts['themes']), $counts['themes']); 321 322 $update_title = !empty($update_title) ? esc_attr(implode(', ', $update_title)) : ''; 323 324 return array( 'counts' => $counts, 'title' => $update_title ); 325 } 326 284 327 function _maybe_update_core() { 285 328 include ABSPATH . WPINC . '/version.php'; // include an unmodified $wp_version 286 329