WP_REST_Global_Styles_Revisions_Controller::get_item_schema(): array

In this article

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

	$schema = array(
		'$schema'    => 'http://json-schema.org/draft-04/schema#',
		'title'      => "{$this->parent_post_type}-revision",
		'type'       => 'object',
		// Base properties for every revision.
		'properties' => array(

			/*
			 * Adds settings and styles from the WP_REST_Revisions_Controller item fields.
			 * Leaves out GUID as global styles shouldn't be accessible via URL.
			 */
			'author'       => array(
				'description' => __( 'The ID for the author of the revision.' ),
				'type'        => 'integer',
				'context'     => array( 'view', 'edit', 'embed' ),
			),
			'date'         => array(
				'description' => __( "The date the revision was published, in the site's timezone." ),
				'type'        => 'string',
				'format'      => 'date-time',
				'context'     => array( 'view', 'edit', 'embed' ),
			),
			'date_gmt'     => array(
				'description' => __( 'The date the revision was published, as GMT.' ),
				'type'        => 'string',
				'format'      => 'date-time',
				'context'     => array( 'view', 'edit' ),
			),
			'id'           => array(
				'description' => __( 'Unique identifier for the revision.' ),
				'type'        => 'integer',
				'context'     => array( 'view', 'edit', 'embed' ),
			),
			'modified'     => array(
				'description' => __( "The date the revision was last modified, in the site's timezone." ),
				'type'        => 'string',
				'format'      => 'date-time',
				'context'     => array( 'view', 'edit' ),
			),
			'modified_gmt' => array(
				'description' => __( 'The date the revision was last modified, as GMT.' ),
				'type'        => 'string',
				'format'      => 'date-time',
				'context'     => array( 'view', 'edit' ),
			),
			'parent'       => array(
				'description' => __( 'The ID for the parent of the revision.' ),
				'type'        => 'integer',
				'context'     => array( 'view', 'edit', 'embed' ),
			),

			// Adds settings and styles from the WP_REST_Global_Styles_Controller parent schema.
			'styles'       => array(
				'description' => __( 'Global styles.' ),
				'type'        => array( 'object' ),
				'context'     => array( 'view', 'edit' ),
			),
			'settings'     => array(
				'description' => __( 'Global settings.' ),
				'type'        => array( 'object' ),
				'context'     => array( 'view', 'edit' ),
			),
		),
	);

	$this->schema = $schema;

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

Changelog

VersionDescription
6.3.0Introduced.

User Contributed Notes

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