Hi jjfollano,
Check out the $in_footer
parameter here in the Codex:
https://codex.www.ads-software.com/Function_Reference/wp_enqueue_script
When you set the $in_footer
parameter to “true”, WordPress will force scripts to be loaded before the closing body
tag.
In Google Language Translator, locate this code:
function scripts($hook_suffix) {
global $p;
if ($p == $hook_suffix) {
wp_enqueue_script( 'my-admin-script', plugins_url('/admin.js',__FILE__), array('jquery'));
wp_enqueue_script( 'my-flag-script', plugins_url('/flags.js',__FILE__), array('jquery'));
wp_register_style( 'style.css', plugins_url('css/style.css', __FILE__) );
wp_enqueue_style( 'style.css' );
}
}
function flags() {
wp_enqueue_script( 'flags', plugins_url('/flags.js',__FILE__), array('jquery'));
wp_register_style( 'style.css', plugins_url('css/style.css', __FILE__) );
wp_enqueue_style( 'style.css' );
}
add_action('wp_enqueue_scripts', 'flags');
And then try changing it to this instead:
function scripts($hook_suffix) {
global $p;
if ($p == $hook_suffix) {
wp_enqueue_script( 'my-admin-script', plugins_url('/admin.js',__FILE__), array('jquery'),'',true);
wp_enqueue_script( 'my-flag-script', plugins_url('/flags.js',__FILE__), array('jquery'),'',true);
wp_register_style( 'style.css', plugins_url('css/style.css', __FILE__) );
wp_enqueue_style( 'style.css' );
}
}
function flags() {
wp_enqueue_script( 'flags', plugins_url('/flags.js',__FILE__), array('jquery'),'',true);
wp_register_style( 'style.css', plugins_url('css/style.css', __FILE__) );
wp_enqueue_style( 'style.css' );
}
add_action('wp_enqueue_scripts', 'flags');
My solution here is untested, so if you have problems, just let me know and I will try and fix, but I think it should work.
Thanks! Rob