Make WordPress Core

Changeset 39632


Ignore:
Timestamp:
12/21/2016 05:47:43 AM (7 years ago)
Author:
pento
Message:

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.

Location:
branches/4.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7

  • branches/4.7/src/wp-content/themes/twentyseventeen/assets/js/customize-controls.js

    r39221 r39632  
    2626
    2727        // Detect when the front page sections section is expanded (or closed) so we can adjust the preview accordingly.
    28         wp.customize.section( 'theme_options' ).expanded.bind( function( isExpanding ) {
     28        wp.customize.section( 'theme_options', function( section ) {
     29            section.expanded.bind( function( isExpanding ) {
    2930
    30             // Value of isExpanding will = true if you're entering the section, false if you're leaving it.
    31             wp.customize.previewer.send( 'section-highlight', { expanded: isExpanding });
    32         });
     31                // Value of isExpanding will = true if you're entering the section, false if you're leaving it.
     32                wp.customize.previewer.send( 'section-highlight', { expanded: isExpanding });
     33            } );
     34        } );
    3335    });
    3436})( jQuery );
Note: See TracChangeset for help on using the changeset viewer.