Skip to content

Instantly share code, notes, and snippets.

@git-bhanu
Last active March 17, 2022 15:37
Show Gist options
  • Save git-bhanu/6d52f11641128f3d115c6781224399e6 to your computer and use it in GitHub Desktop.
Save git-bhanu/6d52f11641128f3d115c6781224399e6 to your computer and use it in GitHub Desktop.
This is the forked verison of plugin made by Gijo. You can view the main version here https://wpspeedmatters.com/fastest-cookie-consent-wordpress-plugin/
@git-bhanu
Copy link
Author

git-bhanu commented Jul 13, 2020

Hi there its https://thegapdecaders.com

Hey the-gap-decaders,

I found out the issue that you were having.

<p id="cookie-notice" style="visibility: visible; color: white"> 
This website uses cookies to ensure you have the best experience. 
<a href="https://thegapdecaders.com/privacy-policy" style="color: white"> Privacy Policy </a> <br> 
<button onclick="acceptCookie();">Got it!</button></p>

The problems were.

  1. You had {{ your link}} added inside href="". It was supposed to just be a placeholder.
  2. The default color of a tag. that is the link, was same as your themes color, which is your background color as well. I have added style="color: white". This should solve your problem.

The final code that you should use is:

<p id="cookie-notice" style="visibility: visible; color: white"> 
This website uses cookies to ensure you have the best experience. 
<a href="https://thegapdecaders.com/privacy-policy" style="color: white"> Privacy Policy </a> <br> 
<button onclick="acceptCookie();">Got it!</button></p>

<style>#cookie-notice{color:#fff;font-family:inherit;background:#596cd5;padding:20px;position:fixed;bottom:10px;left:10px;width:100%;max-width:300px;box-shadow:0 10px 20px rgba(0,0,0,.2);border-radius:5px;margin:0px;visibility:hidden;z-index:1000000;box-sizing:border-box}#cookie-notice button{color:inherit;background:#3842c7;border:0;padding:10px;margin-top:10px;width:100%;cursor:pointer}@media only screen and (max-width:600px){#cookie-notice{max-width:100%;bottom:0;left:0;border-radius:0}}</style>

<script>function acceptCookie(){document.cookie="cookieaccepted=1; expires=Thu, 18 Dec 2030 12:00:00 UTC; path=/",document.getElementById("cookie-notice").style.visibility="hidden"}document.cookie.indexOf("cookieaccepted")<0&&(document.getElementById("cookie-notice").style.visibility="visible");</script>

image
I made the said changes using console.

@letmework
Copy link

Hi there! Thaks for the snippet. Is there anyway this can be translated? I mean, I need to display it in two languages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment