Documentation

CountryBypass extends AbstractCountryBypass
in package
implements IOverrideCountryBypass Uses CountryBypass, UtilsProvider

Bypass the cookie banner for a specific set of countries.

Table of Contents

Interfaces

IOverrideCountryBypass

Constants

CUSTOM_BYPASS  = 'geolocation'
Name for the custom bypass saved in the database.
DEFAULT_COUNTRY_BYPASS_ACTIVE  = false
DEFAULT_COUNTRY_BYPASS_COUNTRIES  = 'GDPR,CCPA,GB,CH'
DEFAULT_COUNTRY_BYPASS_DB_DOWNLOAD_TIME  = ''
DEFAULT_COUNTRY_BYPASS_TYPE  = self::TYPE_ALL
OPTION_COUNTRY_DB_NEXT_DOWNLOAD_TIME  = RCB_OPT_PREFIX . '-country-db-next-download-time'
OPTION_GROUP  = 'options'
PREDEFINED_COUNTRY_LISTS  = [ // EU: https://reciprocitylabs.com/resources/what-countries-are-covered-by-gdpr/ // EEA: https://ec.europa.eu/eurostat/statistics-explained/index.php?title=Glossary:European_Economic_Area_(EEA) 'GDPR' => ['AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HU', 'IE', 'IS', 'IT', 'LI', 'LV', 'LT', 'LU', 'MT', 'NL', 'NO', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE'], 'CCPA' => ['US'], ]
A list of predefined lists for e.g. `GDPR` or `CCPA`.
SETTING_COUNTRY_BYPASS_ACTIVE  = RCB_OPT_PREFIX . '-country-bypass'
SETTING_COUNTRY_BYPASS_COUNTRIES  = RCB_OPT_PREFIX . '-country-bypass-countries'
SETTING_COUNTRY_BYPASS_DB_DOWNLOAD_TIME  = RCB_OPT_PREFIX . '-country-bypass-db-download-time'
SETTING_COUNTRY_BYPASS_TYPE  = RCB_OPT_PREFIX . '-country-bypass-type'
TYPE_ALL  = 'all'
TYPE_ESSENTIALS  = 'essentials'

Properties

$me  : CountryBypass
Singleton instance.
$previousActive  : bool
Save the state of currently active so we can update country database at toggle time.
$settings  : Settings
See Settings

Methods

clearDatabase()  : mixed
dynamicPredecision()  : mixed
Determines, if the current page request is outside our defined countries so all cookies are automatically accepted.
enableOptionsAutoload()  : mixed
Initially `add_option` to avoid autoloading issues.
getCountries()  : array<string|int, string>
Get the list of countries where the banner should be shown, expanded with predefined lists (ISO 3166-1 alpha2).
getCountriesRaw()  : array<string|int, string>
Get the list of countries where the banner should be shown.
getDatabaseDownloadTime()  : mixed
getInstance()  : CountryBypass
Get singleton instance.
getNextUpdateTime()  : mixed
Changes to the country database are published daily, but we do this only once a week.
getPluginConstantPrefix()  : string
Get the prefix of this plugin so composer packages can dynamically build other constant values on it.
getSettings()  : mixed
Getter.
getType()  : string
Get the type for the Country Bypass. Can be `all` or `essentials` (see class constants).
isActive()  : bool
Check if compatibility is enabled.
lookupCountryCode()  : string
Get the country for the passed IP address.
overrideEnableOptionsAutoload()  : mixed
overrideRegister()  : mixed
probablyCreateTransaction()  : mixed
If Country Bypass is active and the requested IP address does match our settings, we can prepare a `Tansaction` instance which we can instantly use to `Consent#commit` so the user does not see any cookie banner (see also the term "Predecision Gateway").
probablyUpdateDatabase()  : mixed
register()  : mixed
Register settings.
rest_pre_get_setting()  : mixed
Output the download time as ISO string instead of mysql formatted string.
setSettings()  : mixed
Setter.
updated_option_active()  : mixed
The option to enable Country Bypass got updated, let's automatically download the country database.
updateDatabase()  : mixed
__construct()  : mixed
C'tor.

Constants

CUSTOM_BYPASS

Name for the custom bypass saved in the database.

public mixed CUSTOM_BYPASS = 'geolocation'

DEFAULT_COUNTRY_BYPASS_ACTIVE

public mixed DEFAULT_COUNTRY_BYPASS_ACTIVE = false

DEFAULT_COUNTRY_BYPASS_COUNTRIES

public mixed DEFAULT_COUNTRY_BYPASS_COUNTRIES = 'GDPR,CCPA,GB,CH'

DEFAULT_COUNTRY_BYPASS_DB_DOWNLOAD_TIME

public mixed DEFAULT_COUNTRY_BYPASS_DB_DOWNLOAD_TIME = ''

DEFAULT_COUNTRY_BYPASS_TYPE

public mixed DEFAULT_COUNTRY_BYPASS_TYPE = self::TYPE_ALL

OPTION_COUNTRY_DB_NEXT_DOWNLOAD_TIME

public mixed OPTION_COUNTRY_DB_NEXT_DOWNLOAD_TIME = RCB_OPT_PREFIX . '-country-db-next-download-time'

PREDEFINED_COUNTRY_LISTS

A list of predefined lists for e.g. `GDPR` or `CCPA`.

public mixed PREDEFINED_COUNTRY_LISTS = [ // EU: https://reciprocitylabs.com/resources/what-countries-are-covered-by-gdpr/ // EEA: https://ec.europa.eu/eurostat/statistics-explained/index.php?title=Glossary:European_Economic_Area_(EEA) 'GDPR' => ['AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HU', 'IE', 'IS', 'IT', 'LI', 'LV', 'LT', 'LU', 'MT', 'NL', 'NO', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE'], 'CCPA' => ['US'], ]

SETTING_COUNTRY_BYPASS_ACTIVE

public mixed SETTING_COUNTRY_BYPASS_ACTIVE = RCB_OPT_PREFIX . '-country-bypass'

SETTING_COUNTRY_BYPASS_COUNTRIES

public mixed SETTING_COUNTRY_BYPASS_COUNTRIES = RCB_OPT_PREFIX . '-country-bypass-countries'

SETTING_COUNTRY_BYPASS_DB_DOWNLOAD_TIME

public mixed SETTING_COUNTRY_BYPASS_DB_DOWNLOAD_TIME = RCB_OPT_PREFIX . '-country-bypass-db-download-time'

SETTING_COUNTRY_BYPASS_TYPE

public mixed SETTING_COUNTRY_BYPASS_TYPE = RCB_OPT_PREFIX . '-country-bypass-type'

Properties

$previousActive

Save the state of currently active so we can update country database at toggle time.

private bool $previousActive = null

Methods

dynamicPredecision()

Determines, if the current page request is outside our defined countries so all cookies are automatically accepted.

public dynamicPredecision(false|string $result, WP_REST_Request $request) : mixed
Parameters
$result : false|string
$request : WP_REST_Request

enableOptionsAutoload()

Initially `add_option` to avoid autoloading issues.

public enableOptionsAutoload() : mixed

getCountries()

Get the list of countries where the banner should be shown, expanded with predefined lists (ISO 3166-1 alpha2).

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

getCountriesRaw()

Get the list of countries where the banner should be shown.

public abstract getCountriesRaw() : array<string|int, string>
Return values
array<string|int, string>

getDatabaseDownloadTime()

public getDatabaseDownloadTime() : mixed

getNextUpdateTime()

Changes to the country database are published daily, but we do this only once a week.

public static getNextUpdateTime() : mixed

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

getSettings()

Getter.

public getSettings() : mixed
Tags
codeCoverageIgnore

getType()

Get the type for the Country Bypass. Can be `all` or `essentials` (see class constants).

public abstract getType() : string
Return values
string

isActive()

Check if compatibility is enabled.

public abstract isActive() : bool
Return values
bool

lookupCountryCode()

Get the country for the passed IP address.

public abstract lookupCountryCode(string $ipAddress) : string
Parameters
$ipAddress : string
Return values
string

overrideEnableOptionsAutoload()

public overrideEnableOptionsAutoload() : mixed

probablyCreateTransaction()

If Country Bypass is active and the requested IP address does match our settings, we can prepare a `Tansaction` instance which we can instantly use to `Consent#commit` so the user does not see any cookie banner (see also the term "Predecision Gateway").

public probablyCreateTransaction(Consent $consent, Transaction $transaction) : mixed
Parameters
$consent : Consent

The current consent

$transaction : Transaction

A prepared transaction which has userAgent, ipAddress filled

probablyUpdateDatabase()

public probablyUpdateDatabase() : mixed

rest_pre_get_setting()

Output the download time as ISO string instead of mysql formatted string.

public rest_pre_get_setting(mixed $result, string $name, array<string|int, mixed> $args) : mixed
Parameters
$result : mixed

Value to use for the requested setting. Can be a scalar matching the registered schema for the setting, or null to follow the default get_option() behavior.

$name : string

Setting name (as shown in REST API responses).

$args : array<string|int, mixed>

Arguments passed to register_setting() for this setting.

updated_option_active()

The option to enable Country Bypass got updated, let's automatically download the country database.

public updated_option_active(WP_REST_Response $response, WP_REST_Request $request) : mixed
Parameters
$response : WP_REST_Response
$request : WP_REST_Request

updateDatabase()

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

        
On this page

Search results