Make WordPress Core

Ticket #42406: 42406.4.diff

File 42406.4.diff, 3.2 KB (added by westonruter, 7 years ago)

Remove unused var to fix jshint error

  • src/wp-admin/js/customize-controls.js

    diff --git src/wp-admin/js/customize-controls.js src/wp-admin/js/customize-controls.js
    index 7fb87bc88e..5110db234a 100644
     
    30303030                        api.Panel.prototype.initialize.call( panel, id, options );
    30313031                },
    30323032
     3033                /**
     3034                 * Determine whether a given theme can be switched to, or in general.
     3035                 *
     3036                 * @since 4.9.0
     3037                 *
     3038                 * @param {string} [slug] - Theme slug.
     3039                 * @returns {boolean} Whether the theme can be switched to.
     3040                 */
     3041                canSwitchTheme: function canSwitchTheme( slug ) {
     3042                        if ( slug && slug === api.settings.theme.stylesheet ) {
     3043                                return true;
     3044                        }
     3045                        return 'publish' === api.state( 'selectedChangesetStatus' ).get() && ( '' === api.state( 'changesetStatus' ).get() || 'auto-draft' === api.state( 'changesetStatus' ).get() );
     3046                },
     3047
    30333048                /**
    30343049                 * Attach events.
    30353050                 *
     
    30523067                        }
    30533068
    30543069                        function toggleDisabledNotifications() {
    3055                                 if ( 'publish' === api.state( 'selectedChangesetStatus' ).get() ) {
     3070                                if ( panel.canSwitchTheme() ) {
    30563071                                        panel.notifications.remove( 'theme_switch_unavailable' );
    30573072                                } else {
    30583073                                        panel.notifications.add( new api.Notification( 'theme_switch_unavailable', {
     
    30633078                        }
    30643079                        toggleDisabledNotifications();
    30653080                        api.state( 'selectedChangesetStatus' ).bind( toggleDisabledNotifications );
     3081                        api.state( 'changesetStatus' ).bind( toggleDisabledNotifications );
    30663082
    30673083                        // Collapse panel to customize the current theme.
    30683084                        panel.contentContainer.on( 'click', '.customize-theme', function() {
     
    31733189                        }
    31743190
    31753191                        // Prevent loading a non-active theme preview when there is a drafted/scheduled changeset.
    3176                         if ( 'publish' !== api.state( 'selectedChangesetStatus' ).get() && slug !== api.settings.theme.stylesheet ) {
     3192                        if ( panel.canSwitchTheme( slug ) ) {
    31773193                                deferred.reject({
    31783194                                        errorCode: 'theme_switch_unavailable'
    31793195                                });
     
    32663282                 * @returns {jQuery.promise} Promise.
    32673283                 */
    32683284                loadThemePreview: function( themeId ) {
    3269                         var deferred = $.Deferred(), onceProcessingComplete, urlParser, queryParams;
     3285                        var panel = this, deferred = $.Deferred(), onceProcessingComplete, urlParser, queryParams;
    32703286
    32713287                        // Prevent loading a non-active theme preview when there is a drafted/scheduled changeset.
    3272                         if ( 'publish' !== api.state( 'selectedChangesetStatus' ).get() && themeId !== api.settings.theme.stylesheet ) {
     3288                        if ( ! panel.canSwitchTheme( themeId ) ) {
    32733289                                return deferred.reject().promise();
    32743290                        }
    32753291
     
    50895105                 * @since 4.2.0
    50905106                 */
    50915107                ready: function() {
    5092                         var control = this;
     5108                        var control = this, panel = api.panel( 'themes' );
    50935109
    50945110                        function disableSwitchButtons() {
    5095                                 return 'publish' !== api.state( 'selectedChangesetStatus' ).get() && control.params.theme.id !== api.settings.theme.stylesheet;
     5111                                return ! panel.canSwitchTheme( control.params.theme.id );
    50965112                        }
    50975113
    50985114                        // Temporary special function since supplying SFTP credentials does not work yet. See #42184.
     
    51075123
    51085124                        api.state( 'selectedChangesetStatus' ).bind( function() {
    51095125                                updateButtons();
    5110                         });
     5126                        } );
     5127                        api.state( 'changesetStatus' ).bind( function() {
     5128                                updateButtons();
     5129                        } );
    51115130                        updateButtons();
    51125131
    51135132                        control.container.on( 'touchmove', '.theme', function() {