Documentation

Revision extends AbstractRevisionPersistance
in package
Uses UtilsProvider

Create a mechanism to catch all settings and create an unique revision.

Note: A revision holds any option in "raw", so there isn't any filter or postprocess like a getter.

Table of Contents

Constants

OPTION_NAME_CURRENT_HASH_PREFIX  = RCB_OPT_PREFIX . '-revision-current-hash'
TABLE_NAME  = 'revision'
TABLE_NAME_INDEPENDENT  = 'revision_independent'

Properties

$me  : Revision
Singleton instance.
$revision  : Revision
See `Revision`.

Methods

alterRevision()  : array<string|int, mixed>
Overwrite this method to modify the revision object. This allows you to add additional data to the revision.
alterRevisionIndependent()  : array<string|int, mixed>
Overwrite this method to modify the independent revision object. This allows you to add additional data to the revision.
applyBackwardsCompatibility()  : mixed
See filter `RCB/Revision/BackwardsCompatibility`.
getByHash()  : mixed
Get the revision(s) by hash(es).
getContextVariablesExplicit()  : array<string|int, mixed>
Get explicit context relevant options like language code (WPML, PolyLang). If the language changes, a new revision will be created or requested so they are completely independent.
getContextVariablesImplicit()  : mixed
Get implicit context relevant options like blog id. Implicit context variables are not populated to the context, nor to the revision. Use this only if you want to modify the cookie name!
getContextVariablesString()  : mixed
Get context relevant options as string so they can be used as cookie name or option name.
getCurrent()  : mixed
Get the current revision as array. It also includes the following infos:
getCurrentHash()  : mixed
Get the current active revision hash. Can also return a falsy value when no hash is currently generated.
getCurrentHashOptionName()  : mixed
Get the option for the current hash option name in `wp_options`.
getInstance()  : mixed
Get singleton instance.
getPluginConstantPrefix()  : string
Get the prefix of this plugin so composer packages can dynamically build other constant values on it.
getRevision()  : mixed
Getter.
needsRetrigger()  : bool
Checks if the given current revision (result of `getCurrent`) needs a retrigger.
persist()  : mixed
Persist an revision JSON string to database.
persistIndependent()  : mixed
Persist an independent revision JSON string to database.
setRevision()  : mixed
Setter.
translateContextVariablesString()  : string
See filter RCB/Revision/Context/Translate.
__construct()  : mixed
C'tor.

Constants

OPTION_NAME_CURRENT_HASH_PREFIX

public mixed OPTION_NAME_CURRENT_HASH_PREFIX = RCB_OPT_PREFIX . '-revision-current-hash'

TABLE_NAME

public mixed TABLE_NAME = 'revision'

TABLE_NAME_INDEPENDENT

public mixed TABLE_NAME_INDEPENDENT = 'revision_independent'

Properties

Methods

alterRevision()

Overwrite this method to modify the revision object. This allows you to add additional data to the revision.

public alterRevision(mixed &$revision) : array<string|int, mixed>
Parameters
$revision : mixed
Return values
array<string|int, mixed>

alterRevisionIndependent()

Overwrite this method to modify the independent revision object. This allows you to add additional data to the revision.

public alterRevisionIndependent(mixed &$revision) : array<string|int, mixed>
Parameters
$revision : mixed
Return values
array<string|int, mixed>

applyBackwardsCompatibility()

See filter `RCB/Revision/BackwardsCompatibility`.

public applyBackwardsCompatibility(array<string|int, mixed> $revision[, bool $independent = false ]) : mixed
Parameters
$revision : array<string|int, mixed>
$independent : bool = false

getByHash()

Get the revision(s) by hash(es).

public getByHash(string|array<string|int, string> $hash[, bool $independent = false ][, bool $applyBackwardsCompatibility = false ]) : mixed
Parameters
$hash : string|array<string|int, string>
$independent : bool = false
$applyBackwardsCompatibility : bool = false

See method applyBackwardsCompatibility

getContextVariablesExplicit()

Get explicit context relevant options like language code (WPML, PolyLang). If the language changes, a new revision will be created or requested so they are completely independent.

public getContextVariablesExplicit() : array<string|int, mixed>

They also get populated to the generated revision.

Warning: Cookie names cannot contain any of the following '=,; \t\r\n\013\014', so please make sure such characters are not stored in your value (if so, they get replaced with underscore _).

Return values
array<string|int, mixed>

getContextVariablesImplicit()

Get implicit context relevant options like blog id. Implicit context variables are not populated to the context, nor to the revision. Use this only if you want to modify the cookie name!

public getContextVariablesImplicit() : mixed

Warning: Cookie names cannot contain any of the following '=,; \t\r\n\013\014', so please make sure such characters are not stored in your value (if so, they get replaced with underscore _).

getContextVariablesString()

Get context relevant options as string so they can be used as cookie name or option name.

public getContextVariablesString([bool $implicit = false ]) : mixed
Parameters
$implicit : bool = false

If true, implicit context variables are parsed, otherwise explicit context variables

getCurrent()

Get the current revision as array. It also includes the following infos:

public getCurrent([bool $recreate = false ]) : mixed
  • public_to_users: The revision hash currently published to users
  • calculated: The current revision hash from the latest settings
  • created_tag_managers: Has a cookie with a valid Google/Matomo Tag Manager script (so you can show a notice in your config UI)
  • public_count: A total count of public cookies
Parameters
$recreate : bool = false

If true, a new revision gets created so new consents need to be made. Always recreates when no consents are given yet.

getCurrentHash()

Get the current active revision hash. Can also return a falsy value when no hash is currently generated.

public getCurrentHash() : mixed

getCurrentHashOptionName()

Get the option for the current hash option name in `wp_options`.

public getCurrentHashOptionName() : mixed

getInstance()

Get singleton instance.

public static getInstance() : mixed
Tags
codeCoverageIgnore

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

needsRetrigger()

Checks if the given current revision (result of `getCurrent`) needs a retrigger.

public needsRetrigger(array<string|int, mixed> $revision) : bool
Parameters
$revision : array<string|int, mixed>

Result of getCurrent

Return values
bool

persist()

Persist an revision JSON string to database.

public persist(mixed $result, mixed $forceNewConsent) : mixed
Parameters
$result : mixed

revision and hash

$forceNewConsent : mixed

If true update the hash to the database to getCurrentHash() returns that hash

persistIndependent()

Persist an independent revision JSON string to database.

public persistIndependent(mixed $result) : mixed
Parameters
$result : mixed

revision and hash

translateContextVariablesString()

See filter RCB/Revision/Context/Translate.

public translateContextVariablesString(string $context) : string
Parameters
$context : string
Return values
string

__construct()

C'tor.

private __construct() : mixed

        
On this page

Search results