I am having a rather difficult time adding a script to the 3.4 Theme Customizer (i.e., customize.php). If I want, I can deregister jquery and add it from googleapi as follows:

wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js');
wp_enqueue_script( 'jquery' );

That works just fine. However, if I want to add jquery-color or some other script I just can’t get it to work. For instance, this doesn’t work:

wp_enqueue_script( 'jquery-color' );

This also does not work:

wp_register_script( 'bpjquerycolor', 'http://localhost/bp2/wp-content/themes/buildpress/admin/scripts/bpjquerycolor.js');

wp_enqueue_script( 'bpjquerycolor' );

In terms of add_action, none of the following work:

add_action( 'admin_print_scripts', 'add_admin_scripts' );
add_action( 'wp_enqueue_scripts', 'add_admin_scripts' );
add_action( 'init', 'add_admin_scripts' );
add_action( 'admin_init', 'add_admin_scripts' );

I have also tried the following with no success:

global $wp_customize;
if ( isset( $wp_customize ) ) {
wp_enqueue_script( 'jquery-color' );
}

In short, I’ve tried every combination that I can think of with no success.

What am I doing wrong? How can I add this to the theme customizer?

Thanks in advance for any help you can offer.

2 Answers
2

It appears that ‘customize_controls_enqueue_scripts’ also works and may be the intended function.

function theme_customize_style() {
    wp_enqueue_style('customize-styles', get_template_directory_uri() . '/customize.css');
}
add_action( 'customize_controls_enqueue_scripts', 'theme_customize_style' );

Leave a Reply

Your email address will not be published. Required fields are marked *