Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Not sure what I'm doing wrong, but I could use some help.

My plugin architecture is below...

register_activation_hook(__FILE__, 'my_post_options_box');
add_action('admin_menu', 'my_post_options_box');

//enqueue jquery ui here
function my_load_js() {
    echo "called"; //THIS ECHO FIRES
    wp_enqueue_script('jquery');
    wp_enqueue_script('jquery-ui-core');
    wp_enqueue_script('jquery-ui-widget');
    }

function my_post_options_box() {
    add_action( 'admin_init', 'my_load_js' );//DOES NOT LOAD THE .JS
    $my_dir = plugins_url('/img', __FILE__);
    add_options_page( '...my options page settings here');
    register_setting( 'my_settings_options', 'my_settings', 'my_settings_validate' );
}

Not sure what I'm doing wrong but when I view the source of the page in which the plugin is loaded, there is no .js file loaded for the jquery ui files I'm trying to enqueue

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

Hook my_load_js() to wp_enqueue_scripts as in the examples in the Codex, and not to admin_init.

add_action('wp_enqueue_scripts', 'my_load_js');

...pretty sure that will take care of it.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.