Constants

DESIGN_VERSION

DESIGN_VERSION =2

The design version is incremented each time, we need to distinguish between some UI elements within our cookie banner and content blockers. For example, in a recent version of Real Cookie Banner we removed the footer for content blockers completely, but to be compliant with our documentation we still want to show footers for older consents in our "List of consents".

HTML_ATTRIBUTE_SKIP_IF_ACTIVE

HTML_ATTRIBUTE_SKIP_IF_ACTIVE ='skip-if-active'

HTML_ATTRIBUTE_SKIP_WRITE

HTML_ATTRIBUTE_SKIP_WRITE ='skip-write'

HTML_ATTRIBUTE_UNIQUE_WRITE_NAME

HTML_ATTRIBUTE_UNIQUE_WRITE_NAME ='unique-write-name'

Example:

<script unique-write-name="gtag">console.log("this gets written to DOM");</script>
<script unique-write-name="gtag">console.log("this gets skipped");</script>

HTML_ATTRIBUTE_SKIP_LAZY_LOADING_PLUGINS

HTML_ATTRIBUTE_SKIP_LAZY_LOADING_PLUGINS ='data-skip-lazy-load="js-extra"'

For "Code on page load" we need to ensure no other plugin is lazy loading it. E.g.

WP Rocket transforms inline scripts to rocketlazyloadscript.

js-extra is a common string which does caching plugins or lazy loading plugins ignore as it is similar to the wp_localize_script output tag.

Properties

Methods

getPluginConstantPrefix()

getPluginConstantPrefix(): string

Get the prefix of this plugin so composer packages can dynamically build other constant values on it.

Returns

string

admin_bar_menu()

admin_bar_menu(\WP_Admin_Bar  $admin_bar)

Show a "Show banner again" button in the admin toolbar in frontend.

Parameters

\WP_Admin_Bar $admin_bar

shouldLoadAssets()

shouldLoadAssets(string  $context)

Checks if the banner is active for the current page. This does not check any user relevant conditions because they need to be done in frontend (caching).

Parameters

string $context

The context passed to Assets#enqueue_script_and_styles

isPreventPreDecision()

isPreventPreDecision()

Determine if the current page should not handle a predecision.

See also useBannerPreDecisionGateway.tsx.

wp_head()

wp_head()

The `codeOnPageLoad` can be directly rendered to the Output Buffer cause it does not stand in conflict with any caching plugin (no conditional rendering).

localizeGroups()

localizeGroups()

Localize available cookie groups for frontend.

modifySkipIfActive()

modifySkipIfActive(string  $html,string  $identifier = null)

Make `skip-if-active` work with comma-separated list of active plugins. That means, if a given plugin is active it automatically skips the HTML tag.

Parameters

string $html
string $identifier

The preset identifier (can be null)

wp_footer()

wp_footer()

Print out the overlay so it is server-side rendered (avoid flickering as early as possible).

See also inlineStyle.tsx#overlay for more information!

isHiddenDueLegal()

isHiddenDueLegal()

Checks if the overlay should be hidden due to legal setting. E. g. hide cookie banner on imprint page. This is also a port of `useHiddenDueLegal.tsx`.

getCustomize()

getCustomize()

Getter.

instance()

instance()

New instance.

poweredLink()

poweredLink()

Get the "Powered by" link.

__construct()

__construct()

C'tor.