From 012cbda992890ead7d682721516932793d8e439f Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Wed, 21 Dec 2016 05:47:43 +0000 Subject: [PATCH] Twenty Seventeen: Ensure functions in `customize-controls.js` don't count on Customizer sections always being present Before, the code assumed the `theme_options` section is always present, but it can be removed by plugins. This way, if it is, no JavaScript errors occur. Merge of [39623] to the 4.7 branch. Props westonruter. Fixes #39355. git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39632 602fd350-edb4-49c9-b593-d223f7449a82 --- .../twentyseventeen/assets/js/customize-controls.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/wp-content/themes/twentyseventeen/assets/js/customize-controls.js b/src/wp-content/themes/twentyseventeen/assets/js/customize-controls.js index b8e7e8160c..e6f6037a4d 100644 --- a/src/wp-content/themes/twentyseventeen/assets/js/customize-controls.js +++ b/src/wp-content/themes/twentyseventeen/assets/js/customize-controls.js @@ -25,10 +25,12 @@ }); // Detect when the front page sections section is expanded (or closed) so we can adjust the preview accordingly. - wp.customize.section( 'theme_options' ).expanded.bind( function( isExpanding ) { + wp.customize.section( 'theme_options', function( section ) { + section.expanded.bind( function( isExpanding ) { - // Value of isExpanding will = true if you're entering the section, false if you're leaving it. - wp.customize.previewer.send( 'section-highlight', { expanded: isExpanding }); - }); + // Value of isExpanding will = true if you're entering the section, false if you're leaving it. + wp.customize.previewer.send( 'section-highlight', { expanded: isExpanding }); + } ); + } ); }); })( jQuery );