Created
May 13, 2017 13:05
-
-
Save Jonnyauk/c7d8fc0077c1b2950367ef353eac2228 to your computer and use it in GitHub Desktop.
Customizer live update example
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( $ ) { | |
// 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