WP_REST_View_Config_Controller::get_view_base_schema(): array

In this article

Returns the schema properties shared by all view types (ViewBase), excluding ‘type’.

Description

Note that search and page are not part of the schema: they are managed via the URL, which is their only source of truth.

Return

array Schema properties for the base view configuration.

Source

protected function get_view_base_schema() {
	return array(
		'filters'               => array(
			'type'  => 'array',
			'items' => array(
				'type'       => 'object',
				'properties' => array(
					'field'    => array(
						'type' => 'string',
					),
					'operator' => array(
						'type' => 'string',
						'enum' => array(
							'is',
							'isNot',
							'isAny',
							'isNone',
							'isAll',
							'isNotAll',
							'lessThan',
							'greaterThan',
							'lessThanOrEqual',
							'greaterThanOrEqual',
							'before',
							'after',
						),
					),
					'value'    => array(),
					'isLocked' => array(
						'type' => 'boolean',
					),
				),
			),
		),
		'sort'                  => array(
			'type'       => 'object',
			'properties' => array(
				'field'     => array(
					'type' => 'string',
				),
				'direction' => array(
					'type' => 'string',
					'enum' => array( 'asc', 'desc' ),
				),
			),
		),
		'perPage'               => array(
			'type' => 'integer',
		),
		'fields'                => array(
			'type'  => 'array',
			'items' => array(
				'type' => 'string',
			),
		),
		'titleField'            => array(
			'type' => 'string',
		),
		'mediaField'            => array(
			'type' => 'string',
		),
		'descriptionField'      => array(
			'type' => 'string',
		),
		'showTitle'             => array(
			'type' => 'boolean',
		),
		'showMedia'             => array(
			'type' => 'boolean',
		),
		'showDescription'       => array(
			'type' => 'boolean',
		),
		'showLevels'            => array(
			'type' => 'boolean',
		),
		'groupBy'               => array(
			'type'       => 'object',
			'properties' => array(
				'field'     => array(
					'type' => 'string',
				),
				'direction' => array(
					'type' => 'string',
					'enum' => array( 'asc', 'desc' ),
				),
				'showLabel' => array(
					'type'    => 'boolean',
					'default' => true,
				),
			),
		),
		'infiniteScrollEnabled' => array(
			'type' => 'boolean',
		),
	);
}

Changelog

VersionDescription
7.1.0Introduced.

User Contributed Notes

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