Skip to content

Instantly share code, notes, and snippets.

View AertHulsebos's full-sized avatar

Aert Hulsebos AertHulsebos

View GitHub Profile
@AertHulsebos
AertHulsebos / whitelisting-inline-script.php
Last active May 21, 2021 13:25
Whitelist inline script so Complianz' cookie blocker skips script.
<?php
// Whitelisting inline script for Complianz
add_filter ( 'cmplz_script_class',
function( $class, $total_match, $found ) {
if ( $found && false !== strpos( $total_match, 'YOUR-SCRIPT-ID' ) ) {
$class = 'cmplz-native'; // add cmplz-script for Marketing and cmplz-stats for Statistics
}
return $class;
}, 10 , 3
);
<?php
/**
* Clear cookies on revoke. In this implementation, cookies which include "wp" are excluded.
*/
function cmplz_clear_cookies_on_revoke() {
?>
<script>
jQuery(document).ready(function ($) {
document.addEventListener('cmplzRevoke', function (e) {
cmplzClearAllCookies();
/* CSS example for the Terms & Conditions legal page - change it your liking */
/* Change Headers */
.cmplz-terms-conditions h2 {
font-size: 25px;
color: #2268DC;
font-weight: 600;
text-decoration:none;
}
/* Change Subtitles */
<?php
/**
* Edit the output html for the Terms & Conditions page
*
* @param string $html
*
* @return string
*/
function cmplz_tc_document_html( $html ) {
@AertHulsebos
AertHulsebos / show-banner-no-revoke.php
Last active October 8, 2024 09:16
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) ) {
/* You can add a class for styling on line 6,
* You can change alignment on line 7.
* You can change the wording on line 8,
* Copy code from line 7-10.
*/
<div data-service="google-recaptcha" data-category="marketing" class="cmplz-blocked-content-container cmplz-blocked-content-notice cmplz-accept-service cmplz-accept-marketing cmplz-wpforms"
style="text-align: left; cursor: pointer;">
Click here to accept reCaptcha cookies before sending the form.
</div>
/* Styling for the inline reCaptcha notice. And example can be seen on
* https://complianz.io/how-to-implement-recaptcha-and-consent-for-wp-forms/
* You can ofcourse edit however you see fit.
*/
.cmplz-recaptcha .wpforms-submit-container {
display:block!important;
}
.wpforms-submit-container {
display:none;
input.wpcf7-form-control.wpcf7-submit {
margin-top: 8px;
margin-left:2px;
}
.placeholder-active {
color: #28303E;
padding: 15px;
border: 3px solid #28303E;
margin-left: 2px;
font-size: 18px;
<script>
jQuery(document).ready(function ($) {
$( ".wpcf7-blocked-content-notice" ).wrap( "<div class='cmplz-accept-cookies placeholder-active'></div>" );
});
</script>
/* HTML custom field
* Accept cookies for ReCaptcha
* Feedback when Accepted
*/
<div data-service="google-recaptcha" data-category="marketing" class="cmplz-blocked-content-container cmplz-blocked-content-notice cmplz-accept-service cmplz-accept-marketing cmplz-ninjaforms"
style="text-align: left; cursor: pointer;">
Click here to accept reCaptcha cookies before sending the form.
</div>