WP_REST_Themes_Controller::get_item_schema()

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


Return Return

(array) Item schema data.


Top ↑

Source Source

File: wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php

	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'      => 'theme',
			'type'       => 'object',
			'properties' => array(
				'theme_supports' => array(
					'description' => __( 'Features supported by this theme.' ),
					'type'        => 'object',
					'readonly'    => true,
					'properties'  => array(
						'align-wide'                => array(
							'description' => __( 'Whether theme opts in to wide alignment CSS class.' ),
							'type'        => 'boolean',
						),
						'automatic-feed-links'      => array(
							'description' => __( 'Whether posts and comments RSS feed links are added to head.' ),
							'type'        => 'boolean',
						),
						'custom-header'             => array(
							'description'          => __( 'Custom header if defined by the theme.' ),
							'type'                 => array( 'boolean', 'object' ),
							'properties'           => array(
								'default-image'      => array(
									'type'   => 'string',
									'format' => 'uri',
								),
								'random-default'     => array(
									'type' => 'boolean',
								),
								'width'              => array(
									'type' => 'integer',
								),
								'height'             => array(
									'type' => 'integer',
								),
								'flex-height'        => array(
									'type' => 'boolean',
								),
								'flex-width'         => array(
									'type' => 'boolean',
								),
								'default-text-color' => array(
									'type' => 'string',
								),
								'header-text'        => array(
									'type' => 'boolean',
								),
								'uploads'            => array(
									'type' => 'boolean',
								),
								'video'              => array(
									'type' => 'boolean',
								),
							),
							'additionalProperties' => false,
						),
						'custom-background'         => array(
							'description'          => __( 'Custom background if defined by the theme.' ),
							'type'                 => array( 'boolean', 'object' ),
							'properties'           => array(
								'default-image'      => array(
									'type'   => 'string',
									'format' => 'uri',
								),
								'default-preset'     => array(
									'type' => 'string',
									'enum' => array(
										'default',
										'fill',
										'fit',
										'repeat',
										'custom',
									),
								),
								'default-position-x' => array(
									'type' => 'string',
									'enum' => array(
										'left',
										'center',
										'right',
									),
								),
								'default-position-y' => array(
									'type' => 'string',
									'enum' => array(
										'left',
										'center',
										'right',
									),
								),
								'default-size'       => array(
									'type' => 'string',
									'enum' => array(
										'auto',
										'contain',
										'cover',
									),
								),
								'default-repeat'     => array(
									'type' => 'string',
									'enum' => array(
										'repeat-x',
										'repeat-y',
										'repeat',
										'no-repeat',
									),
								),
								'default-attachment' => array(
									'type' => 'string',
									'enum' => array(
										'scroll',
										'fixed',
									),
								),
								'default-color'      => array(
									'type' => 'string',
								),
							),
							'additionalProperties' => false,
						),
						'custom-logo'               => array(
							'description'          => __( 'Custom logo if defined by the theme.' ),
							'type'                 => array( 'boolean', 'object' ),
							'properties'           => array(
								'width'       => array(
									'type' => 'integer',
								),
								'height'      => array(
									'type' => 'integer',
								),
								'flex-width'  => array(
									'type' => 'boolean',
								),
								'flex-height' => array(
									'type' => 'boolean',
								),
								'header-text' => array(
									'type'  => 'array',
									'items' => array(
										'type' => 'string',
									),
								),
							),
							'additionalProperties' => false,
						),
						'customize-selective-refresh-widgets' => array(
							'description' => __( 'Whether the theme enables Selective Refresh for Widgets being managed with the Customizer.' ),
							'type'        => 'boolean',
						),
						'dark-editor-style'         => array(
							'description' => __( 'Whether theme opts in to the dark editor style UI.' ),
							'type'        => 'boolean',
						),
						'disable-custom-colors'     => array(
							'description' => __( 'Whether the theme disables custom colors.' ),
							'type'        => 'boolean',
						),
						'disable-custom-font-sizes' => array(
							'description' => __( 'Whether the theme disables custom font sizes.' ),
							'type'        => 'boolean',
						),
						'disable-custom-gradients'  => array(
							'description' => __( 'Whether the theme disables custom gradients.' ),
							'type'        => 'boolean',
						),
						'editor-color-palette'      => array(
							'description' => __( 'Custom color palette if defined by the theme.' ),
							'type'        => array( 'boolean', 'array' ),
							'items'       => array(
								'type'                 => 'object',
								'properties'           => array(
									'name'  => array(
										'type' => 'string',
									),
									'slug'  => array(
										'type' => 'string',
									),
									'color' => array(
										'type' => 'string',
									),
								),
								'additionalProperties' => false,
							),
						),
						'editor-font-sizes'         => array(
							'description' => __( 'Custom font sizes if defined by the theme.' ),
							'type'        => array( 'boolean', 'array' ),
							'items'       => array(
								'type'                 => 'object',
								'properties'           => array(
									'name' => array(
										'type' => 'string',
									),
									'size' => array(
										'type' => 'number',
									),
									'slug' => array(
										'type' => 'string',
									),
								),
								'additionalProperties' => false,
							),
						),
						'editor-gradient-presets'   => array(
							'description' => __( 'Custom gradient presets if defined by the theme.' ),
							'type'        => array( 'boolean', 'array' ),
							'items'       => array(
								'type'                 => 'object',
								'properties'           => array(
									'name'     => array(
										'type' => 'string',
									),
									'gradient' => array(
										'type' => 'string',
									),
									'slug'     => array(
										'type' => 'string',
									),
								),
								'additionalProperties' => false,
							),
						),
						'editor-styles'             => array(
							'description' => __( 'Whether theme opts in to the editor styles CSS wrapper.' ),
							'type'        => 'boolean',
						),
						'formats'                   => array(
							'description' => __( 'Post formats supported.' ),
							'type'        => 'array',
							'items'       => array(
								'type' => 'string',
								'enum' => get_post_format_slugs(),
							),
						),
						'html5'                     => array(
							'description' => __( 'Allows use of html5 markup for search forms, comment forms, comment lists, gallery, and caption.' ),
							'type'        => array( 'boolean', 'array' ),
							'items'       => array(
								'type' => 'string',
								'enum' => array(
									'search-form',
									'comment-form',
									'comment-list',
									'gallery',
									'caption',
									'script',
									'style',
								),
							),
						),
						'post-thumbnails'           => array(
							'description' => __( 'Whether the theme supports post thumbnails.' ),
							'type'        => array( 'boolean', 'array' ),
							'items'       => array(
								'type' => 'string',
							),
						),
						'responsive-embeds'         => array(
							'description' => __( 'Whether the theme supports responsive embedded content.' ),
							'type'        => 'boolean',
						),
						'title-tag'                 => array(
							'description' => __( 'Whether the theme can manage the document title tag.' ),
							'type'        => 'boolean',
						),
						'wp-block-styles'           => array(
							'description' => __( 'Whether theme opts in to default WordPress block styles for viewing.' ),
							'type'        => 'boolean',
						),
					),
				),
			),
		);

		$this->schema = $schema;

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


Top ↑

Changelog Changelog

Changelog
Version Description
5.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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