0
votes

I am trying to load some scripts in the front-end. Been trying the code below (and variations of it) but doesn't do anything. Otherwise, the plugin is loading fine (using custom shortcode).

class MyPluginClass {   
    function load_scripts() {
        wp_enqueue_script('any_unique_id_is_ok', plugins_url('/somefolder/somefile.js', __FILE__),array('jquery'));
    }
}
add_action('wp_enqueue_scripts', array('MyPluginClass','load_scripts'));

Any help would be highly appreciated. Thanks!

1
Try: wp_enqueue_script('any_unique_id_is_ok', plugins_url('/somefolder/somefile.js', FILE),array('jquery'),null,false); - zipkundan
Sorry not working - antikbd
Try taking "load_scripts" outside of class. - zipkundan
Yeah tried that as well. Didn't work sadly. - antikbd

1 Answers

1
votes

For those who might stumble upon this issue, the problem was the missing wp_head() and wp_footer() hooks in my custom theme. Put these into the relevant places and everything should work fine.