[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/abilities/ -> class-wp-abilities-settings.php (summary)

Abilities API: WP_Abilities_Settings class.

File Size: 340 lines (12 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 0 files

Defines 9 functions

  register()
  register_settings_get()
  execute_settings_get()
  check_permission()
  get_settings_get_input_schema()
  get_settings_get_output_schema()
  get_exposed_settings()
  get_exposure_args()
  value_schema()

Functions
Functions that are not part of a class:

register()   X-Ref
Registers all settings abilities.

Must run on the `wp_abilities_api_init` hook. Registers nothing when no setting is
exposed to abilities.


register_settings_get()   X-Ref
Registers the read-only `core/settings-get` ability.


execute_settings_get( $input = array()   X-Ref
Executes the `core/settings-get` ability.

param: mixed $input Optional. The ability input. Default empty array.
return: array<string, mixed> Map of exposed setting name to current value.

check_permission()   X-Ref
Permission callback for the settings abilities.

The settings abilities read site options, so they are gated on the `manage_options`
capability regardless of the input.

return: bool True if the current user can manage options.

get_settings_get_input_schema( array $groups, array $field_names )   X-Ref
Builds the input schema for the `core/settings-get` ability: optional filters by group and/or name.

Both `group` and `fields` are optional; supplying both narrows the response to their
intersection, and supplying neither returns every exposed setting.

param: list<string> $groups      Available settings groups.
param: list<string> $field_names Available exposed setting names.
return: array<string, mixed> The input JSON Schema.

get_settings_get_output_schema()   X-Ref
Builds the output schema for the `core/settings-get` ability.

No setting is marked required because the `group` and `fields` inputs let the caller
request any subset, and a setting whose value does not match its schema is left out.

return: array<string, mixed> The output JSON Schema.

get_exposed_settings()   X-Ref
Returns the settings exposed through the Abilities API.

Reads {@see get_registered_settings()} and keeps only settings flagged with a truthy
`show_in_abilities` argument, of a type the settings endpoint supports. Each entry is
keyed by its exposed name and carries the underlying option name, the settings group,
the registered default (null when there is none), and a JSON Schema describing the value.

Two settings exposed under the same name trigger a notice, and the later one is exposed.

return: array<string, array{option: string, group: string, default: mixed, schema: array<string, mixed>}> Settings keyed by exposed name.

get_exposure_args( array $args )   X-Ref
Returns the name and schema overrides used to expose a setting to abilities.

When `show_in_abilities` is `true`, the setting is exposed the same way as in the
REST API: it uses the `name` and `schema` from `show_in_rest`. An array is used
as is.

param: array<string, mixed> $args The setting registration arguments.
return: array<string, mixed> The exposure arguments, with optional `name` and `schema` keys.

value_schema( array $args, $show )   X-Ref
Builds the JSON Schema describing a single setting's value.

As in the settings endpoint, objects in the schema reject properties they do not declare,
unless the schema allows them.

param: array<string, mixed> $args The setting registration arguments.
param: array<string, mixed> $show The exposure arguments, see get_exposure_args().
return: array<string, mixed> The value JSON Schema.



Generated : Tue Oct 13 08:20:33 2026 Cross-referenced by PHPXref