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.

Built from https://develop.svn.wordpress.org/trunk@42046


git-svn-id: http://core.svn.wordpress.org/trunk@41880 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Konstantin Obenland 2017-10-31 01:33:47 +00:00
parent 8981414082
commit b61de38e87
10 changed files with 31 additions and 18 deletions

View File

@ -2030,7 +2030,7 @@ p.customize-section-description {
display: none;
}
.themes-section-installed_themes .theme .notice-success {
.themes-section-installed_themes .theme .notice-success:not(.updated-message) {
display: none; /* Hide "installed" notice on installed themes tab. */
}

File diff suppressed because one or more lines are too long

View File

@ -2030,7 +2030,7 @@ p.customize-section-description {
display: none;
}
.themes-section-installed_themes .theme .notice-success {
.themes-section-installed_themes .theme .notice-success:not(.updated-message) {
display: none; /* Hide "installed" notice on installed themes tab. */
}

File diff suppressed because one or more lines are too long

View File

@ -3347,7 +3347,10 @@
api.control.each( function( control ) {
if ( 'theme' === control.params.type && control.params.theme.id === response.slug ) {
control.params.theme.hasUpdate = false;
control.rerenderAsInstalled( true );
control.params.theme.version = response.newVersion;
setTimeout( function() {
control.rerenderAsInstalled( true );
}, 2000 );
}
});
} );

File diff suppressed because one or more lines are too long

View File

@ -937,12 +937,12 @@
} else if ( 'customize' === pagenow ) {
// Update the theme details UI.
$notice = $( '#update-theme' ).closest( '.notice' ).removeClass( 'notice-large' );
$notice = $( '[data-slug="' + args.slug + '"].notice' ).removeClass( 'notice-large' );
$notice.find( 'h3' ).remove();
// Add the top-level UI, and update both.
$notice = $notice.add( $( '#customize-control-theme-installed_' + args.slug ).find( '.update-message' ) );
$notice = $notice.add( $( '#customize-control-installed_theme_' + args.slug ).find( '.update-message' ) );
$notice = $notice.addClass( 'updating-message' ).find( 'p' );
} else {
@ -988,10 +988,17 @@
$notice, newText;
if ( 'customize' === pagenow ) {
$theme = wp.customize.control( 'installed_theme_' + response.slug ).container;
}
$theme = $( '.updating-message' ).siblings( '.theme-name' );
if ( 'themes-network' === pagenow ) {
if ( $theme.length ) {
// Update the version number in the row.
newText = $theme.html().replace( response.oldVersion, response.newVersion );
$theme.html( newText );
}
$notice = $( '.theme-info .notice' ).add( wp.customize.control( 'installed_theme_' + response.slug ).container.find( '.theme' ).find( '.update-message' ) );
} else if ( 'themes-network' === pagenow ) {
$notice = $theme.find( '.update-message' );
// Update the version number in the row.
@ -1016,7 +1023,7 @@
$document.trigger( 'wp-theme-update-success', response );
// Show updated message after modal re-rendered.
if ( isModalOpen ) {
if ( isModalOpen && 'customize' !== pagenow ) {
$( '.theme-info .theme-author' ).after( wp.updates.adminNotice( updatedMessage ) );
}
};
@ -1046,7 +1053,7 @@
}
if ( 'customize' === pagenow ) {
$theme = wp.customize.control( 'installed_theme_' + response.slug ).container;
$theme = wp.customize.control( 'installed_theme_' + response.slug ).container.find( '.theme' );
}
if ( 'themes-network' === pagenow ) {

File diff suppressed because one or more lines are too long

View File

@ -4276,6 +4276,9 @@ final class WP_Customize_Manager {
if ( ! is_multisite() && ( current_user_can( 'install_themes' ) || current_user_can( 'update_themes' ) || current_user_can( 'delete_themes' ) ) ) {
wp_enqueue_script( 'updates' );
wp_localize_script( 'updates', '_wpUpdatesItemCounts', array(
'totals' => wp_get_update_data(),
) );
}
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.9-beta4-42045';
$wp_version = '4.9-beta4-42046';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.