Skip to content

Instantly share code, notes, and snippets.

@Jonnyauk
Created May 13, 2017 13:05
Show Gist options
  • Save Jonnyauk/c7d8fc0077c1b2950367ef353eac2228 to your computer and use it in GitHub Desktop.
Save Jonnyauk/c7d8fc0077c1b2950367ef353eac2228 to your computer and use it in GitHub Desktop.
Customizer live update example
( function( $ ) {
// CLEAN UP DATA
// Allow basic text and certain symbols
function js_clean_text( input ) {
return input.replace(/[^a-zA-Z0-9 " ' , . ! ? @ £ % & ( ) * - ]/g,'');
}
wp.customize( 'opt_link_colour', function( value ) {
value.bind( function( newval ) {
$( 'a' ).css( 'color', newval );
} );
} );
wp.customize( 'opt_strapline', function( value ) {
value.bind( function( newval ) {
$('.customizer_strapline').html( js_clean_text(newval) );
} );
} );
wp.customize( 'blogname', function( value ) {
value.bind( function( newval ) {
$( '#header h1' ).html( newval );
} );
} );
wp.customize( 'blogdescription', function( value ) {
value.bind( function( newval ) {
$( '#header h5' ).html( newval );
} );
} );
} )( jQuery );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment