Support » Fixing WordPress » Load jQuery in Plugin Options Page

  • Resolved rpophessagr


    I’m trying to load jQuery into a plugin options page and having a dickens of a time doing so… any tips would be welcome.

    I tried:

    add_action('admin_init', 'add_jQuery'));
    function add_jQuery(){

    didn’t work…. any help would be most welcome.

Viewing 5 replies - 1 through 5 (of 5 total)
  • JQuery should already be running in the admin area.

    firebug is saying that it’s not.

    Ok, first look at how you’re adding your plugin page, eg.

    add_dashboard_page( 'page_title' , 'menu_title' , 'manage_options' , 'plugin_handle' , 'callback_function' );
    add_posts_page( 'page_title' , 'menu_title' , 'manage_options' , 'plugin_handle' , 'callback_function' );

    It’s the handle you need, so you can add actions to that page specifically, using the two examples above the page hook would be the following respectively..


    The easiest way to get the hook/handle is to store it when you add the page, eg..

    $plugin_hook = add_posts_page( 'page_title' , 'menu_title' , 'manage_options' , 'plugin_handle' , 'callback_function' );

    So you can then do..

    add_action( "admin_print_scripts-$plugin_hook" , 'my_enqueue_func' );


    add_action( "admin_head-$plugin_hook" , 'my_enqueue_func' );


    add_action( "load-$plugin_hook" , 'my_enqueue_func' );

    Hope that helps..


    Thank you!

    You’re welcome.. 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Load jQuery in Plugin Options Page’ is closed to new replies.