OptionsSchema
in package

Table of Contents

$optionsSchema  : array<string|int, mixed>
$schema  : array<string|int, mixed>
addOption()  : mixed
getOptionsSchema()  : array<string|int, mixed>
getSchema()  : array<string|int, mixed>
sanitizeCallback()  : mixed|WP_Error
Custom sanitize callback used for all options to allow the use of 'null'.
setAdditionalPropertiesToFalse()  : array<string|int, mixed>
Recursively add additionalProperties = false to all objects in a schema.
prepareOptionSchema()  : array<string|int, mixed>

Properties

$optionsSchema

protected array<string|int, mixed> $optionsSchema = array()

$schema

protected array<string|int, mixed> $schema = array()

Methods

addOption()

public addOption(string $dbOptionName, string $endpointOptionName, array<string|int, mixed> $schema) : mixed
Parameters
$dbOptionName : string
$endpointOptionName : string
$schema : array<string|int, mixed>
Return values
mixed

getOptionsSchema()

public getOptionsSchema() : array<string|int, mixed>
Return values
array<string|int, mixed>

getSchema()

public getSchema() : array<string|int, mixed>
Return values
array<string|int, mixed>

sanitizeCallback()

Custom sanitize callback used for all options to allow the use of 'null'.

public sanitizeCallback(mixed $value, WP_REST_Request $request, string $param) : mixed|WP_Error

By default, the schema of settings will throw an error if a value is set to null as it's not a valid value for something like "type => string". We provide a wrapper sanitizer to allow the use of null.

Parameters
$value : mixed

The value for the setting.

$request : WP_REST_Request

The request object.

$param : string

The parameter name.

Return values
mixed|WP_Error

setAdditionalPropertiesToFalse()

Recursively add additionalProperties = false to all objects in a schema.

protected setAdditionalPropertiesToFalse(array<string|int, mixed> $schema) : array<string|int, mixed>

This is need to restrict properties of objects in settings values to only registered items, as the REST API will allow additional properties by default.

Parameters
$schema : array<string|int, mixed>

The schema array.

Return values
array<string|int, mixed>

prepareOptionSchema()

private prepareOptionSchema( $schema) : array<string|int, mixed>
Parameters
$schema :
Return values
array<string|int, mixed>

Search results