[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/ -> json-schema.php (summary)

JSON Schema API: shared functions for working with JSON Schema.

File Size: 203 lines (8 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 3 functions

  wp_get_json_schema_allowed_keywords()
  wp_prepare_json_schema_for_client()
  _wp_prepare_json_schema_for_client_with_allowed_keywords()

Functions
Functions that are not part of a class:

wp_get_json_schema_allowed_keywords( string $schema_profile = 'rest-api' )   X-Ref
Gets the JSON Schema keywords allowed for a given schema profile.

Use this when preparing a schema that will be consumed outside of
WordPress's server-side validation, such as by REST clients, frontend code,
or AI providers.

The 'rest-api' profile returns the subset of JSON Schema draft-04 keywords
that the REST API has historically exposed. The 'draft-04' profile preserves
the larger draft-04 vocabulary used by clients that can consume standalone
schemas.

Allowing a keyword to be exposed does not make WordPress validate or
sanitize values against it.

param: string $schema_profile Optional. Name of the schema profile to get keywords for.
return: string[] Allowed JSON Schema keywords.

wp_prepare_json_schema_for_client( array $schema, string $schema_profile = 'draft-04' )   X-Ref
Prepares a JSON Schema for clients.

Use this before exposing a schema outside of WordPress's server-side
validation, for example in REST responses, Ability metadata, or AI provider
requests. The prepared schema uses forms that JSON Schema draft-04 clients
can understand.

WordPress-internal schema conveniences are converted or removed only where
needed to keep the exposed schema valid for the selected profile.

param: array<string, mixed> $schema         The schema array.
param: string               $schema_profile Optional. Name of the schema profile
return: array<string, mixed> The prepared schema.

_wp_prepare_json_schema_for_client_with_allowed_keywords( array $schema, array $allowed_keywords )   X-Ref
Prepares a JSON Schema for clients using a given keyword lookup.

param: array<string, mixed> $schema           The schema array.
param: array<string, true>  $allowed_keywords Lookup map of allowed JSON Schema keywords.
return: array<string, mixed> The prepared schema.



Generated : Tue Jul 14 08:20:16 2026 Cross-referenced by PHPXref