Documentation

BannerCustomize extends AbstractCustomizePanel
in package
Uses UtilsProvider

Customize cookie box in customize. Conditional UI is implemented in `others/conditionalBanner.tsx`.

Table of Contents

Constants

NEEDED_CAPABILITY  = \DevOwl\RealCookieBanner\Core::MANAGE_MIN_CAPABILITY
PANEL_MAIN  = 'real-cookie-banner-banner'
TRANSLATE_SECTIONS  = ['texts', 'individualTexts']
WEB_SAFE_FONT_FAMILY  = ['Georgia, serif', '"Palatino Linotype", "Book Antiqua", Palatino, serif', '"Times New Roman", Times, serif', 'Arial, Helvetica, sans-serif', '"Arial Black", Gadget, sans-serif', '"Comic Sans MS", cursive, sans-serif', 'Impact, Charcoal, sans-serif', '"Lucida Sans Unicode", "Lucida Grande", sans-serif', 'Tahoma, Geneva, sans-serif', '"Trebuchet MS", Helvetica, sans-serif', 'Verdana, Geneva, sans-serif', '"Courier New", Courier, monospace', '"Lucida Console", Monaco, monospace']
Cross-browser compatible font families.

Properties

$manager  : WP_Customize_Manager
The manager received through customize_register.
$name  : string
The name of this panel.
$panel  : string
The main panel ID.
$sections  : array<string|int, mixed>
Cached sections definition.

Methods

__construct()  : mixed
C'tor.
customize_register()  : mixed
Add cookie banner section. If you need a more granular customization you can safely override this method!
enableOptionsAutoload()  : mixed
Write defaults to database via `add_option` to avoid performance issues with `get_option` (autoload).
expandLocalizeValues()  : mixed
Expand localize values by e.g. header logo dimensions. This is not needed for the customize nor export, but for the frontend to fit Web Vitals.
getManager()  : mixed
Get manager.
getName()  : mixed
Get name.
getPanel()  : mixed
Get main panel id.
getPluginConstantPrefix()  : string
Get the prefix of this plugin so composer packages can dynamically build other constant values on it.
getSections()  : mixed
Return sections for this panel with caching mechanism.
getSetting()  : mixed
Get value of a setting. Unfortunately, getting the managers' settings does not work as expected because they are only available in customize, and not in frontend. We need to reconstruct the #value method.
getUrl()  : mixed
Get the live preview url with autofocus.
gotUpdated()  : mixed
Check depending on the `$response` of `customize_save_response` hook if a specific prefix got changed.
instance()  : mixed
New instance.
isPoweredByLinkDisabledByException()  : mixed
Check if powered-by link is disabled through our license server.
localizeDefaultValues()  : mixed
Localize for frontend (customize defaults so they can be resetted)
localizeIds()  : mixed
Localize for frontend (registered panel, section and setting IDs).
localizeValues()  : mixed
Localize for frontend (customize values)
resolveSections()  : array<string|int, mixed>
Return sections for this panel. Do not directly use this, use `getSections` instead.
sanitize_checkbox()  : bool
Sanitize boolean for checkbox. Note: We need to sanitize the value to "y" or "n".
controlDefaults()  : array<string|int, mixed>
Override this for default control arguments.
getPanelArgs()  : array<string|int, mixed>
Return main arguments for this panel.
getSkipControlClasses()  : array<string|int, string>
Override this for default overrides arguments.
registerSections()  : mixed
Register sections from the dynamic array.
sectionDefaults()  : array<string|int, mixed>
Override this for default section arguments.
settingDefaults()  : array<string|int, mixed>
Override this for default setting arguments.
translateArray()  : mixed
Translate the banner array with the help of `translateArray`.

Constants

NEEDED_CAPABILITY

public mixed NEEDED_CAPABILITY = \DevOwl\RealCookieBanner\Core::MANAGE_MIN_CAPABILITY

TRANSLATE_SECTIONS

public mixed TRANSLATE_SECTIONS = ['texts', 'individualTexts']

WEB_SAFE_FONT_FAMILY

Cross-browser compatible font families.

public mixed WEB_SAFE_FONT_FAMILY = ['Georgia, serif', '"Palatino Linotype", "Book Antiqua", Palatino, serif', '"Times New Roman", Times, serif', 'Arial, Helvetica, sans-serif', '"Arial Black", Gadget, sans-serif', '"Comic Sans MS", cursive, sans-serif', 'Impact, Charcoal, sans-serif', '"Lucida Sans Unicode", "Lucida Grande", sans-serif', 'Tahoma, Geneva, sans-serif', '"Trebuchet MS", Helvetica, sans-serif', 'Verdana, Geneva, sans-serif', '"Courier New", Courier, monospace', '"Lucida Console", Monaco, monospace']
Tags
see
https://www.w3schools.com/cssref/css_websafe_fonts.asp

Properties

Methods

customize_register()

Add cookie banner section. If you need a more granular customization you can safely override this method!

public customize_register(WP_Customize_Manager $wp_customize) : mixed
Parameters
$wp_customize : WP_Customize_Manager

enableOptionsAutoload()

Write defaults to database via `add_option` to avoid performance issues with `get_option` (autoload).

public enableOptionsAutoload() : mixed

expandLocalizeValues()

Expand localize values by e.g. header logo dimensions. This is not needed for the customize nor export, but for the frontend to fit Web Vitals.

public expandLocalizeValues(array<string|int, mixed> &$values) : mixed

It also disables the footer link if our license server orders this.

Parameters
$values : array<string|int, mixed>

Result of localizeValues

getPluginConstantPrefix()

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

public getPluginConstantPrefix() : string
Tags
codeCoverageIgnore

It only returns a string with the constant prefix

Return values
string

getSections()

Return sections for this panel with caching mechanism.

public getSections([bool $force = false ]) : mixed
Parameters
$force : bool = false

getSetting()

Get value of a setting. Unfortunately, getting the managers' settings does not work as expected because they are only available in customize, and not in frontend. We need to reconstruct the #value method.

public getSetting(string $id[, bool $resolve = true ]) : mixed
Parameters
$id : string

The unique ID of the setting

$resolve : bool = true

If false, it returns always the default values

Tags
throws
Exception

When no setting with the given ID was found

see
https://developer.wordpress.org/reference/classes/wp_customize_setting/value/

gotUpdated()

Check depending on the `$response` of `customize_save_response` hook if a specific prefix got changed.

public static gotUpdated(array<string|int, mixed> $response, string $prefix) : mixed
Parameters
$response : array<string|int, mixed>
$prefix : string

instance()

New instance.

public static instance() : mixed
Tags
codeCoverageIgnore

isPoweredByLinkDisabledByException()

Check if powered-by link is disabled through our license server.

public isPoweredByLinkDisabledByException() : mixed

localizeDefaultValues()

Localize for frontend (customize defaults so they can be resetted)

public localizeDefaultValues([mixed $skipControlClasses = [] ]) : mixed
Parameters
$skipControlClasses : mixed = []

localizeIds()

Localize for frontend (registered panel, section and setting IDs).

public localizeIds() : mixed

localizeValues()

Localize for frontend (customize values)

public localizeValues([mixed $skipControlClasses = [] ]) : mixed
Parameters
$skipControlClasses : mixed = []

resolveSections()

Return sections for this panel. Do not directly use this, use `getSections` instead.

public resolveSections() : array<string|int, mixed>
Return values
array<string|int, mixed>

Documentation follows soon, in the meantime have a look at Real Cookie Banner implementation

sanitize_checkbox()

Sanitize boolean for checkbox. Note: We need to sanitize the value to "y" or "n".

public static sanitize_checkbox(bool $checked) : bool
Parameters
$checked : bool

Whether or not a box is checked.

Tags
see
https://developer.wordpress.org/reference/functions/bool_from_yn/
see
https://github.com/WordPress/WordPress/blob/6677070a138f46d38517149472229a29324a95f4/wp-content/themes/twentytwenty/classes/class-twentytwenty-customize.php#L457
Return values
bool

controlDefaults()

Override this for default control arguments.

protected controlDefaults() : array<string|int, mixed>
Return values
array<string|int, mixed>

getPanelArgs()

Return main arguments for this panel.

protected getPanelArgs() : array<string|int, mixed>
Return values
array<string|int, mixed>

getSkipControlClasses()

Override this for default overrides arguments.

protected getSkipControlClasses() : array<string|int, string>
Return values
array<string|int, string>

registerSections()

Register sections from the dynamic array.

protected registerSections(array<string|int, mixed> $sections) : mixed
Parameters
$sections : array<string|int, mixed>

Result of getSections

sectionDefaults()

Override this for default section arguments.

protected sectionDefaults() : array<string|int, mixed>
Return values
array<string|int, mixed>

settingDefaults()

Override this for default setting arguments.

protected settingDefaults() : array<string|int, mixed>
Return values
array<string|int, mixed>

translateArray()

Translate the banner array with the help of `translateArray`.

protected translateArray(array<string|int, mixed> $customizeValues, string $mapKey) : mixed
Parameters
$customizeValues : array<string|int, mixed>
$mapKey : string

Can be customizeDefaults or customizeValuesBanner


        
On this page

Search results