Skip to content

Instantly share code, notes, and snippets.

@AertHulsebos
Last active October 8, 2024 09:16
Show Gist options
  • Save AertHulsebos/00a8526595c6f1ea2a7c91a01cde157f to your computer and use it in GitHub Desktop.
Save AertHulsebos/00a8526595c6f1ea2a7c91a01cde157f to your computer and use it in GitHub Desktop.
Show Cookie Banner without Revoke
<?php
/**
* Show the banner when a html element with class 'cmplz-show-banner' is clicked
*/
function cmplz_show_banner_on_click() {
?>
<script>
function addEvent(event, selector, callback, context) {
document.addEventListener(event, e => {
if ( e.target.closest(selector) ) {
callback(e);
}
});
}
addEvent('click', '.cmplz-show-banner', function(){
document.querySelectorAll('.cmplz-manage-consent').forEach(obj => {
obj.click();
});
});
</script>
<?php
}
add_action( 'wp_footer', 'cmplz_show_banner_on_click' );
@tonai126
Copy link

tonai126 commented Oct 8, 2024

@gatonero , this is a mu-plugin. you can paste the raw code in a .php and insert it in the following directory /wp-content/mu-plugins/

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