diff --git src/wp-admin/js/customize-controls.js src/wp-admin/js/customize-controls.js
index a02e2b5..3f5b2f0 100644
|
|
|
2966 | 2966 | }; |
2967 | 2967 | _( constructs ).each( function ( activeConstructs, type ) { |
2968 | 2968 | 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 | } |
2974 | 2987 | } |
2975 | 2988 | } ); |
2976 | 2989 | } ); |