I’m trying hook the customizer_preview_init action in order to trigger live preview of the changes I’m making in the customizer. However, my first test is failing. I’m just trying to get an alert to fire inside the .js
Any ideas what I’m doing wrong?
//Add customizer.php to admin:
if ( is_admin() ) :
require_once( GENESIS_ADMIN_DIR . '/customizer.php' );
customizer.php:
function mytheme_customizer_live_preview()
{
wp_enqueue_script(
'mytheme-themecustomizer', //Give the script an ID
get_template_directory_uri().'/framework/admin/customizer.js',//Point to file
array( 'customize-preview' ), //Define dependencies
'', //Define a version (optional)
true //Put script in footer?
);
}
add_action( 'customize_preview_init', 'mytheme_customizer_live_preview' );
customizer.js
alert('customizer.js loaded!');
( function( $ ) {
alert('Customizer!');
//Do Stuff
} )( jQuery );
Update: It appears that my enqueue is failing. The customizer.js file is nowhere to be found in the dev tools resource panel.
I’ve verified that the footer.php does in fact have a wp_footer() call as expected. This is Genesis theme, perhaps some filter affecting the enqueue?