Hi @cleze,
Please add below code snippet to your site theme’s functions.php to set auto reject after delay.
add_action('wp_head', 'cli_auto_reject');
function cli_auto_reject() {
if (class_exists('Cookie_Law_Info')) {
?>
<script>
jQuery(function(){
//Set time in Milliseconds
var CLI_AUTO_REJECT_TIME = 10000;//10 Seconds
setTimeout(function(){
if(!CLI_Cookie.read(CLI_ACCEPT_COOKIE_NAME) && CLI_AUTO_REJECT_TIME) {
CLI.reject_close();
}
},CLI_AUTO_REJECT_TIME);
});
</script>
<?php
}
}
To show the banner again after X days if rejected, please use below code.
add_action('wp_footer','cli_set_expire',20);
function cli_set_expire() {
if(class_exists('Cookie_Law_Info_Public')) //first time visit and class exists
{
?>
<script type="text/javascript">
CLI_ACCEPT_COOKIE_EXPIRE = 365;//accept cookie expire after 365 days
var CLI_REJECT_COOKIE_EXPIRE_DAYS = 5;//cookie bar reappear after 5 days upon reject
jQuery(function() {
jQuery('.cli_action_button').click(function(e){
e.preventDefault();
if(jQuery(this).attr('data-cli_action') == 'reject') {
setTimeout(function() {
CLI_Cookie.set(CLI_ACCEPT_COOKIE_NAME,'no',CLI_REJECT_COOKIE_EXPIRE_DAYS);
}, 300);
}
});
});
</script>
<?php
}
}
Note : Please change the values of CLI_ACCEPT_COOKIE_EXPIRE & CLI_REJECT_COOKIE_EXPIRE_DAYS as per the need.