Inside a wordpress plugin : The second enqueued js file isn't read, need I specify something ? Does registering is necessary when several js files are called (enqueued) ?
function atv_internationalization() {
wp_enqueue_style('atv-translate-css', plugins_url('', ATVTRANSLATE) . '/atvinternationalization.css');
wp_enqueue_script('atv-translate-js', plugins_url('', ATVTRANSLATE) . '/atvinternationalization.js', array('jquery'), '1.0', true );
wp_enqueue_script('atv-converturl-js', plugins_url('', ATVTRANSLATE) . '/atv_permalink/replaceurl.js', array('jquery'), '1.0', true);
}
add_action('admin_enqueue_scripts', 'atv_internationalization');
add_action('login_enqueue_scripts', 'atv_internationalization');
add_action('wp_enqueue_scripts', 'atv_internationalization');
atvinternationalization.css
and atvinternationalization.js
work.
replaceurl.js
is well included inside wp footer but the script isn't read or interpreted even just for console.log('something');
Each jQuery file is instantiated like this:
console.log("something"); // works outside jQuery
jQuery.noConflict(); don't resolve problem : It's not a jQuery conflict
(function($){
$(document).ready(function() {
$('body').text("something"); // doesn't read
});
});
I checked the good way to directory file .
Must I use get_template_directory_uri()
instead, if yes why ?
I emptied browser cache many times
Update : This method doesn't solve the problem :
function atv_internationalization() {
wp_enqueue_style('atv-translate-css', plugins_url('', ATVTRANSLATE) . '/atvinternationalization.css');
wp_register_script( 'atv-converturl-js', plugins_url('', ATVTRANSLATE) . '/atv_permalink/replaceurl.js', array('jquery'), '1.0', true );
wp_enqueue_script('atv-translate-js', plugins_url('', ATVTRANSLATE) . '/atvinternationalization.js', array('jquery'), '1.0', true);
wp_enqueue_script('atv-converturl-js');
wp_enqueue_script('atv-translate-js');
}
<script>
tag is included in the HTML with the correct URL then it's been enqueued correctly. WordPress has done it's job. If the script isn't working then it's a problem with the script. If your script is the last thing on the page, then(document).ready(
may have already run by the time your script is loaded, meaning that it won't run.console.log
is commented out. This is extremely unlikely to be a WordPress problem if the script tag is in the HTML and points to the correct URL