wp_prepare_json_schema_for_client() │ WP 7.1.0

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.

Хуков нет.

Возвращает

array<string, mixed>. The prepared schema.

Использование

wp_prepare_json_schema_for_client( $schema, $schema_profile ): array;
$schema(array<string, mixed>) (обязательный)
The schema array.
$schema_profile(строка)
Name of the schema profile whose keywords should be preserved.
По умолчанию: 'draft-04'

Список изменений

С версии 7.1.0 Введена.

Код wp_prepare_json_schema_for_client() WP 7.1.4

function wp_prepare_json_schema_for_client( array $schema, string $schema_profile = 'draft-04' ): array {
	$allowed_keywords = array_fill_keys( wp_get_json_schema_allowed_keywords( $schema_profile ), true );

	return _wp_prepare_json_schema_for_client_with_allowed_keywords( $schema, $allowed_keywords );
}