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

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


git-svn-id: https://develop.svn.wordpress.org/trunk@38977 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Weston Ruter 2016-10-27 05:01:21 +00:00
parent dcc71eddcd
commit 968148ec51

View File

@ -5629,18 +5629,21 @@
// @todo These should actually toggle the active state, but without the preview overriding the state in data.activeControls. // @todo These should actually toggle the active state, but without the preview overriding the state in data.activeControls.
toggleVisibility = function( preset ) { toggleVisibility = function( preset ) {
api.control( 'background_position' ).container.toggle( visibility[ preset ][0] ); _.each( [ 'background_position', 'background_size', 'background_repeat', 'background_attachment' ], function( controlId, i ) {
api.control( 'background_size' ).container.toggle( visibility[ preset ][1] ); var control = api.control( controlId );
api.control( 'background_repeat' ).container.toggle( visibility[ preset ][2] ); if ( control ) {
api.control( 'background_attachment' ).container.toggle( visibility[ preset ][3] ); control.container.toggle( visibility[ preset ][ i ] );
}
} );
}; };
updateSettings = function( preset ) { updateSettings = function( preset ) {
api( 'background_position_x' ).set( values[ preset ][0] ); _.each( [ 'background_position_x', 'background_position_y', 'background_size', 'background_repeat', 'background_attachment' ], function( settingId, i ) {
api( 'background_position_y' ).set( values[ preset ][1] ); var setting = api( settingId );
api( 'background_size' ).set( values[ preset ][2] ); if ( setting ) {
api( 'background_repeat' ).set( values[ preset ][3] ); setting.set( values[ preset ][ i ] );
api( 'background_attachment' ).set( values[ preset ][4] ); }
} );
}; };
preset = control.setting.get(); preset = control.setting.get();