Skip to content

Instantly share code, notes, and snippets.

@tonai126
Created August 5, 2025 15:00
Show Gist options
  • Select an option

  • Save tonai126/9731875a3cc9f5de85eb00fb3be1b59d to your computer and use it in GitHub Desktop.

Select an option

Save tonai126/9731875a3cc9f5de85eb00fb3be1b59d to your computer and use it in GitHub Desktop.
Hides the default "Deny" button from the main banner and moves it inside the preferences section
<?php
/**
* Plugin Name: Complianz - Move "Deny" button inside Preferences modal
* Description: Hides the default "Deny" button from the main banner and moves it inside the preferences section.
* Version: 1.5
* Author: Complianz Support
*/
add_action('wp_footer', function () {
?>
<style>
/* Hide the original deny button in the main button row */
.cmplz-buttons .cmplz-deny {
display: none !important;
}
/* Styling for the custom deny button inside the preferences panel */
.cmplz-categories .cmplz-btn.cmplz-deny {
margin-top: 15px;
height: 45px;
padding: 10px;
width: 100%;
white-space: nowrap;
border-radius: var(--cmplz_button_border_radius);
cursor: pointer;
font-size: var(--cmplz_button_font_size);
font-weight: 500;
text-decoration: none;
line-height: 20px;
text-align: center;
background-color: var(--cmplz_button_deny_background_color);
border: 1px solid var(--cmplz_button_deny_border_color);
color: var(--cmplz_button_deny_text_color);
}
.cmplz-categories .cmplz-btn.cmplz-deny:hover {
filter: brightness(95%);
}
</style>
<script>
document.addEventListener("DOMContentLoaded", function () {
// Watch for DOM changes to insert the button only when preferences are visible
const observer = new MutationObserver(() => {
const categories = document.querySelector('.cmplz-categories');
const alreadyExists = categories?.querySelector('.cmplz-btn.cmplz-deny');
// Insert the deny button inside the preferences block if not already added
if (categories && !alreadyExists) {
const btn = document.createElement('button');
btn.className = 'cmplz-btn cmplz-deny';
btn.innerText = '<?php echo esc_js(__('Deny', 'complianz-gdpr')); ?>';
categories.appendChild(btn);
}
});
// Start observing for changes in the body
observer.observe(document.body, { childList: true, subtree: true });
});
</script>
<?php
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment