wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



wp_prepare_json_schema_for_client › WordPress Function

Od7.1.0
Przestarzałyn/a
› wp_prepare_json_schema_for_client ( $schema, $schema_profile = 'draft-04' )
Parametry: (2)
  • (array<string,mixed>) $schema The schema array.
    Wymagane: Tak
  • (string) $schema_profile Optional. Name of the schema profile whose keywords should be preserved. Default 'draft-04'.
    Wymagane: Nie
    Domyślny: 'draft-04'
Powrót:
  • (array<string,mixed>) The prepared schema.
Zdefiniowane na:
Codex:

Prepares a JSON Schema for clients.

Converts WordPress-specific schema conventions and removes unsupported keywords so clients can interpret the schema using the selected profile. Applies the same preparation to nested schemas. Existing default values are normalized according to their schemas so empty objects encode as } rather than [], including within nested default values.


Źródło

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 );
}