Support » Plugins and Hacks » Hacks » Loading built in jQuery UI in a plugin

Loading built in jQuery UI in a plugin

  • I am having a stab at writing my first plugin and have encountered a problem including the built in jQuery UI scripts. The code I have is as follows:

    function bda_faqs_load_js() {
    add_action( 'init', 'bda_faqs_load_js' );

    This doesn’t load the required scripts is there something I am missing?

    I would really like to utilise the built in scripts and not load my own version.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Where do you have this code?

    in a plugin file called bda_faqs.php

    Are you sure that the code is firing? And how do youknow that the scripts aren’t loading?

    I inserted an echo statement into the function bda_faqs_load_js which was outputted in the head of the the HTML.

    I know it is not working as when I review the HTML source the required ui.core.js and ui.widget.js are not included on the page.

    If I explicitly declare a javascript with wp_enqueue_script it works e.g.

    function bda_faqs_load_js() {
      wp_enqueue_script( 'bda-faqs-jquery-ui', plugins_url().'/bda-faqs/bda_faqs.jquery-ui.js', array('jquery'));

    But I really wanted to use the built in versions to keep the plugin as light weight as possible.

    I’m loading jQuery (not the others) with wp_enqueue_script on the ‘get_header’ hook and it is working fine. Its not what the docs say, but maybe try that instead of ‘init’.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Loading built in jQuery UI in a plugin’ is closed to new replies.
Skip to toolbar