0

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.

user1518699
  • 385
  • 2
  • 8
  • 20

2 Answers2

0

define jquery-ui-tabs as $deps your custom js file:

wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/tagmanager-master/tagmanager.js', array( 'jquery', 'jquery-ui-tabs' ), $this->version, false );
Mohammad Yousefi
  • 513
  • 3
  • 12
0

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.

user1518699
  • 385
  • 2
  • 8
  • 20