스크립트를 WordPerss 페이지에로드하려고하는데 대기열에 추가 스크립트가 아무것도 추가하지 않는 것 같습니다.
다음 스크립트를 사용하고 있습니다.
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' );
어딘가에서 실수를 했나요? 코드가 나에게 맞는 것 같습니다.
좋아, 디버깅 후 오류가 wp_add_inline_script 부분에 있음을 발견했습니다. 이에 대한 핸들은 wp_enqueue_script와 동일해야합니다 (이 변경 후 작동합니다)
<?php
/**
* Plugin Name: Cookie Consent
* Version: 1
* Author: Jasper (Bottle Post Media)
*/
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("CookieConsentJS", "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' );
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다