I am trying to enqueue a JavaScript file from a bare bones php file, but I am having trouble actually getting the JavaScript to enqueue. This is the php file.
function zdload_javascript(){
wp_enqueue_script( 'java-code',plugins_url('/update-shortcut.js',__FILE__),array('jquery'),'2.1.1',true);}
add_action( 'admin_enqueue_scripts','zdload_javascript');
It seems like the solution should be quite simple but for the life of me I can’t find my error. For reference, the java code creates a hotkey shortcut. Is my error obvious or is there some subtlety I’m missing?
This is not correct.
plugins_url('/update-shortcut.js',__FILE__) ;
Do it this way.
plugins_url( 'myplugin/js/update-shortcut.js' );
TRY THIS :