Version Description
- Add support for disqus and ShareThis
- Bugfix
Download this release
Release Info
Developer | matteobarale |
Plugin | Ginger – EU Cookie Law |
Version | 1.2 |
Comparing to | |
See all releases |
Code changes from version 1.1.6 to 1.2
- admin/ginger.admin.php +10 -6
- front/gingerfront.utils.php +35 -5
- front/js/cookies-enabler.min.js +1 -1
- ginger-eu-cookie-law.php +1 -1
- readme.txt +7 -1
admin/ginger.admin.php
CHANGED
@@ -1,7 +1,11 @@
|
|
1 |
<?php
|
2 |
-
$
|
3 |
-
|
4 |
-
$key ="ginger_"
|
|
|
|
|
|
|
|
|
5 |
|
6 |
if(isset($_POST["submit"]) && !wp_verify_nonce($_POST['ginger_options'], 'save_ginger_options')){
|
7 |
return;
|
@@ -72,11 +76,11 @@ $options = get_option($key);
|
|
72 |
<a href="admin.php?page=ginger-setup&tab=policy" class="nav-tab <?php echo (($_GET["page"] == 'ginger-setup') && ($_GET["tab"] == "policy" )) ? 'nav-tab-active' : ''; ?>"><?php _e("Privacy Policy", "ginger"); ?></a>
|
73 |
<?php do_action("ginger_add_tab_menu"); ?>
|
74 |
</h2>
|
75 |
-
<form method="post" action="admin.php?page=<?php echo $_GET["page"];
|
76 |
<?php wp_nonce_field('save_ginger_options', 'ginger_options'); ?>
|
77 |
<?php
|
78 |
-
switch($
|
79 |
-
case "":
|
80 |
include('partial/general.php');
|
81 |
break;
|
82 |
case "banner":
|
1 |
<?php
|
2 |
+
if(isset($_GET['tab'])):
|
3 |
+
$tab = $_GET['tab'];
|
4 |
+
$key = "ginger_". $tab;
|
5 |
+
else:
|
6 |
+
$tab = 'general';
|
7 |
+
$key = "ginger_general";
|
8 |
+
endif;
|
9 |
|
10 |
if(isset($_POST["submit"]) && !wp_verify_nonce($_POST['ginger_options'], 'save_ginger_options')){
|
11 |
return;
|
76 |
<a href="admin.php?page=ginger-setup&tab=policy" class="nav-tab <?php echo (($_GET["page"] == 'ginger-setup') && ($_GET["tab"] == "policy" )) ? 'nav-tab-active' : ''; ?>"><?php _e("Privacy Policy", "ginger"); ?></a>
|
77 |
<?php do_action("ginger_add_tab_menu"); ?>
|
78 |
</h2>
|
79 |
+
<form method="post" action="admin.php?page=<?php echo $_GET["page"]; ?><?php if(isset($tab)) echo '&tab=' . $tab; ?>" <?php if (isset($tab) && $tab == 'url') echo 'class="repeater"';?>>
|
80 |
<?php wp_nonce_field('save_ginger_options', 'ginger_options'); ?>
|
81 |
<?php
|
82 |
+
switch($tab){
|
83 |
+
case "general":
|
84 |
include('partial/general.php');
|
85 |
break;
|
86 |
case "banner":
|
front/gingerfront.utils.php
CHANGED
@@ -204,6 +204,7 @@ add_action('wp_footer', 'ginger_scirpt');
|
|
204 |
|
205 |
//Ginger Start
|
206 |
function ginger_run(){
|
|
|
207 |
$option_ginger_general = get_option('ginger_general');
|
208 |
if($option_ginger_general['enable_ginger'] != 1) return;
|
209 |
if(isset($_COOKIE['ginger-cookie']) && $_COOKIE['ginger-cookie'] == 'Y'):
|
@@ -215,7 +216,7 @@ function ginger_run(){
|
|
215 |
add_filter('final_output', 'ginger_parse_dom');
|
216 |
endif;
|
217 |
}
|
218 |
-
add_action('
|
219 |
|
220 |
|
221 |
|
@@ -249,8 +250,14 @@ function ginger_parse_dom($output){
|
|
249 |
'www.youtube.com/iframe_api',
|
250 |
'www.google-analytics.com/analytics.js',
|
251 |
'google-analytics.com/ga.js',
|
252 |
-
'maps.googleapis.com'
|
|
|
253 |
);
|
|
|
|
|
|
|
|
|
|
|
254 |
do_action('ginger_add_scripts');
|
255 |
|
256 |
$ginger_iframe_tags = array(
|
@@ -259,7 +266,8 @@ function ginger_parse_dom($output){
|
|
259 |
'www.facebook.com/plugins/like.php',
|
260 |
'apis.google.com',
|
261 |
'www.google.com/maps/embed/',
|
262 |
-
'player.vimeo.com'
|
|
|
263 |
);
|
264 |
do_action('ginger_add_iframe');
|
265 |
|
@@ -269,13 +277,20 @@ function ginger_parse_dom($output){
|
|
269 |
$doc->loadHTML(mb_convert_encoding($output, 'HTML-ENTITIES', 'UTF-8'));
|
270 |
// get all the script tags
|
271 |
$script_tags = $doc->getElementsByTagName('script');
|
272 |
-
|
|
|
273 |
foreach($script_tags as $script):
|
274 |
-
|
275 |
if($src_script):
|
276 |
if(strpos_arr($src_script, $ginger_script_tags) !== false ):
|
277 |
$script->setAttribute("class", "ginger-script");
|
278 |
$script->setAttribute("type", "text/plain");
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
endif;
|
280 |
endif;
|
281 |
if($script->nodeValue):
|
@@ -287,9 +302,16 @@ function ginger_parse_dom($output){
|
|
287 |
endif;
|
288 |
$script->setAttribute("class", "ginger-script");
|
289 |
$script->setAttribute("type", "text/plain");
|
|
|
|
|
|
|
|
|
290 |
endif;
|
291 |
endif;
|
292 |
endforeach;
|
|
|
|
|
|
|
293 |
// get all the iframe tags
|
294 |
$iframe_tags = $doc->getElementsByTagName('iframe');
|
295 |
foreach($iframe_tags as $iframe):
|
@@ -307,6 +329,14 @@ function ginger_parse_dom($output){
|
|
307 |
endif;
|
308 |
endif;
|
309 |
endforeach;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
310 |
// get the HTML string back
|
311 |
$output = $doc->saveHTML();
|
312 |
libxml_use_internal_errors(false);
|
204 |
|
205 |
//Ginger Start
|
206 |
function ginger_run(){
|
207 |
+
if(is_feed()) return;
|
208 |
$option_ginger_general = get_option('ginger_general');
|
209 |
if($option_ginger_general['enable_ginger'] != 1) return;
|
210 |
if(isset($_COOKIE['ginger-cookie']) && $_COOKIE['ginger-cookie'] == 'Y'):
|
216 |
add_filter('final_output', 'ginger_parse_dom');
|
217 |
endif;
|
218 |
}
|
219 |
+
add_action('wp', 'ginger_run');
|
220 |
|
221 |
|
222 |
|
250 |
'www.youtube.com/iframe_api',
|
251 |
'www.google-analytics.com/analytics.js',
|
252 |
'google-analytics.com/ga.js',
|
253 |
+
'maps.googleapis.com',
|
254 |
+
'disqus.com',
|
255 |
);
|
256 |
+
|
257 |
+
$ginger_script_async_tags = array(
|
258 |
+
'addthis.com'
|
259 |
+
);
|
260 |
+
|
261 |
do_action('ginger_add_scripts');
|
262 |
|
263 |
$ginger_iframe_tags = array(
|
266 |
'www.facebook.com/plugins/like.php',
|
267 |
'apis.google.com',
|
268 |
'www.google.com/maps/embed/',
|
269 |
+
'player.vimeo.com',
|
270 |
+
'disqus.com'
|
271 |
);
|
272 |
do_action('ginger_add_iframe');
|
273 |
|
277 |
$doc->loadHTML(mb_convert_encoding($output, 'HTML-ENTITIES', 'UTF-8'));
|
278 |
// get all the script tags
|
279 |
$script_tags = $doc->getElementsByTagName('script');
|
280 |
+
$async_array = array();
|
281 |
+
$domElemsToRemove = array();
|
282 |
foreach($script_tags as $script):
|
283 |
+
$src_script = $script->getAttribute('src');
|
284 |
if($src_script):
|
285 |
if(strpos_arr($src_script, $ginger_script_tags) !== false ):
|
286 |
$script->setAttribute("class", "ginger-script");
|
287 |
$script->setAttribute("type", "text/plain");
|
288 |
+
continue;
|
289 |
+
endif;
|
290 |
+
if(strpos_arr($src_script, $ginger_script_async_tags) !== false ):
|
291 |
+
$async_array[] = $src_script;
|
292 |
+
$domElemsToRemove[] = $script;
|
293 |
+
continue;
|
294 |
endif;
|
295 |
endif;
|
296 |
if($script->nodeValue):
|
302 |
endif;
|
303 |
$script->setAttribute("class", "ginger-script");
|
304 |
$script->setAttribute("type", "text/plain");
|
305 |
+
if($ginger_script_tags[$key] == 'disqus.com/embed.js' || $ginger_script_tags[$key] == 'disqus.com'):
|
306 |
+
$script->setAttribute("class", "ginger-script");
|
307 |
+
$script->setAttribute("type", "text/plain");
|
308 |
+
endif;
|
309 |
endif;
|
310 |
endif;
|
311 |
endforeach;
|
312 |
+
foreach( $domElemsToRemove as $domElement ){
|
313 |
+
$domElement->parentNode->removeChild($domElement);
|
314 |
+
}
|
315 |
// get all the iframe tags
|
316 |
$iframe_tags = $doc->getElementsByTagName('iframe');
|
317 |
foreach($iframe_tags as $iframe):
|
329 |
endif;
|
330 |
endif;
|
331 |
endforeach;
|
332 |
+
if(!empty($async_array)):
|
333 |
+
$text = json_encode($async_array);
|
334 |
+
$text = 'var async_ginger_script = ' . $text . ';';
|
335 |
+
$head = $doc->getElementsByTagName('head')->item(0);
|
336 |
+
$element = $doc->createElement('script', $text);
|
337 |
+
$head->appendChild($element);
|
338 |
+
endif;
|
339 |
+
|
340 |
// get the HTML string back
|
341 |
$output = $doc->saveHTML();
|
342 |
libxml_use_internal_errors(false);
|
front/js/cookies-enabler.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
window.COOKIES_ENABLER=window.COOKIES_ENABLER||function(){"use strict";function e(){var e,n;for(e=1;e<arguments.length;e++)for(n in arguments[e])arguments[e].hasOwnProperty(n)&&(arguments[0][n]=arguments[e][n]);return arguments[0]}function n(e,n,t){var s;return function(){var a=this,i=arguments,
|
1 |
+
window.COOKIES_ENABLER=window.COOKIES_ENABLER||function(){"use strict";function e(){var e,n;for(e=1;e<arguments.length;e++)for(n in arguments[e])arguments[e].hasOwnProperty(n)&&(arguments[0][n]=arguments[e][n]);return arguments[0]}function n(e,n,t){var s;return function(){var a=this,i=arguments,r=function(){s=null,t||e.apply(a,i)},o=t&&!s;clearTimeout(s),s=setTimeout(r,n),o&&e.apply(a,i)}}function t(e,n){do if(s(e,n))return e;while(e=e.parentNode);return null}function s(e,n){return(" "+e.className+" ").indexOf(" "+n+" ")>-1}var a,i,r,o={scriptClass:"ce-script",iframeClass:"ce-iframe",acceptClass:"ce-accept",disableClass:"ce-disable",dismissClass:"ce-dismiss",bannerClass:"ce-banner",bannerHTML:null!==document.getElementById("ce-banner-html")?document.getElementById("ce-banner-html").innerHTML:'<p>This website uses cookies. <a href="#" class="ce-accept">Enable Cookies</a></p>',eventScroll:!1,scrollOffset:200,clickOutside:!1,cookieName:"ce-cookie",cookieDuration:"365",forceBannerClass:"ginger-banner bottom dialog dark force",forceEnable:!1,forceEnableText:'<div class="ginger-button-wrapper"><div class="ginger-button"><a href="#" class="ginger-accept">Enable Cookie</a></div></div>',iframesPlaceholder:!0,iframesPlaceholderHTML:null!==document.getElementById("ce-iframePlaceholder-html")?document.getElementById("ce-iframePlaceholder-html").innerHTML:'<p>To view this content you need to<a href="#" class="ce-accept">Enable Cookies</a></p>',iframesPlaceholderClass:"ce-iframe-placeholder",onEnable:"",onDismiss:"",onDisable:"",forceReload:!1},c=function(){Math.abs(window.pageYOffset-r)>a.scrollOffset&&"N"!=p.get()&&u()},l=function(){i={accept:document.getElementsByClassName(a.acceptClass),disable:document.getElementsByClassName(a.disableClass),banner:document.getElementsByClassName(a.bannerClass),bannerForce:document.getElementsByClassName(a.forceBannerClass),dismiss:document.getElementsByClassName(a.dismissClass)};var e,n=i.accept,s=n.length,o=i.disable,l=o.length,d=i.dismiss,g=d.length;for(a.eventScroll&&window.addEventListener("load",function(){r=window.pageYOffset,window.addEventListener("scroll",c)}),a.clickOutside&&document.addEventListener("click",function(e){var n=e.target;return t(n,a.iframesPlaceholderClass)||t(n,a.disableClass)||t(n,a.bannerClass)||t(n,a.dismissClass)||t(n,a.disableClass)?!1:void("N"!=p.get()&&u())}),e=0;s>e;e++)n[e].addEventListener("click",function(e){e.preventDefault(),u(e)});for(e=0;l>e;e++)o[e].addEventListener("click",function(e){e.preventDefault(),f(e)});for(e=0;g>e;e++)d[e].addEventListener("click",function(e){e.preventDefault(),m.dismiss()})},d=function(n){if(a=e({},o,n),"Y"==p.get())"function"==typeof a.onEnable&&a.onEnable(),b.get(),g.get();else if("N"==p.get()){var t=document.getElementById("disqus_thread");null!=t&&(t.style.display="none"),0!=a.forceEnable&&m.forceAccept(),"function"==typeof a.onDisable&&a.onDisable(),g.hide(),l()}else{var t=document.getElementById("disqus_thread");null!=t&&(t.style.display="none"),m.create(),g.hide(),l()}},u=n(function(e){if("undefined"!=typeof e&&"click"===e.type&&e.preventDefault(),"Y"!=p.get()){p.set(),b.get(),y.get_async(),g.get(),g.removePlaceholders(),m.dismiss();var n=document.getElementById("disqus_thread");null!=n&&(n.style.display="block"),window.removeEventListener("scroll",c),"function"==typeof a.onEnable&&a.onEnable(),1==a.forceReload&&location.reload()}},250,!1),f=function(e){"undefined"!=typeof e&&"click"===e.type&&e.preventDefault(),"N"!=p.get()&&(p.set("N"),m.dismiss(),window.removeEventListener("scroll",c),"function"==typeof a.onDisable&&a.onDisable())},m=function(){function e(){var e='<div class="'+a.bannerClass+'">'+a.bannerHTML+"</div>";document.body.insertAdjacentHTML("beforeend",e)}function n(){var e='<div class="'+a.forceBannerClass+'">'+a.forceEnableText+"</div>";document.body.insertAdjacentHTML("beforeend",e)}function t(){console.log(i.bannerForce),i.bannerForce[0]&&(i.bannerForce[0].style.display="none"),i.banner[0]&&(i.banner[0].style.display="none"),"function"==typeof a.onDismiss&&a.onDismiss()}return{create:e,dismiss:t,forceAccept:n}}(),p=function(){function e(e){var n,t,s="undefined"!=typeof e?e:"Y";a.cookieDuration?(n=new Date,n.setTime(n.getTime()+24*a.cookieDuration*60*60*1e3),t="; expires="+n.toGMTString()):t="",document.cookie=a.cookieName+"="+s+t+"; path=/"}function n(){var e,n,t,s=document.cookie.split(";"),i=s.length;for(e=0;i>e;e++)if(n=s[e].substr(0,s[e].indexOf("=")),t=s[e].substr(s[e].indexOf("=")+1),n=n.replace(/^\s+|\s+$/g,""),n==a.cookieName)return unescape(t)}return{set:e,get:n}}(),g=function(){function e(e){var n=document.createElement("div");n.className=a.iframesPlaceholderClass,n.innerHTML=a.iframesPlaceholderHTML,e.parentNode.insertBefore(n,e)}function n(){var e,n=document.getElementsByClassName(a.iframesPlaceholderClass),t=n.length;for(e=t-1;e>=0;e--)n[e].remove()}function t(){var n,t,s=document.getElementsByClassName(a.iframeClass),i=s.length;for(t=0;i>t;t++)n=s[t],n.style.display="none",a.iframesPlaceholder&&e(n)}function s(){var e,n,t,s=document.getElementsByClassName(a.iframeClass),i=s.length;for(t=0;i>t;t++)n=s[t],e=n.attributes["data-ce-src"].value,n.src=e,n.style.display="block"}return{hide:t,get:s,removePlaceholders:n}}(),b=function(){function e(){var e,n,t,s,i=document.getElementsByClassName(a.scriptClass),r=i.length,o=document.createDocumentFragment();for(e=0;r>e;e++)if(i[e].hasAttribute("data-ce-src"))"undefined"==typeof postscribe&&postscribe(i[e].parentNode,'<script src="'+i[e].getAttribute("data-ce-src")+'"></script>');else{for(t=document.createElement("script"),t.type="text/javascript",n=0;n<i[e].attributes.length;n++)s=i[e].attributes[n],s.specified&&"type"!=s.name&&"class"!=s.name&&t.setAttribute(s.name,s.value);t.innerHTML=i[e].innerHTML,o.appendChild(t)}document.body.appendChild(o)}function n(){"undefined"!=typeof async_ginger_script&&console.log(async_ginger_script)}return{get:e,get_async:n}}(),y=function(){function e(){if("undefined"!=typeof async_ginger_script){console.log(async_ginger_script);var e,n=async_ginger_script;for(e=0;e<n.length;++e){var t=document.createElement("script");t.type="text/javascript",t.src=n[e],document.getElementsByTagName("head")[0].appendChild(t)}}}return{get_async:e}}();return{init:d,enableCookies:u,dismissBanner:m.dismiss}}();
|
ginger-eu-cookie-law.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Ginger - EU Cookie Law
|
4 |
Plugin URI: http://manafactory.it/
|
5 |
Description: Make your website compliant with EU Cookie Policy.
|
6 |
-
Version: 1.
|
7 |
Author: Manafactory
|
8 |
Author URI: http://manafactory.it/
|
9 |
License: GPLv2 or later
|
3 |
Plugin Name: Ginger - EU Cookie Law
|
4 |
Plugin URI: http://manafactory.it/
|
5 |
Description: Make your website compliant with EU Cookie Policy.
|
6 |
+
Version: 1.2
|
7 |
Author: Manafactory
|
8 |
Author URI: http://manafactory.it/
|
9 |
License: GPLv2 or later
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: manafactory, webgrafia, matteobarale
|
|
3 |
Tags: EU Cookie Law, cookie law, block cookie, cookie consent, cookie law, cookie policy, privacy policy, cookie banner, italian cookie law, cookie italia
|
4 |
Requires at least: 3.0.1
|
5 |
Tested up to: 4.2.2
|
6 |
-
Stable tag: 1.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -30,6 +30,8 @@ The aim of Ginger is to be a **complete plug'n play solution** that make your we
|
|
30 |
* google maps
|
31 |
* youtube
|
32 |
* vimeo
|
|
|
|
|
33 |
|
34 |
= Coming soon: =
|
35 |
* **WPML** support
|
@@ -69,6 +71,10 @@ No, you can be safe from plugins conflict. It's been developed using Cookies Ena
|
|
69 |
|
70 |
== Changelog ==
|
71 |
|
|
|
|
|
|
|
|
|
72 |
= 1.1.6 =
|
73 |
* Get original class on iframe
|
74 |
* Bugfix on Css
|
3 |
Tags: EU Cookie Law, cookie law, block cookie, cookie consent, cookie law, cookie policy, privacy policy, cookie banner, italian cookie law, cookie italia
|
4 |
Requires at least: 3.0.1
|
5 |
Tested up to: 4.2.2
|
6 |
+
Stable tag: 1.2
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
30 |
* google maps
|
31 |
* youtube
|
32 |
* vimeo
|
33 |
+
* Disqus
|
34 |
+
* ShareThis
|
35 |
|
36 |
= Coming soon: =
|
37 |
* **WPML** support
|
71 |
|
72 |
== Changelog ==
|
73 |
|
74 |
+
= 1.2 =
|
75 |
+
* Add support for disqus and ShareThis
|
76 |
+
* Bugfix
|
77 |
+
|
78 |
= 1.1.6 =
|
79 |
* Get original class on iframe
|
80 |
* Bugfix on Css
|