Shortcodes, CSS and developers
The [kncc_cookie_policy] and [kncc_cookie_settings] shortcodes, custom CSS, the JavaScript API, events, the consent cookie and filters.
Shortcodes
| Shortcode | What it does |
|---|---|
[kncc_cookie_policy] |
The cookie declaration: cookies per category, the visitor’s current choice and an Edit cookie preferences button |
[kncc_cookie_settings] |
A link that reopens the cookie settings |
[kncc_cookie_settings text="Manage cookies"] |
The same link with your own text |
Put the settings link in your footer or menu, so visitors can always change their choice.
Open the settings from your own link
Any element with the class kncc-open-settings opens the banner when clicked:
<a href="#" class="kncc-open-settings">Cookie settings</a>
From JavaScript:
window.knccEditConsent();
Custom CSS
The Documentation tab in the plugin has a CSS template with every selector the plugin uses. Copy it to Appearance → Customize → Additional CSS, your child theme or a code snippets plugin, and uncomment the rules you need.
- If a rule does not apply, prefix it with
.kncc-banneror add!important. - With Plugin style typography, the font rules use
!important. Switch to Theme style for easier overrides. - The banner’s
z-indexis 999999 and the floating button’s 999998. Raise them if your theme shows overlays on top of the banner.
The consent cookie
The choice is stored in the first-party cookie kncc_consent for one year, as URL-encoded JSON:
{ "necessary": true, "analytics": true, "marketing": false, "preferences": false, "choice": "custom", "timestamp": "2026-10-28T09:00:00.000Z" }
choice is accept, reject or custom. Read it from your own code if you need the visitor’s choice, but do not write it: use the banner or knccEditConsent().
Events
- dataLayer:
consent_updatewithconsent_analytics,consent_marketingandconsent_preferences, pushed when the visitor chooses. See Google Consent Mode v2 and Tag Manager. - Google Consent Mode:
gtag('consent', 'update', …)with the signals of the allowed categories. - WP Consent API: the choice is shared with plugins that support the API.
Holding back your own scripts
To make your own script wait for a category, print it with the type text/plain and the category:
<script type="text/plain" data-kncc-category="marketing" src="https://example.com/widget.js"></script>
The plugin runs it when the visitor allows that category. Without touching code, a Block by address rule on the Script Blocking tab does the same.
Filters
| Filter | Default | Use |
|---|---|---|
kncc_block_html_scripts |
true |
Return false to turn off blocking of scripts in the page HTML and of scripts added later |
kncc_block_injected_scripts |
true |
Return false to turn off only the guard for scripts added after the page has loaded |
kncc_block_iframes |
true |
Return false to turn off YouTube and Vimeo blocking |
// Example: turn off the guard for scripts added after load.
add_filter('kncc_block_injected_scripts', '__return_false'); Updated 28 October 2026
Something wrong or missing? Tell me in the support forum. (opens in a new tab)