WP_REST_Widget_Types_Controller::get_item_schema()publicWP 5.8.0

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

Метод класса: WP_REST_Widget_Types_Controller{}

Хуков нет.

Возвращает

Массив. Item schema data.

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

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

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

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

Код WP_REST_Widget_Types_Controller::get_item_schema() WP 6.6.2

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