Make WordPress Core

Changeset 47883


Ignore:
Timestamp:
06/01/2020 08:51:10 PM (5 years ago)
Author:
azaozz
Message:

Plugins and Themes Auto-Updates: update the state of the auto-update link on the themes screen after successfully saving the setting.

Props desrosj, pbiron, azaozz.
Fixes #50291.

Location:
trunk/src/js/_enqueues/wp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/wp/theme.js

    r47122 r47883  
    667667        'click .left': 'previousTheme',
    668668        'click .right': 'nextTheme',
    669         'click #update-theme': 'updateTheme'
     669        'click #update-theme': 'updateTheme',
     670        'click .toggle-auto-update': 'autoupdateState'
    670671    },
    671672
     
    786787        this.unbind();
    787788        this.trigger( 'theme:collapse' );
     789    },
     790
     791    // Set state of the auto-update settings link after it has been changed and saved.
     792    autoupdateState: function() {
     793        var callback,
     794            _this = this;
     795
     796        // Support concurrent clicks in different Theme Details overlays.
     797        callback = function( event, data ) {
     798            if ( _this.model.get( 'id' ) === data.asset ) {
     799                _this.model.set( { autoupdate: 'enable' === data.state } );
     800                $( document ).off( 'wp-auto-update-setting-changed', callback );
     801            }
     802        }
     803
     804        // Triggered in updates.js
     805        $( document ).on( 'wp-auto-update-setting-changed', callback );
    788806    },
    789807
  • trunk/src/js/_enqueues/wp/updates.js

    r47835 r47883  
    26002600                        wp.a11y.speak( wp.updates.l10n.autoUpdatesDisabled, 'polite' );
    26012601                    }
     2602
     2603                    $document.trigger( 'wp-auto-update-setting-changed', { state: action, type: type, asset: asset } );
    26022604                } )
    26032605                .fail( function() {
Note: See TracChangeset for help on using the changeset viewer.