Field
in package
Read onlyYes
FinalYes
Declarative description of one admin settings field: the persisted option name, the control to render and how to sanitize it on save.
options feeds Select/CheckboxList choices (value => label); attributes
become extra HTML attributes on the control (placeholder, min, ...);
html is the literal markup for FieldType::RawHtml.
Table of Contents
Properties
- $attributes : array<string|int, mixed>
- $default : mixed
- $description : string
- $html : string
- $name : string
- $options : array<string|int, mixed>
- $sanitizer : mixed
- $title : string
- $type : FieldType
Methods
- __construct() : mixed
- resolveSanitizer() : callable
- The save-time sanitizer: the field's own, or its type default.
Properties
$attributes
public
array<string|int, mixed>
$attributes
= []
$default
public
mixed
$default
= ''
$description
public
string
$description
= ''
$html
public
string
$html
= ''
$name
public
string
$name
$options
public
array<string|int, mixed>
$options
= []
$sanitizer
public
mixed
$sanitizer
= null
$title
public
string
$title
$type
public
FieldType
$type
= FieldType::Text
Methods
__construct()
public
__construct(non-empty-string $name, string $title[, FieldType $type = FieldType::Text ][, mixed $default = '' ][, array<string, string> $options = [] ][, string $description = '' ][, array<string, string> $attributes = [] ][, null|callable $sanitizer = null ][, string $html = '' ]) : mixed
Parameters
- $name : non-empty-string
-
option name persisted in wp_options
- $title : string
- $type : FieldType = FieldType::Text
- $default : mixed = ''
- $options : array<string, string> = []
-
choices for Select/CheckboxList
- $description : string = ''
- $attributes : array<string, string> = []
-
extra HTML attributes for the control
- $sanitizer : null|callable = null
-
save-time sanitizer; null = the type default
- $html : string = ''
resolveSanitizer()
The save-time sanitizer: the field's own, or its type default.
public
resolveSanitizer() : callable