Settings_Command
in package
Reads, writes, exports, imports and resets CreaCaptcha settings.
Table of Contents
Constants
- BOOL_WORDS = ['true' => ['1', 'true', 'yes', 'on'], 'false' => ['0', 'false', 'no', 'off']]
- The words `parse_bool()` accepts, per resulting value.
Methods
- count_dropped_list_entries() : int
- Zählt, wie viele Listeneinträge zwischen zwei Settings-Ständen verschwunden sind — reine Zähllogik, öffentlich für den direkten Ebene-2-Test (dieselbe Begründung wie bei `sensitive_value_notice()` oben). Zählt nur VERLUSTE (ein Feld mit mehr Einträgen danach als vorher trägt 0 bei, nicht negativ).
- export() : void
- Exports all settings as JSON.
- get() : void
- Prints one setting value.
- import() : void
- Imports settings from a JSON file.
- list_settings() : void
- Lists all settings as key/value pairs.
- load_defaults() : void
- Resets configuration values to default but keeps the lists.
- parse_bool() : bool|null
- Parses a boolean-ish CLI string; NULL for anything that is neither.
- reset() : void
- Resets every setting to its default — including emptying all lists.
- sensitive_value_notice() : string|null
- Warnt vor Klartext-Geheimnissen, die eine Ausgabe gleich mitliefert — dieselben zwei Felder, die `export()` schon benennt (B-M22).
- set() : void
- Sets one setting value.
- report_reset_state() : void
- Prints the success line of `reset`/`load-defaults` together with the one consequence that is easy to overlook: the event log is back to its default (off).
- stringify() : string
- Converts a setting value to a printable string.
- warn_if_inside_webroot() : void
- Warns when the export target lies inside the WordPress installation directory and would therefore likely be reachable over HTTP.
Constants
BOOL_WORDS
The words `parse_bool()` accepts, per resulting value.
public
array<string, array<int, string>>
BOOL_WORDS
= ['true' => ['1', 'true', 'yes', 'on'], 'false' => ['0', 'false', 'no', 'off']]
Methods
count_dropped_list_entries()
Zählt, wie viele Listeneinträge zwischen zwei Settings-Ständen verschwunden sind — reine Zähllogik, öffentlich für den direkten Ebene-2-Test (dieselbe Begründung wie bei `sensitive_value_notice()` oben). Zählt nur VERLUSTE (ein Feld mit mehr Einträgen danach als vorher trägt 0 bei, nicht negativ).
public
static count_dropped_list_entries(array<string, mixed> $before, array<string, mixed> $after, array<int, string> $list_keys) : int
Parameters
- $before : array<string, mixed>
-
Settings vor dem Schreibvorgang.
- $after : array<string, mixed>
-
Settings nach dem Schreibvorgang.
- $list_keys : array<int, string>
-
Zu zählende Listen-Schlüssel.
Return values
intexport()
Exports all settings as JSON.
public
export(array<int, string> $args, array<string, string> $assoc_args) : void
Die Ausgabe enthält Klartext-Geheimnisse: bypass_cookies sind
name=wert-Paare, mit denen jeder Client den kompletten Schutz umgeht,
und firewall_ip_allow beschreibt, wer ihn ohne Prüfung passiert. Nur
die HMAC-Signaturschlüssel sind bewusst ausgenommen. Die Datei ist damit
so schützenswert wie ein Passwort — --file legt sie deshalb mit den
Rechten 0600 an und weist auf einen Pfad im Web-Root hin (CLI-6).
OPTIONS
[--file=
EXAMPLES
wp creacaptcha settings export --file=backup.json
Parameters
- $args : array<int, string>
-
Positional arguments.
- $assoc_args : array<string, string>
-
Associative arguments.
get()
Prints one setting value.
public
get(array<int, string> $args, array<string, string> $assoc_args) : void
OPTIONS
EXAMPLES
wp creacaptcha settings get difficulty
Parameters
- $args : array<int, string>
-
Positional arguments.
- $assoc_args : array<string, string>
-
Associative arguments.
import()
Imports settings from a JSON file.
public
import(array<int, string> $args, array<string, string> $assoc_args) : void
OPTIONS
[--yes] : Skip the confirmation prompt.
EXAMPLES
wp creacaptcha settings import backup.json
Parameters
- $args : array<int, string>
-
Positional arguments.
- $assoc_args : array<string, string>
-
Associative arguments.
list_settings()
Lists all settings as key/value pairs.
public
list_settings(array<int, string> $args, array<string, string> $assoc_args) : void
OPTIONS
[--format=
EXAMPLES
wp creacaptcha settings list
Parameters
- $args : array<int, string>
-
Positional arguments.
- $assoc_args : array<string, string>
-
Associative arguments.
Tags
load_defaults()
Resets configuration values to default but keeps the lists.
public
load_defaults(array<int, string> $args, array<string, string> $assoc_args) : void
OPTIONS
[--yes] : Skip the confirmation prompt.
EXAMPLES
wp creacaptcha settings load-defaults --yes
Parameters
- $args : array<int, string>
-
Positional arguments.
- $assoc_args : array<string, string>
-
Associative arguments.
Tags
parse_bool()
Parses a boolean-ish CLI string; NULL for anything that is neither.
public
static parse_bool(string $value) : bool|null
CLI-4: Die Whitelist war einseitig — alles außer 1/true/yes/on wurde
kommentarlos zu FALSE. settings set firewall_enabled y schaltete damit
die Firewall AB, obwohl der Aufrufer sie einschalten wollte. Ein Wort,
das in keiner der beiden Listen steht, ist keine Angabe von false,
sondern ein Tippfehler — der Aufrufer bekommt jetzt NULL und darüber
einen Fehler statt eines stillen Gegenteils.
Parameters
- $value : string
-
Raw value.
Return values
bool|null —TRUE/FALSE bei bekanntem Wort, sonst NULL.
reset()
Resets every setting to its default — including emptying all lists.
public
reset(array<int, string> $args, array<string, string> $assoc_args) : void
OPTIONS
[--yes] : Skip the confirmation prompt.
EXAMPLES
wp creacaptcha settings reset --yes
Parameters
- $args : array<int, string>
-
Positional arguments.
- $assoc_args : array<string, string>
-
Associative arguments.
sensitive_value_notice()
Warnt vor Klartext-Geheimnissen, die eine Ausgabe gleich mitliefert — dieselben zwei Felder, die `export()` schon benennt (B-M22).
public
static sensitive_value_notice(string $key, mixed $value) : string|null
Öffentlich, weil dies die Entscheidungs-Nahtstelle ist, die
tests/test-cli-output-accuracy.php direkt prüfen muss (dasselbe Muster wie
List_Command::normalise()/reject_reason()).
Parameters
- $key : string
-
Settings-Schlüssel.
- $value : mixed
-
Zugehöriger Wert.
Return values
string|nullset()
Sets one setting value.
public
set(array<int, string> $args, array<string, string> $assoc_args) : void
OPTIONS
EXAMPLES
wp creacaptcha settings set difficulty high
Parameters
- $args : array<int, string>
-
Positional arguments.
- $assoc_args : array<string, string>
-
Associative arguments.
report_reset_state()
Prints the success line of `reset`/`load-defaults` together with the one consequence that is easy to overlook: the event log is back to its default (off).
private
report_reset_state(string $headline) : void
Parameters
- $headline : string
-
Success message of the calling command.
stringify()
Converts a setting value to a printable string.
private
stringify(mixed $value) : string
Parameters
- $value : mixed
-
Raw setting value.
Return values
stringwarn_if_inside_webroot()
Warns when the export target lies inside the WordPress installation directory and would therefore likely be reachable over HTTP.
private
warn_if_inside_webroot(string $path) : void
Bewusst eine Warnung, kein Fehler: Ob ein Pfad wirklich ausgeliefert wird, hängt von der Webserver-Konfiguration ab, die hier niemand kennt. Die Prüfung behauptet nur, was sie sieht — dass der Pfad unterhalb von ABSPATH liegt.
Parameters
- $path : string
-
Target path as given on the command line.