-
-
Save dankerizer/e656de33725da16cdff0514e33de3a75 to your computer and use it in GitHub Desktop.
Show or hide WordPress customizer control on change of another control. https://florianbrinkmann.com/en/3783/conditional-displaying-and-hiding-of-customizer-controls-via-javascript/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(function () { | |
/** | |
* Run function when customizer is ready. | |
*/ | |
wp.customize.bind('ready', function () { | |
wp.customize.control('slug_select_control', function (control) { | |
/** | |
* Run function on setting change of control. | |
*/ | |
control.setting.bind(function (value) { | |
switch (value) { | |
/** | |
* The select was switched to the hide option. | |
*/ | |
case 'hide': | |
/** | |
* Deactivate the conditional control. | |
*/ | |
wp.customize.control('slug_conditional_control').deactivate(); | |
break; | |
/** | |
* The select was switched to »show«. | |
*/ | |
case 'show': | |
/** | |
* Activate the conditional control. | |
*/ | |
wp.customize.control('slug_conditional_control').activate(); | |
break; | |
} | |
}); | |
}); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment