Can I Use Cookies ? WordPress plugin
WordPress plugin that does one thing but does it right:
Ask the user for his consent about cookies and tracking.
Available on the WordPress Plugins Repository
The plugin will add a new menu under your settings, where you can set up the various texts and images used by the popup.
Then, a popup will appear on every public pages, asking the user for his consent about cookies and tracking, presenting
him with 2 choices:
cookie-consent=yes
valid for 6 monthscookie-consent=no
valid for 6 monthsIt’s then up to you, and your analytics solution, to check for the cookie-consent
value and handle it according to the
user’s wishes.
A default style is applied to the popup, with the strict minimum (the layout of the popup). The popup will inherit the
text style, button style and colors from your theme.
However, you can use CSS to customize the popup layout and style
(by enqueuing a stylesheet in your functions.php
file, add additional CSS in your theme’s options, or whatever
technique to add CSS to your page).
For reference, here is the popup HTML code. You can use the main container id (#can-i-use-cookies
)
to scope your CSS rules.
<div id="can-i-use-cookies">
<div class="container">
<div class="subcontainer">
<img class="image" src="...">
<div class="text-container">
<p class="title">...</p>
<p class="description">...</p>
</div>
</div>
<div class="button-bar">
<button id="can-i-use-cookies-yes" class="button">...</button>
<button id="can-i-use-cookies-no" class="button">...</button>
</div>
</div>
</div>
Check other screenshots in the assets/
folder.
This plugin is build using node and webpack to produce an optimized JS code. Once built, the plugin is available under
the build/
directory.
To publish a new version of the plugin to WordPress’s SVN repo, follow
these example steps.
yarn run install
yarn run build
yarn run test
WordPress requires that all plugins should be under a GPLv2+ compliant license.
This code is distributed under the GPLv3 or later license.