Last active
May 16, 2022 05:36
-
-
Save wtmujeebu/a6211941378345f980ad0201b70328cf to your computer and use it in GitHub Desktop.
Show cookie banner with a delay using CookieYes GDPR cookie consent plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // Do not copy this line | |
add_action('wp_footer', 'wt_cli_delay_cookie_banner', 10); | |
function wt_cli_delay_cookie_banner() | |
{ | |
if (class_exists('Cookie_Law_Info')) { | |
?> | |
<script> | |
jQuery(function() { | |
var timeDelay = 3000; //Time in milli seconds, 1000 ms = 1 second. | |
CLI.bar_elm.hide(); | |
if (CLI.settings.notify_animate_show) { | |
CLI.bar_elm.css('visibility', 'hidden'); | |
} | |
setTimeout(function() { | |
if (!CLI_Cookie.read(CLI_ACCEPT_COOKIE_NAME)) { | |
if (CLI.settings.notify_animate_show) { | |
CLI.bar_elm.hide(); | |
CLI.bar_elm.css('visibility', 'visible'); | |
CLI.bar_elm.slideDown(CLI.settings.notify_animate_show); | |
} else { | |
CLI.bar_elm.show(); | |
} | |
} | |
}, timeDelay); | |
jQuery(document).on('click', '.wt-cli-manage-consent-link, .cli_manage_current_consent', function() { | |
CLI.bar_elm.css('visibility', 'visible'); | |
}); | |
}); | |
</script> | |
<?php | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Thank you very much for this code snippet. You should mention that loading animation should be deactivated when using it.
Indeed, I just noticed that [wt_cli_manage_consent] button is not working when this code snippet is used while animation is activated for loading. Fortunately, everything works fine when animation is deactivated. :)
Just in case some people face the same issue.
Best regards,
MC