Make WordPress Core

Ticket #29022: 29022.7.diff

File 29022.7.diff, 6.0 KB (added by pento, 9 years ago)
  • src/wp-admin/includes/class-wp-upgrader-skins.php

     
    111111                        return;
    112112                }
    113113
     114                $updated = wp_cache_get( "{$type}_updated", 'updates' );
     115                wp_cache_set( "{$type}_updated", intval( $updated ) + 1, 'updates' );
     116
     117                $update_data = wp_get_update_data();
     118
    114119                if ( defined( 'IFRAME_REQUEST' ) ) {
    115120                        echo '<script type="text/javascript">
    116121                                        if ( window.postMessage && JSON ) {
    117                                                 window.parent.postMessage( JSON.stringify( { action: "decrementUpdateCount", upgradeType: "' . $type . '" } ), window.location.protocol + "//" + window.location.hostname );
     122                                                window.parent.postMessage( JSON.stringify( { action: "decrementUpdateCount", upgradeType: "' . $type . '", upgradeTitle: "' . $update_data['title'] . '" } ), window.location.protocol + "//" + window.location.hostname );
    118123                                        }
    119124                                </script>';
    120125                } else {
    121126                        echo '<script type="text/javascript">
    122127                                        (function( wp ) {
    123128                                                if ( wp && wp.updates.decrementCount ) {
    124                                                         wp.updates.decrementCount( "' . $type . '" );
     129                                                        wp.updates.decrementCount( "' . $type . '", "' . $update_data['title'] . '" );
    125130                                                }
    126131                                        })( window.wp );
    127132                                </script>';
  • src/wp-admin/js/updates.js

     
    88         * Decrement update counts throughout the various menus
    99         *
    1010         * @param {string} updateType
     11         * @param {string} title
    1112         */
    12         wp.updates.decrementCount = function( upgradeType ) {
     13        wp.updates.decrementCount = function( upgradeType, title ) {
    1314                var count, pluginCount, $elem;
    1415
    1516                $elem = $( '#wp-admin-bar-updates .ab-label' );
     
    1819                if ( count < 0 ) {
    1920                        return;
    2021                }
    21                 $( '#wp-admin-bar-updates .ab-item' ).removeAttr( 'title' );
    2222                $elem.text( count );
    2323
     24                $( '#wp-admin-bar-updates .ab-item' ).attr( 'title', title );
     25                $( '#wp-admin-bar-updates .screen-reader-text' ).text( title );
     26
    2427                $elem = $( 'a[href="update-core.php"] .update-plugins' );
    2528                $elem.each( function( index, elem ) {
    2629                        elem.className = elem.className.replace( /count-\d+/, 'count-' + count );
     
    5861                        return;
    5962                }
    6063
    61                 wp.updates.decrementCount( message.upgradeType );
     64                wp.updates.decrementCount( message.upgradeType, message.upgradeTitle );
    6265
    6366        } );
    6467
  • src/wp-includes/load.php

     
    452452
    453453        if ( function_exists( 'wp_cache_add_global_groups' ) ) {
    454454                wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache' ) );
    455                 wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) );
     455                wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins', 'updates' ) );
    456456        }
    457457}
    458458
  • src/wp-includes/update.php

     
    522522
    523523        if ( $plugins = current_user_can( 'update_plugins' ) ) {
    524524                $update_plugins = get_site_transient( 'update_plugins' );
    525                 if ( ! empty( $update_plugins->response ) )
     525                if ( ! empty( $update_plugins->response ) ) {
    526526                        $counts['plugins'] = count( $update_plugins->response );
     527                        $plugins_updated = wp_cache_get( 'plugin_updated', 'updates' );
     528                        if ( $plugins_updated > 0 ) {
     529                                $counts['plugins'] -= $plugins_updated;
     530                        }
     531                }
    527532        }
    528533
    529534        if ( $themes = current_user_can( 'update_themes' ) ) {
    530535                $update_themes = get_site_transient( 'update_themes' );
    531                 if ( ! empty( $update_themes->response ) )
     536                if ( ! empty( $update_themes->response ) ) {
    532537                        $counts['themes'] = count( $update_themes->response );
     538                        $themes_updated = wp_cache_get( 'theme_updated', 'updates' );
     539                        if ( $themes_updated > 0 ) {
     540                                $counts['plugins'] -= $themes_updated;
     541                        }
     542                }
    533543        }
    534544
    535545        if ( ( $core = current_user_can( 'update_core' ) ) && function_exists( 'get_core_updates' ) ) {
    536546                $update_wordpress = get_core_updates( array('dismissed' => false) );
    537                 if ( ! empty( $update_wordpress ) && ! in_array( $update_wordpress[0]->response, array('development', 'latest') ) && current_user_can('update_core') )
     547                if ( ! empty( $update_wordpress ) && ! in_array( $update_wordpress[0]->response, array('development', 'latest') ) && current_user_can('update_core') && ! wp_cache_get( 'wordpress_updated', 'updates' ) )
    538548                        $counts['wordpress'] = 1;
    539549        }
    540550
    541         if ( ( $core || $plugins || $themes ) && wp_get_translation_updates() )
    542                 $counts['translations'] = 1;
     551        if ( ( $core || $plugins || $themes ) && $translations = wp_get_translation_updates() ) {
     552                $counts['translations'] = count( $translations );
     553                $translations_updated = wp_cache_get( 'translation_updated', 'updates' );
     554                if ( $translations_updated > 0 ) {
     555                        $counts['translations'] -= $translations_updated;
     556                }
     557        }
    543558
    544559        $counts['total'] = $counts['plugins'] + $counts['themes'] + $counts['wordpress'] + $counts['translations'];
    545560        $titles = array();
    546         if ( $counts['wordpress'] )
     561        if ( $counts['wordpress'] > 0 )
    547562                $titles['wordpress'] = sprintf( __( '%d WordPress Update'), $counts['wordpress'] );
    548         if ( $counts['plugins'] )
     563        if ( $counts['plugins'] > 0 )
    549564                $titles['plugins'] = sprintf( _n( '%d Plugin Update', '%d Plugin Updates', $counts['plugins'] ), $counts['plugins'] );
    550         if ( $counts['themes'] )
     565        if ( $counts['themes'] > 0 )
    551566                $titles['themes'] = sprintf( _n( '%d Theme Update', '%d Theme Updates', $counts['themes'] ), $counts['themes'] );
    552         if ( $counts['translations'] )
     567        if ( $counts['translations'] > 0 )
    553568                $titles['translations'] = __( 'Translation Updates' );
    554569
    555570        $update_title = $titles ? esc_attr( implode( ', ', $titles ) ) : '';