Cookillian 1.1.7 released

on June 2, 2012 in WordPress with no comments by

Just days after the release of Cookillian 1.1, a new version has been pushed out. I do apologise if it seems too quick, but I’d rather have the bug fixes out now rather than later, but also so you can enjoy some added features.

Bug fixes

The first bug fix is regarding implied consent. Due to a spelling error, quite similar to one made back in 1996 by Mr. Fielding, the implied consent function didn’t always work as intended. This has now been resolved.

A minor bug fix was a regression bug, which did not show the “More…” link on the Dashboard widget if there were more statistics available than it had displayed. This also led to the discovery of a nuisance, where certain visitors would purposely use the opt-in or opt-out links even though no alert was shown for them (nor was it necessary to be shown, given they were located in Asia). This issue has also been addressed.

New features

Aside from the bug fixes, I’ve also added some more features to Cookillian. The first is an improvement to the Statistics screen, where previous months are initially hidden so they do not take up so much space. Simply click on the month to reveal all the statistics.

Another, which will provide faster web-page loading speeds, is the option to use asynchronous AJAX to initialize Cookillian. AJAX was introduces in version 1.1 to work around caching plugins, such as WP Super Cache. Whilst that worked fine, it could potentially negate the gain of using such plugins, as the AJAX was loaded synchronously to ensure the Cookillian variables were initialized before use.

The use of asynchronous AJAX is optional, as it means that any JavaScript that relies on the Cookillian variables must use events (and for some this might be unfamiliar territory). These events are document-based events, called cookillian_load and cookillian_ready. Using jQuery, you would use those events as following:

  $(document).on("cookillian_ready", function(event, data) {
   // ... (data contains the Cookillian variables, ie. data.blocked_cookies)

To simplify things, I’ve also added a function that inserts a string based on the Cookillian variables, regardless if AJAX is used synchronously or asynchronously. It’s the function cookillian.insertString(where, true_string, false_string, tf_value). The parameter where is mandatory, and is the jQuery/CSS selector of the element where the string needs to be inserted. The false_string and tf_value parameters are optional, where the latter is based on cookillian.blocked_cookies if omitted.

To provide an example, the following will display a regular Twitter Tweet link if cookies are blocked, or provide the better-looking Tweet Button with the counter if cookies are permitted:

<div id="tweet_this"><a href="" class="twitter-share-button" data-lang="en">Tweet</a></div>
   "#tweet_this", // The selector, in this case the id of the <div> above
   "",            // Nothing extra to insert if cookies are blocked
   "<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);;js.src="//";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>" // Insert this script if cookies are accepted

The Tweet Button code can be found in Twitter’s Developer Documentation. The only thing that needs attention is escaping double quotes and the closing script tag.

The above code should also work for Google AdSense, as effectively it doesn’t alter their provided code, however, this might still be a grey area and care should be taken before implementation with Google AdSense.

And of course the above code works within a sidebar widget (using the Text widget, without automatic paragraphs).

Join the discussion

Your email address will not be published. Required fields are marked *