webgrafia / ginger

Wordpress plugin to make website compliant with EU Cookie Policy, with opt-in feature
18 stars 7 forks source link

ShortCut/Link to open the Banner and change idea #20

Open HartLarsson opened 6 years ago

HartLarsson commented 6 years ago

In the GDPR the user need the possibility to change is previous choice. Is there a way to fire with a button or a link the banner so the user can change setup?

rich-eicher commented 6 years ago

I agree this plugin needs a short code that relaunches the consent request banner/popup.

Is anyone working on this? If not I will see if someone from my company can do it.

webgrafia commented 6 years ago

Hi Rich, nobody is working on this feature, but if you make a pull request I'll merge it with pleasure

paolobros commented 6 years ago

ciao webgrafia. Anch'io sento questa necessità. Insieme a quella di esportare il log dei consensi ai cookie trasformerebbero Ginger nel plugin perfetto.

substa commented 6 years ago

Hello,

I hope I can contribute with a pull request ASAP, but for now I'm using a temporary solution.

On the banner/popup I added the link to the privacy policy page for more information and enabling/disabling cookie choice. Then, I added this code in the cookie section of the privacy page to show buttons to enable/disable cookies:

<script>
function createCookie(name, value, days) {
    var date, expires;
    if (days) {
        date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        expires = "; expires="+date.toGMTString();
    } else {
        expires = "";
    }
    document.cookie = name+"="+value+expires+"; path=/";
}
function enableCookie() {
document.cookie = "ginger-cookie=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
createCookie("ginger-cookie","Y",365);
var disabled = document.getElementById("cookie-disabled");
var enabled = document.getElementById("cookie-enabled");
disabled.style.display = "none";
enabled.style.display = "block";
}
function disableCookie() {
document.cookie = "ginger-cookie=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
createCookie("ginger-cookie","N",7);
var disabled = document.getElementById("cookie-disabled");
var enabled = document.getElementById("cookie-enabled");
enabled.style.display = "none";
disabled.style.display = "block";
}
</script>

<button type="button" onclick='enableCookie();'>Enable cookies</button> <button type="button" onclick='disableCookie();'>Disable cookies</button></p>

<div id="cookie-enabled" style="display: none;">Cookies are now enabled</div>
<div id="cookie-disabled" style="display: none;">Cookies are now disabled</div>
Filoz commented 6 years ago

I made the same thing but with a different approach:

// Add Shortcode
function ginger_shortcode_button() {
    if (isset($_COOKIE["ginger-cookie"])) {
        return '<script>
                function removeGingerCookie(sPath, sDomain) {
                    document.cookie = encodeURIComponent("ginger-cookie") + 
                  "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/";
                  location.reload(true);
                }</script>

        <div>Cookies are enabled, if you want you can <button type="button" onclick="removeGingerCookie();">disable cookies</button></div>';

    }else{
        return '<div>Cookies are disabled</div>'; //so the cookie bar is showed
    }

}
add_shortcode( 'ginger-button', 'ginger_shortcode_button' );

so you can put [ginger-button] everywhere you want that the button appear. It's a really simple solution... maybe ginger can prepend the shortcode automatically at the top of privacy policy page...

@webgrafia do you think that a improved version (a better one :) ) of my code could be added to ginger? A shortcode would be very useful

substa commented 6 years ago

Yes, I think the shortcode solution is better, and maybe essential if you want to log the user choice or add more options

matteobarale commented 6 years ago

in the next days we will release a version that uses shortcodes to generate a button that allows you to delete cookies. with this approach everyone can decide if and where to place the Button. give us some other time to test the latest changes. thanks for the suggestions and for the patience.

rich-eicher commented 6 years ago

One challenge we have is that cookies seem to be set by different sub-domains for our service. After some R&D we found that we could not delete all cookies across all of our sub-domains with a single script. Our script could only clear the current sub-domain's cookies. Has anyone else experienced this or did we miss something? Anyway we tried solving this with Frames but becuase of x-frame-options security we had to use a redirect to each sub-domain to clear those cookies.

THANK YOU FOR THIS UPDATE

Feature Suggestion: After the cookie short code (Button) has been clicked, and cookies are cleared on the WP hosted sub-domain, can we have Ginger config define a redirect URL to bring the customer to? In this case, we can redirect to another sub-domain where we might clear more cookies until finally redirecting the user back to the home page of our www site.

Finally - I seem to be more adept at writing checks than writing code. If you want to add a donate link in the Readme.txt I'd be able to help in my own way.

Filoz commented 6 years ago

@matteobarale have you an eta? Do you need some beta tester?