Skip to content

Instantly share code, notes, and snippets.

@mircobabini
Last active November 19, 2020 15:18
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mircobabini/de33dab69ca7598f39b6 to your computer and use it in GitHub Desktop.
Save mircobabini/de33dab69ca7598f39b6 to your computer and use it in GitHub Desktop.
Better IUBENDA code for Wordpress + WPML (without PHP)
<!-- replace 000001 with the site_id from your specific iubenda embed code -->
<!-- replace 000002 with the policy_id from your EN iubenda embed code -->
<!-- replace 000003 with the policy_id from your IT iubenda embed code -->
<script type="text/javascript">
var lang_id = jQuery('html').attr('lang').split('-')[0]
, site_id = 000001; // site_id from iubenda embed code
switch( lang_id ){
case 'en':
var policy_id = 000002; // policy_id from iubenda embed code EN
break;
case 'it':
var policy_id = 000003; // policy_id from iubenda embed code IT
break;
// case 'other language code' ...
}
var _iub = _iub || [];
_iub.csConfiguration = {
cookiePolicyId: policy_id,
siteId: site_id,
lang: lang_id
};
(function (w, d) {
var loader = function () { var s = d.createElement("script"), tag = d.getElementsByTagName("script")[0]; s.src = "//cdn.iubenda.com/cookie_solution/iubenda_cs.js"; tag.parentNode.insertBefore(s, tag); };
if (w.addEventListener) { w.addEventListener("load", loader, false); } else if (w.attachEvent) { w.attachEvent("onload", loader); } else { w.onload = loader; }
})(window, document);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment