I need to create a wordpress plugin. Only impossible to display any data. My url is ok and I followed the answers to the question: how to load Javascript in Wordpress Plugin
But nothing works. I also read on the wordpress doc that probably had recorded my script but nothing. I tried with and without "wp_register_scripts"
without success. I tried to put add action before, after, finally, I tried a lot of combination but nothing. My code:
index.php
function scriptjs() {
wp_enqueue_script( 'scriptjs', plugin_dir_url( __FILE__ ).'js/app.js' );
// wp_localize_script('scriptjs', 'ajaxurl', admin_url( 'admin-ajax.php' ) );
}
function jsscript() {
wp_register_script('scriptjs', plugin_dir_url( __FILE__ ).'js/app.js' );
}
add_action('wp_enqueue_scripts', 'scriptjs');
add_action('wp_register_scripts', 'jsscript');
app.js
console.log('hello world')
The goal is to make only ajax requests in app.js
Edit:
I just saw that I had the console open only the backend. I just watched front side. I have my "hello world". My script runs only on the user side. I am digging on this side. Sorry for the post a bit premature Ok done it's ok with add_action( 'admin_enqueue_scripts', 'scriptjs' );