WP_REST_Widget_Types_Controller::get_item_schema(): array

In this article

Retrieves the widget type’s schema, conforming to JSON Schema.

Return

array Item schema data.

Source

public function get_item_schema() {
	if ( $this->schema ) {
		return $this->add_additional_fields_schema( $this->schema );
	}

	$schema = array(
		'$schema'    => 'http://json-schema.org/draft-04/schema#',
		'title'      => 'widget-type',
		'type'       => 'object',
		'properties' => array(
			'id'          => array(
				'description' => __( 'Unique slug identifying the widget type.' ),
				'type'        => 'string',
				'context'     => array( 'embed', 'view', 'edit' ),
				'readonly'    => true,
			),
			'name'        => array(
				'description' => __( 'Human-readable name identifying the widget type.' ),
				'type'        => 'string',
				'default'     => '',
				'context'     => array( 'embed', 'view', 'edit' ),
				'readonly'    => true,
			),
			'description' => array(
				'description' => __( 'Description of the widget.' ),
				'type'        => 'string',
				'default'     => '',
				'context'     => array( 'view', 'edit', 'embed' ),
			),
			'is_multi'    => array(
				'description' => __( 'Whether the widget supports multiple instances' ),
				'type'        => 'boolean',
				'context'     => array( 'view', 'edit', 'embed' ),
				'readonly'    => true,
			),
			'classname'   => array(
				'description' => __( 'Class name' ),
				'type'        => 'string',
				'default'     => '',
				'context'     => array( 'embed', 'view', 'edit' ),
				'readonly'    => true,
			),
		),
	);

	$this->schema = $schema;

	return $this->add_additional_fields_schema( $this->schema );
}

Changelog

VersionDescription
5.8.0Introduced.

User Contributed Notes

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