I'm trying to load a script into a WordPerss page, however it seems the enqueue script does not add anything.
I'm using the following script
function loadCC(){
wp_enqueue_script('cookieConsentJS', 'https://cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.3/cookieconsent.min.js');
wp_enqueue_style('cookieConsentCSS', 'https://cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.3/cookieconsent.min.css');
wp_add_inline_script("CookieConsent", "window.addEventListener(\"load\", function(){
window.cookieconsent.initialise({
\"palette\": {
\"popup\": {
\"background\": \"#107fc9\"
},
\"button\": {
\"background\": \"#ffffff\"
}
},
\"position\": \"top\",
\"static\": true,
\"content\": {
\"message\": \"".__("Deze website maakt gebruik van cookies om authenticatie, navigatie en andere functies te beheren. Door het gebruik van onze website, gaat u ermee akkoord dat we dit soort cookies plaatsen op uw apparaat.","bpm_cc")."\",
\"dismiss\": \"".__("Ik begrijp het","bpm_cc")."\"
},
\"elements\": {
\"messagelink\": \"<span id=\\\"cookieconsent:desc\\\" class=\\\"cc-message\\\">{{message}}</span>\",
\"dismiss\": \"<a aria-label=\\\"dismiss cookie message\\\" role=button tabindex=\\\"0\\\" class=\\\"vc_gitem-link vc_btn3 vc_btn3-size-md vc_btn-white\\\">{{dismiss}}</a>\"}
})
});");
}
add_action( 'wp_enqueue_scripts', 'loadCC' );
Did I make a mistake somewhere? The code seems correct to me.
wp_enqueue_style('wp_enqueue_scripts',towp_enqueue_style('wp_enqueue_scripts2',. If it works it's a name conflict.wp_enqueue_script('cookieConsentJS', 'https://cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.3/cookieconsent.min.js', array(),'3.0.3', true);.3.0.3is the version,truemeans call it on footer (false to call it on header) , and not sure aboutarray()wp_register_scriptfirst for theexternalscripts..and after registering enqueue it