Opened 6 years ago
Closed 5 years ago
#47023 closed enhancement (invalid)
Allow settings option schema to be modified
Reported by: | pcfreak30 | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.7 |
Component: | REST API | Keywords: | |
Focuses: | Cc: |
Description
In WP_REST_Settings_Controller,
get_registered_options
and
get_item_schema
Seem to pull/manipulate data from
get_registered_settings
, but don't have filters and/or register_setting does not allow a schema for the option value.
The use case is storing an associative array/hash of settings data in one option, to keep the options table tidy.
I think the best route possibly may be for
register_settings
to allow a schema in the
$argsand that get used in the controller for validation. Another way maybe just a filter to inject the needed schema on the fly, but that's less than ideal for the use case of verifying children items inside an options data.
Change History (1)
Note: See
TracTickets for help on using
tickets.
Hi @pcfreak30!
Setting a custom schema is supported under the
show_in_rest
argument.register_setting('name', 'group', [ 'show_in_rest' => [ 'schema' => [ 'type' => 'object', 'properties' => [ 'propA' => [ 'type' => 'string', ] ] ] ] ]);