WP_REST_Abilities_V1_List_Controller::strip_internal_schema_keywords( $schema ): array<string,

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only by core. It is listed here for completeness.

Recursively removes WordPress-internal keywords from a schema.

Description

Ability schemas may include WordPress-internal properties like sanitize_callback, validate_callback, and arg_options that are used server-side but are not valid JSON Schema keywords. This method removes those specific keys so they are not exposed in REST responses.

Parameters

mixed> $schema The schema array.

Return

array<string, mixed> The schema without WordPress-internal keywords.

Source

/**
 * Retrieves the ability's schema, conforming to JSON Schema.
 *
 * @since 6.9.0
 *
 * @return array<string, mixed> Item schema data.
 */
public function get_item_schema(): array {
	$schema = array(
		'$schema'    => 'http://json-schema.org/draft-04/schema#',
		'title'      => 'ability',
		'type'       => 'object',
		'properties' => array(
			'name'          => array(
				'description' => __( 'Unique identifier for the ability.' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit', 'embed' ),
				'readonly'    => true,
			),
			'label'         => array(
				'description' => __( 'Display label for the ability.' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit', 'embed' ),
				'readonly'    => true,
			),
			'description'   => array(
				'description' => __( 'Description of the ability.' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'category'      => array(
				'description' => __( 'Ability category this ability belongs to.' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit', 'embed' ),
				'readonly'    => true,
			),
			'input_schema'  => array(
				'description' => __( 'JSON Schema for the ability input.' ),
				'type'        => 'object',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'output_schema' => array(
				'description' => __( 'JSON Schema for the ability output.' ),
				'type'        => 'object',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),

Changelog

VersionDescription
7.0.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.