WP_REST_View_Config_Controller::get_item_schema(): array

In this article

Retrieves the item’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 );
	}

	$view_base_properties = $this->get_view_base_schema();

	$this->schema = array(
		'$schema'    => 'http://json-schema.org/draft-04/schema#',
		'title'      => 'view-config',
		'type'       => 'object',
		'properties' => array(
			'kind'            => array(
				'description' => __( 'Entity kind.' ),
				'type'        => 'string',
				'readonly'    => true,
			),
			'name'            => array(
				'description' => __( 'Entity name.' ),
				'type'        => 'string',
				'readonly'    => true,
			),
			'version'         => array(
				'description' => __( 'The schema version of the configuration.' ),
				'type'        => 'integer',
				'readonly'    => true,
			),
			'default_view'    => array(
				'description' => __( 'Default view configuration.' ),
				'type'        => 'object',
				'readonly'    => true,
				'properties'  => array_merge(
					array(
						'type'   => array(
							'type' => 'string',
						),
						'layout' => $this->get_combined_layout_schema(),
					),
					$view_base_properties
				),
			),
			'default_layouts' => array(
				'description' => __( 'Default layout configurations.' ),
				'type'        => 'object',
				'readonly'    => true,
				'properties'  => array(
					'table'       => array(
						'type'       => 'object',
						'properties' => array_merge(
							$view_base_properties,
							array(
								'layout' => $this->get_table_layout_schema(),
							)
						),
					),
					'list'        => array(
						'type'       => 'object',
						'properties' => array_merge(
							$view_base_properties,
							array(
								'layout' => $this->get_list_layout_schema(),
							)
						),
					),
					'grid'        => array(
						'type'       => 'object',
						'properties' => array_merge(
							$view_base_properties,
							array(
								'layout' => $this->get_grid_layout_schema(),
							)
						),
					),
					'activity'    => array(
						'type'       => 'object',
						'properties' => array_merge(
							$view_base_properties,
							array(
								'layout' => $this->get_list_layout_schema(),
							)
						),
					),
					'pickerGrid'  => array(
						'type'       => 'object',
						'properties' => array_merge(
							$view_base_properties,
							array(
								'layout' => $this->get_grid_layout_schema(),
							)
						),
					),
					'pickerTable' => array(
						'type'       => 'object',
						'properties' => array_merge(
							$view_base_properties,
							array(
								'layout' => $this->get_table_layout_schema(),
							)
						),
					),
				),
			),
			'view_list'       => array(
				'description' => __( 'List of default views.' ),
				'type'        => 'array',
				'readonly'    => true,
				'items'       => array(
					'type'       => 'object',
					'properties' => array(
						'title' => array(
							'type' => 'string',
						),
						'slug'  => array(
							'type' => 'string',
						),
						'view'  => array(
							'type'       => 'object',
							'properties' => array_merge(
								array(
									'type'   => array(
										'type' => 'string',
									),
									'layout' => $this->get_combined_layout_schema(),
								),
								$view_base_properties
							),
						),
					),
				),
			),
			'form'            => array(
				'description' => __( 'Default form configuration.' ),
				'type'        => 'object',
				'readonly'    => true,
				'properties'  => $this->get_form_schema(),
			),
		),
	);

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

Changelog

VersionDescription
7.1.0Introduced.

User Contributed Notes

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