Make WordPress Core

Ticket #37270: 37270.3.diff

File 37270.3.diff, 1.5 KB (added by westonruter, 8 years ago)
  • src/wp-admin/js/customize-controls.js

    diff --git src/wp-admin/js/customize-controls.js src/wp-admin/js/customize-controls.js
    index a02e2b5..3f5b2f0 100644
     
    29662966                                };
    29672967                                _( constructs ).each( function ( activeConstructs, type ) {
    29682968                                        api[ type ].each( function ( construct, id ) {
    2969                                                 var active = !! ( activeConstructs && activeConstructs[ id ] );
    2970                                                 if ( active ) {
    2971                                                         construct.activate();
    2972                                                 } else {
    2973                                                         construct.deactivate();
     2969                                                var isDynamicallyCreated = _.isUndefined( wp.customize.settings[ type + 's' ][ id ] );
     2970
     2971                                                /*
     2972                                                 * If the construct was created statically in PHP (not dynamically in JS)
     2973                                                 * then consider a missing (undefined) value in the activeConstructs to
     2974                                                 * mean it should be deactivated (since it is gone). But if it is
     2975                                                 * dynamically created then only toggle activation if the value is defined,
     2976                                                 * as this means that the construct was also then correspondingly
     2977                                                 * created statically in PHP and the active callback is available.
     2978                                                 * Otherwise, dynamically-created constructs should normally have
     2979                                                 * their active states toggled in JS rather than from PHP.
     2980                                                 */
     2981                                                if ( ! isDynamicallyCreated || ! _.isUndefined( activeConstructs[ id ] ) ) {
     2982                                                        if ( activeConstructs[ id ] ) {
     2983                                                                construct.activate();
     2984                                                        } else {
     2985                                                                construct.deactivate();
     2986                                                        }
    29742987                                                }
    29752988                                        } );
    29762989                                } );