wordpressclassjquery-uipluginsenqueue

How to Enqueue Core WordPress Jquery into Class


What is the proper way to enqueue into a class? It seems fine to use just

wp_enqueue_script('jquery-ui-tabs');

Into a theme template but if you use the same line inside the enqueue_scripts boilerplate class area it does not work.

I can get custom JS to enqueue in fine with this

wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/tagmanager-master/tagmanager.js', array( 'jquery' ), $this->version, false );

But can't seem to get the right line for something that comes in WordPress is not on by default.


Solution

  • I ended up adding a custom file/version of tabs directly into the plugin because with tabs activated with:

    wp_enqueue_script( 'tabs-script', plugin_dir_url( __FILE__ ) . '../js/tabs.js', array('jquery-ui-core', 'jquery-ui-accordion', 'jquery-ui-tabs') );
    

    Not sure why but:

    wp_enqueue_script('jquery-ui-tabs');
    

    Was loading but it was not making tabs work.