WP_REST_Block_Directory_Controller::get_item_schema()publicWP 5.5.0

Retrieves the theme's schema, conforming to JSON Schema.

Method of the class: WP_REST_Block_Directory_Controller{}

No Hooks.

Return

Array. Item schema data.

Usage

$WP_REST_Block_Directory_Controller = new WP_REST_Block_Directory_Controller();
$WP_REST_Block_Directory_Controller->get_item_schema();

Changelog

Since 5.5.0 Introduced.

WP_REST_Block_Directory_Controller::get_item_schema() code WP 6.5.2

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

	$this->schema = array(
		'$schema'    => 'http://json-schema.org/draft-04/schema#',
		'title'      => 'block-directory-item',
		'type'       => 'object',
		'properties' => array(
			'name'                => array(
				'description' => __( 'The block name, in namespace/block-name format.' ),
				'type'        => 'string',
				'context'     => array( 'view' ),
			),
			'title'               => array(
				'description' => __( 'The block title, in human readable format.' ),
				'type'        => 'string',
				'context'     => array( 'view' ),
			),
			'description'         => array(
				'description' => __( 'A short description of the block, in human readable format.' ),
				'type'        => 'string',
				'context'     => array( 'view' ),
			),
			'id'                  => array(
				'description' => __( 'The block slug.' ),
				'type'        => 'string',
				'context'     => array( 'view' ),
			),
			'rating'              => array(
				'description' => __( 'The star rating of the block.' ),
				'type'        => 'number',
				'context'     => array( 'view' ),
			),
			'rating_count'        => array(
				'description' => __( 'The number of ratings.' ),
				'type'        => 'integer',
				'context'     => array( 'view' ),
			),
			'active_installs'     => array(
				'description' => __( 'The number sites that have activated this block.' ),
				'type'        => 'integer',
				'context'     => array( 'view' ),
			),
			'author_block_rating' => array(
				'description' => __( 'The average rating of blocks published by the same author.' ),
				'type'        => 'number',
				'context'     => array( 'view' ),
			),
			'author_block_count'  => array(
				'description' => __( 'The number of blocks published by the same author.' ),
				'type'        => 'integer',
				'context'     => array( 'view' ),
			),
			'author'              => array(
				'description' => __( 'The WordPress.org username of the block author.' ),
				'type'        => 'string',
				'context'     => array( 'view' ),
			),
			'icon'                => array(
				'description' => __( 'The block icon.' ),
				'type'        => 'string',
				'format'      => 'uri',
				'context'     => array( 'view' ),
			),
			'last_updated'        => array(
				'description' => __( 'The date when the block was last updated.' ),
				'type'        => 'string',
				'format'      => 'date-time',
				'context'     => array( 'view' ),
			),
			'humanized_updated'   => array(
				'description' => __( 'The date when the block was last updated, in fuzzy human readable format.' ),
				'type'        => 'string',
				'context'     => array( 'view' ),
			),
		),
	);

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