{eac}Doojigger Reference

cookie_consent

cookie_consent trait - Advanced set cookies using WP Consent API

Tags
category

WordPress Plugin

author

Kevin Burkholder KBurkholder@EarthAsylum.com

copyright

Copyright (c) 2024 EarthAsylum Consulting <www.EarthAsylum.com>

version
24.0821.1

Table of Contents

$cookie_default_service  : string
cookie_consent_hack()  : void
enqueue javascripts to patch consent interface between browser and server
get_cookie()  : string
get a cookie (convenience method, since we have set_cookie)
get_cookie_consent()  : array<string|int, mixed>
get a registered cookie consent array for a single cookie or all cookies
set_cookie()  : bool
set a cookie supporting wp_consent if enabled
set_cookie_consent()  : array<string|int, mixed>
set a cookie's consent information
set_cookie_expiration()  : array<string|int, mixed>
set a cookie expiration as integer and string

Properties

public string $cookie_default_service = ''

defaul consent service name (set bay using class)

Methods

enqueue javascripts to patch consent interface between browser and server

public cookie_consent_hack() : void
Return values
void

get a cookie (convenience method, since we have set_cookie)

public get_cookie(string $name[, string $default = null ]) : string
Parameters
$name : string

the cookie name

$default : string = null

if cookie not set

Return values
string

cookie value

get a registered cookie consent array for a single cookie or all cookies

public get_cookie_consent([string $name = false ]) : array<string|int, mixed>
Parameters
$name : string = false

the cookie name (optional)

Return values
array<string|int, mixed>

$consent or array of [name => $consent]

set a cookie supporting wp_consent if enabled

public set_cookie(string $name, string $value, string|int $expires[, array<string|int, mixed> $options = [] ][, mixed $consent = [] ]) : bool
Parameters
$name : string

the cookie name

$value : string

the cookie value

$expires : string|int

cookie expiration in seconds or timestamp or string 'delete', 'expired', 'session', 'n days', 'n months', etc.

$options : array<string|int, mixed> = []

cookie parameters 'path', 'domain', 'secure', 'httponly', 'samesite'.

$consent : mixed = []

(array) consent parameters or (string) category or true, already registered 'plugin_or_service', 'category', 'function', ...

Return values
bool

success or failure (as best we can tell)

set a cookie's consent information

public set_cookie_consent(string $name, array<string|int, mixed>|string $consent[, bool $register = true ][, array<string|int, mixed> $defaults = [] ]) : array<string|int, mixed>
Parameters
$name : string

the cookie name

$consent : array<string|int, mixed>|string

consent parameters or category 'plugin_or_service', 'category', 'function', ...

$register : bool = true

with wp_add_cookie_info()

$defaults : array<string|int, mixed> = []

default consent parameters

Return values
array<string|int, mixed>

$consent

set a cookie expiration as integer and string

public set_cookie_expiration(string|int $expires[, bool $getString = true ]) : array<string|int, mixed>
Parameters
$expires : string|int

cookie expiration in seconds or timestamp or string 'delete', 'expired', 'session', 'n days', 'n months', etc.

$getString : bool = true

(false) return array when true

Return values
array<string|int, mixed>

[ $expInt, $expStr ]

Search results