Skip to content
Corex

SettingsSanitizer

Corex\Config\Settings\SettingsSanitizer · class · Config layer

The pure per-type sanitization + validation for a settings write (spec 068 T197/T198). It never persists — it returns a clean value to store, or null when the input is invalid and must be rejected (so a bad email, URL, or unknown select option is never saved). Write-only secrets that arrive empty are reported so the caller can preserve the stored value rather than clearing it. The only WordPress calls are the core sanitizers, so it stays unit-testable.

sanitize(string $raw, string $type, array $options): ?string

Section titled “sanitize(string $raw, string $type, array $options): ?string”

shouldPreserve(string $value, string $type): bool

Section titled “shouldPreserve(string $value, string $type): bool”

Whether a sanitized value for the given field type must be skipped rather than saved — an empty write-only secret is preserved (the stored key is never cleared by re-saving the form).