WordPress.org

Make WordPress Core

Changeset 38977


Ignore:
Timestamp:
10/27/2016 05:01:21 AM (4 years ago)
Author:
westonruter
Message:

Customize: Check for existence of controls and settings for background properties before attempting to access.

Amends [38948].
See #22058.
Fixes #38523.

File:
1 edited

Legend:

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

    r38967 r38977  
    56305630            // @todo These should actually toggle the active state, but without the preview overriding the state in data.activeControls.
    56315631            toggleVisibility = function( preset ) {
    5632                 api.control( 'background_position' ).container.toggle( visibility[ preset ][0] );
    5633                 api.control( 'background_size' ).container.toggle( visibility[ preset ][1] );
    5634                 api.control( 'background_repeat' ).container.toggle( visibility[ preset ][2] );
    5635                 api.control( 'background_attachment' ).container.toggle( visibility[ preset ][3] );
     5632                _.each( [ 'background_position', 'background_size', 'background_repeat', 'background_attachment' ], function( controlId, i ) {
     5633                    var control = api.control( controlId );
     5634                    if ( control ) {
     5635                        control.container.toggle( visibility[ preset ][ i ] );
     5636                    }
     5637                } );
    56365638            };
    56375639
    56385640            updateSettings = function( preset ) {
    5639                 api( 'background_position_x' ).set( values[ preset ][0] );
    5640                 api( 'background_position_y' ).set( values[ preset ][1] );
    5641                 api( 'background_size' ).set( values[ preset ][2] );
    5642                 api( 'background_repeat' ).set( values[ preset ][3] );
    5643                 api( 'background_attachment' ).set( values[ preset ][4] );
     5641                _.each( [ 'background_position_x', 'background_position_y', 'background_size', 'background_repeat', 'background_attachment' ], function( settingId, i ) {
     5642                    var setting = api( settingId );
     5643                    if ( setting ) {
     5644                        setting.set( values[ preset ][ i ] );
     5645                    }
     5646                } );
    56445647            };
    56455648
Note: See TracChangeset for help on using the changeset viewer.