Skip to content

Instantly share code, notes, and snippets.

@kellenmace
Created September 3, 2015 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kellenmace/ea03d6be587947a864e7 to your computer and use it in GitHub Desktop.
Save kellenmace/ea03d6be587947a864e7 to your computer and use it in GitHub Desktop.
( function( $ ) {
$( window ).load( function() {
// When 'Use Portal Color Controls' customizer control is toggled
wp.customize( 'portal_color_control', function ( value ) {
value.bind( function( newval ) {
// If toggled off, warn user that portal color settings will be deleted
if ( 'off' == newval ) {
var confirmation = window.confirm( "WARNING: turning this off will delete all the portal color settings. Continue?" );
if ( true == confirmation ) {
// If user confirms, run code here to delete all portal color settings
} else {
// If user does not confirm, reset the customizer control to 'on'
this.set( 'on' );
}
}
});
});
});
})( jQuery );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment