Consent-gate any enqueued script by handle for Kjeks.
Assign a registered script handle to a consent category, and the script stays inert until the visitor consents to that category. No code changes to the scripts themselves — you gate them by handle from an admin screen.
- WordPress 6.8+
- PHP 8.3+
- The Kjeks plugin (active) — it provides
the consent UI, the script gate, and the shared
AddonKitbase classes.
- A script is registered/enqueued with a handle (by a theme, plugin, or your
own code) — for example
google-analyticsorhotjar. - On the settings screen you map that handle to a consent category (Analytics, Marketing, or Preferences).
- On the front end the add-on registers each mapped handle with the core Kjeks
blocking registry. Core rewrites the tag to
type="text/plain"withdata-kjeks-category, so the browser does not run it until consent is given.
- Multisite: Network Admin → Settings → Kjeks Scripting (network-wide).
- Single site: Settings → Kjeks Scripting.
Type or pick a script handle (the field suggests handles registered in the admin), choose its category, and save. Add as many rows as you need; leave a row blank to ignore it.
Handles are the first argument passed to wp_enqueue_script() /
wp_register_script(). Check the enqueuing plugin/theme, or view source and
look at the id attribute of the <script> tag (WordPress appends -js, e.g.
id="google-analytics-js" → handle google-analytics).
Self-updates from GitHub releases. For a private repository, define a
KJEKS_GITHUB_TOKEN constant in wp-config.php.
GPL-2.0-or-later. Copyright Per Søderlind.