List_Command
in package
Manages one list-type setting — IP block/allow list, UA block list or the interceptor path list. The same class backs the blocklist, allowlist, ua-blocklist and paths command namespaces.
Table of Contents
Properties
- $key : string
- The list setting key this instance manages.
- $validation : string
- Validation type: 'ip' (IP/CIDR), 'action' (action-slug charset), 'cookie' (name=value), or 'text' (plain).
Methods
- __construct() : mixed
- add() : void
- Adds one or more entries to the list.
- clear() : void
- Empties the list.
- list_entries() : void
- Prints the current list entries.
- remove() : void
- Removes one or more entries from the list.
- current() : array<int, string>
- The current list value.
- is_ip_or_cidr() : bool
- Whether the value is a valid IP address or CIDR range.
- normalise() : string|null
- Validates and normalises one entry; returns null when invalid.
- save() : void
- Writes the list back through the settings sanitiser.
Properties
$key
The list setting key this instance manages.
private
string
$key
$validation
Validation type: 'ip' (IP/CIDR), 'action' (action-slug charset), 'cookie' (name=value), or 'text' (plain).
private
string
$validation
Methods
__construct()
public
__construct(string $key[, string $validation = 'text' ]) : mixed
Parameters
- $key : string
-
The list setting key.
- $validation : string = 'text'
-
'ip' (IP/CIDR), 'action' (action slug), 'cookie' (name=value), or 'text' (plain).
add()
Adds one or more entries to the list.
public
add(array<int, string> $args, array<string, string> $assoc_args) : void
OPTIONS
EXAMPLES
wp creacaptcha blocklist add 203.0.113.4 203.0.113.0/24
Parameters
- $args : array<int, string>
-
Positional arguments.
- $assoc_args : array<string, string>
-
Associative arguments.
clear()
Empties the list.
public
clear(array<int, string> $args, array<string, string> $assoc_args) : void
OPTIONS
[--yes] : Skip the confirmation prompt.
EXAMPLES
wp creacaptcha blocklist clear --yes
Parameters
- $args : array<int, string>
-
Positional arguments.
- $assoc_args : array<string, string>
-
Associative arguments.
list_entries()
Prints the current list entries.
public
list_entries(array<int, string> $args, array<string, string> $assoc_args) : void
OPTIONS
[--format=
EXAMPLES
wp creacaptcha blocklist list
Parameters
- $args : array<int, string>
-
Positional arguments.
- $assoc_args : array<string, string>
-
Associative arguments.
Tags
remove()
Removes one or more entries from the list.
public
remove(array<int, string> $args, array<string, string> $assoc_args) : void
OPTIONS
EXAMPLES
wp creacaptcha blocklist remove 203.0.113.4
Parameters
- $args : array<int, string>
-
Positional arguments.
- $assoc_args : array<string, string>
-
Associative arguments.
current()
The current list value.
private
current() : array<int, string>
Return values
array<int, string>is_ip_or_cidr()
Whether the value is a valid IP address or CIDR range.
private
is_ip_or_cidr(string $value) : bool
Parameters
- $value : string
-
Candidate value.
Return values
boolnormalise()
Validates and normalises one entry; returns null when invalid.
private
normalise(string $raw) : string|null
Parameters
- $raw : string
-
Raw entry value.
Return values
string|nullsave()
Writes the list back through the settings sanitiser.
private
save(array<int, string> $list) : void
Parameters
- $list : array<int, string>
-
The new list.