Skip to content

Developers

← Documentation

Written for Cookie Rocks 2.9.5, checked on 1 November 2026. The current version is 2.11.2: some details may have changed.

What you can do here

  • Place the cookie policy and a “Manage cookies” link in your theme, with shortcodes.
  • Hold your own scripts until consent, and react to the visitor’s choice, with JavaScript.
  • Change texts, categories, known cookies and the look of the banner, with PHP filters and CSS.

This section lists every shortcode, hook, REST route, constant and JavaScript event of the plugins, and says which plugin provides each one.

Two plugins

Cookie Rocks AuditCookie Rocks Pro
PriceFreePaid, with a free trial
Plugin foldercookie-rockscookie-rocks-banner
Constant defined when activeCOOKIE_ROCKS_VERSIONCOOKIE_ROCKS_BANNER_VERSION
Text domaincookie-rockscookie-rocks-banner
On your visitors’ pagesNothing, except the cookie policy where you place its shortcodeThe banner, the cookie button, the blocking of trackers, the consent signals

Cookie Rocks Pro works on top of the Audit. Without the Audit active, it does nothing on your site and offers to install it. Both plugins keep their settings in one shared option, cookie_rocks_settings, and share the Cookie Rocks menu.

To run code only when Pro is there:

if ( defined( 'COOKIE_ROCKS_BANNER_VERSION' ) ) {
	// Cookie Rocks Pro is active: the banner, window.CookieRocks and the PHP filters of the banner exist.
}

What you can use

PageAuditPro
Shortcodes[cookie_rocks_policy][cookie_rocks_policy], [cookie_rocks_link], and the other ways to reopen the choices
PHP filters, actions and REST APIFilters on categories, known cookies, news and checks; one action after each admin pageFilters on texts, configuration, Google Consent Mode, optimisation and protected pages; one action for accounts managed outside WordPress; three REST routes, for the register of proofs and the rules by country
JavaScript API and eventsNone: the Audit adds no script for visitorswindow.CookieRocks, DOM events, Google Tag Manager events, holding your own scripts and frames
CSS (below)None: the policy takes the style of your themeVariables and classes of the banner

The Developers page of the admin lists the 675 tools whose cookies Cookie Rocks knows. For a tool it does not know, hold its script with a few HTML attributes, or add it to the catalogue with the cookie_rocks_services filter.

Constants
ConstantSet byPluginUse
COOKIE_ROCKS_VERSIONThe pluginAuditVersion of the Audit. Defined when the Audit is active.
COOKIE_ROCKS_BANNER_VERSIONThe pluginProVersion of Cookie Rocks Pro. Defined when Pro is active.
COOKIE_ROCKS_APIYou, in wp-config.phpProAnother address for the Cookie Rocks key service, for tests. Pro then sends there every call about the key, such as confirming it and checking for updates. End it with a slash. Leave it undefined on a live site.
SCRIPT_DEBUGYou, in wp-config.phpProA WordPress constant. When true, Cookie Rocks Pro serves its readable scripts and stylesheets instead of the minified ones.
// wp-config.php, test site only.
define( 'COOKIE_ROCKS_API', 'https://keys.example.test/wp-json/cookierocks/v1/' );

Change the look with CSS

This applies to the banner of Cookie Rocks Pro. Start with the Appearance page: colours, corners, distance from the edges and shadows are settings there. Use CSS for what the page does not offer.

  1. Open the place where your site keeps its own CSS: Appearance, Customize, Additional CSS (classic themes), Appearance, Editor, Styles, Additional CSS (block themes), the custom CSS field of your theme or page builder, or your child theme.
  2. Write your rules on .cr-root[data-theme], so that they apply in the light and dark themes.
  3. For a variable that the Appearance page also sets, add !important. See why below.
/* Square corners and a lighter shadow, in light and dark themes */
.cr-root[data-theme] {
	--cr-radius: 6px !important;
	--cr-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}

/* Buttons in capital letters */
.cr-root .cr-btn {
	text-transform: uppercase;
	letter-spacing: .04em;
}

If your CSS value is ignored. The banner writes the values chosen on the Appearance page in the style attribute of .cr-root: --cr-accent, --cr-accent-text, --cr-accent-ink, --cr-accent-dark (when the accent lacks contrast in the dark theme), --cr-radius, --cr-gap, and --cr-sh when Shadows is off. These inline values win over your stylesheet. A value left at its default is not written, so a rule without !important works only while that setting stays at its default (for example Rounded corners at 20). Add !important, or change the setting on the Appearance page.

Variables
VariableWhat it sets
--cr-accentAccent colour: buttons and switches. Set it on the Appearance page.
--cr-accent-textText on the accent colour. Chosen automatically to stay readable.
--cr-bgBackground of the banner and the details.
--cr-fgMain text.
--cr-mutedSecondary text.
--cr-lineBorders and separators.
--cr-softLight backgrounds: the “Let me choose” button, the categories.
--cr-trackSwitches that are off.
--cr-shadowShadow of the banner and the details. When Shadows is off, no shadow is shown, whatever this value.
--cr-radiusRounded corners, in pixels (0 to 32, 20 by default). Set it on the Appearance page.
--cr-gapDistance between the banner and the screen edges, in pixels (0 to 40, 20 by default). Set it with Distance from the screen edges on the Appearance page. At 0, the box sits in the corner. The bar layout does not use it. On phones, the distance is 8 px at most.
Classes
ClassWhat it is
.cr-rootContainer of everything. Attributes: data-theme (auto, light, dark), data-layout (box, bar), data-position (left, right).
.cr-bannerThe banner.
.cr-eyebrow, .cr-title, .cr-textSite name, title and text of the banner.
.cr-btn--solid“Reject all” and “Accept all” buttons (same look, as the law requires). With Highlight “Accept all” on the Appearance page, “Reject all” becomes .cr-btn--outline.
.cr-btn--soft“Let me choose” button.
.cr-dialogThe details window, with .cr-cat for each category and .cr-switch for the switches.
.cr-widgetThe cookie button.
.cr-toastThe short message after a choice.
.cr-form-noticeThe request shown above forms protected by reCAPTCHA.
.cr-manage-linkThe “Manage cookies” link of the shortcode.

Video and map placeholders are drawn inside their own frame: they follow the accent colour, not your CSS.

Next step: Shortcodes.