Download from wordpress.org

WP Cookies Enabler 1.0

WP Cookies Enabler is a plugin for WordPress that offers an easy and lightweight solution to preventively block third-party cookies installed by js and to comply with the EU cookie law.

cute-cookie

EU legislation on cookies

EUROPEAN websites must follow the Commission’s guidelines on privacy and data protection and inform users that cookies are not being used to gather information unnecessarily.

The ePrivacy directive – more specifically Article 5(3) – requires prior informed consent for storage or for access to information stored on a user’s terminal equipment. In other words, you must ask users if they agree to most cookies and similar technologies before the site starts to use them.

For consent to be valid, it must be informed, specific, freely given and must constitute a real indication of the individual’s wishes.

 

This plugin blocks cookies from script tags…

Prevent javascript from installing cookies through <script> tags, ie Google Analytics.

… iframes…

Prevent iframes that could install cookies from being loaded, ie Google Maps.

… and also problematic scripts

Some scripts use document.write and can’t be executed asynchronusly. Thanks to Postscribe it is possible to defer the loading of these script without blocking the page.

 

Changelog

1.0

  • First release

 

Documentation

WP Cookies Enabler will not block cookies out of the box. Even though the banner is displayed, you still have to put your hands on the code to actually stop cookies. Here it is what you have to do.

Blocking cookies from script tags

Add the class "ce-script" and type="text/plain" to every script tag that installs cookies

<script type="text/plain" class="ce-script">
	// GA Demo
	var _gaq = _gaq || [];
	_gaq.push(['_setAccount', 'UA-XXXXX-X']);
	_gaq.push(['_trackPageview']);
</script>

<script type="text/plain" class="ce-script">
	// FB Share Demo
	(function(d, s, id) {
	var js, fjs = d.getElementsByTagName(s)[0];
	if (d.getElementById(id)) return;
</script>

Blocking cookies from iframes

For iframes, change the src attribute to data-ce-src and add the class "ce-iframe"

<iframe class="ce-iframe" data-ce-src="https://player.vimeo.com/video/1084537" width="500" height="281">

iframe placeholder

You can enable placeholders for blocked iframes using the related option in the General Settings page.

Doing so, a custom placeholder for blocked iframes will be inserted after the hidden iframe element.

You can customize the placeholder HTML using his relative text editor in the Settings page.

Problematic scripts

Some scripts use document.write and can’t be executed asynchronusly. This plugin load Postscribe to defer the loading of these script without blocking the page.

Just change the src to data-ce-src and add the class ce-script.

<script data-ce-src="http://pagead2.googlesyndication.com/pagead/show_ads.js" class="ce-script"></script>

DOM hooks

Adding the ce-accept class to any element will make it act as an accept button, enabling the cookies on click.

Adding the ce-dismiss class to any element will make it act as a dismiss button, removing the notice banner on click.

Adding the ce-disable class to any element will make it act as a disable button, removing the notice banner and disabling cookies on click.