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

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

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


git-svn-id: http://core.svn.wordpress.org/trunk@38920 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2016-10-27 05:02:35 +00:00
parent 1c5c130af9
commit 62445cd41b
3 changed files with 14 additions and 11 deletions

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();

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.7-alpha-38976'; $wp_version = '4.7-alpha-38977';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.