How to use variable from customizer.php in customizer.js
Use wp_add_inline_script() to export the variable from PHP to JS. For example, in my_styles_method assuming that your customizr.js script has the handle my-styles-customize-preview: wp_add_inline_script( ‘my-styles-customize-preview’, sprintf( ‘var MyStylesSelector = %s;’, wp_json_encode( $custom_css ) ), ‘before’ ); Then you can modify for JS to be: wp.customize( ‘wpt_heading_color’, function( value ) { value.bind( function( newval ) { … Read more