WordPress.org

Make WordPress Core

Changeset 42046


Ignore:
Timestamp:
10/31/2017 01:32:15 AM (8 months ago)
Author:
obenland
Message:

Customize: Spiff up theme updates

Fixes UI bugs around theme updates in the Customizer. Theme versions now get updated and users are no longer left alone after a successful update.

Props rinkuyadav999, celloexpressions for initial patch.
Fixes #42365.

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/css/customize-controls.css

    r42036 r42046  
    20312031}
    20322032
    2033 .themes-section-installed_themes .theme .notice-success {
     2033.themes-section-installed_themes .theme .notice-success:not(.updated-message) {
    20342034    display: none; /* Hide "installed" notice on installed themes tab. */
    20352035}
  • trunk/src/wp-admin/js/customize-controls.js

    r42042 r42046  
    33483348                    if ( 'theme' === control.params.type && control.params.theme.id === response.slug ) {
    33493349                        control.params.theme.hasUpdate = false;
    3350                         control.rerenderAsInstalled( true );
     3350                        control.params.theme.version = response.newVersion;
     3351                        setTimeout( function() {
     3352                            control.rerenderAsInstalled( true );
     3353                        }, 2000 );
    33513354                    }
    33523355                });
  • trunk/src/wp-admin/js/updates.js

    r42018 r42046  
    938938
    939939            // Update the theme details UI.
    940             $notice = $( '#update-theme' ).closest( '.notice' ).removeClass( 'notice-large' );
     940            $notice = $( '[data-slug="' + args.slug + '"].notice' ).removeClass( 'notice-large' );
    941941
    942942            $notice.find( 'h3' ).remove();
    943943
    944944            // Add the top-level UI, and update both.
    945             $notice = $notice.add( $( '#customize-control-theme-installed_' + args.slug ).find( '.update-message' ) );
     945            $notice = $notice.add( $( '#customize-control-installed_theme_' + args.slug ).find( '.update-message' ) );
    946946            $notice = $notice.addClass( 'updating-message' ).find( 'p' );
    947947
     
    989989
    990990        if ( 'customize' === pagenow ) {
    991             $theme = wp.customize.control( 'installed_theme_' + response.slug ).container;
    992         }
    993 
    994         if ( 'themes-network' === pagenow ) {
     991            $theme = $( '.updating-message' ).siblings( '.theme-name' );
     992
     993            if ( $theme.length ) {
     994
     995                // Update the version number in the row.
     996                newText = $theme.html().replace( response.oldVersion, response.newVersion );
     997                $theme.html( newText );
     998            }
     999
     1000            $notice = $( '.theme-info .notice' ).add( wp.customize.control( 'installed_theme_' + response.slug ).container.find( '.theme' ).find( '.update-message' ) );
     1001        } else if ( 'themes-network' === pagenow ) {
    9951002            $notice = $theme.find( '.update-message' );
    9961003
     
    10171024
    10181025        // Show updated message after modal re-rendered.
    1019         if ( isModalOpen ) {
     1026        if ( isModalOpen && 'customize' !== pagenow ) {
    10201027            $( '.theme-info .theme-author' ).after( wp.updates.adminNotice( updatedMessage ) );
    10211028        }
     
    10471054
    10481055        if ( 'customize' === pagenow ) {
    1049             $theme = wp.customize.control( 'installed_theme_' + response.slug ).container;
     1056            $theme = wp.customize.control( 'installed_theme_' + response.slug ).container.find( '.theme' );
    10501057        }
    10511058
  • trunk/src/wp-includes/class-wp-customize-manager.php

    r42039 r42046  
    42774277        if ( ! is_multisite() && ( current_user_can( 'install_themes' ) || current_user_can( 'update_themes' ) || current_user_can( 'delete_themes' ) ) ) {
    42784278            wp_enqueue_script( 'updates' );
     4279            wp_localize_script( 'updates', '_wpUpdatesItemCounts', array(
     4280                'totals' => wp_get_update_data(),
     4281            ) );
    42794282        }
    42804283    }
Note: See TracChangeset for help on using the changeset viewer.