Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#47023 closed enhancement (invalid)

Allow settings option schema to be modified

Reported by: pcfreak30's profile pcfreak30 Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.7
Component: REST API Keywords:
Focuses: Cc:


In WP_REST_Settings_Controller,




Seem to pull/manipulate data from


, 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


to allow a schema in the


and 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)

#1 @TimothyBlynJacobs
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed
  • Version changed from 5.2 to 4.7

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',
Note: See TracTickets for help on using tickets.