WP_REST_Sidebars_Controller::get_item_schema(): array

In this article

Retrieves the block type’ 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'      => 'sidebar',
		'type'       => 'object',
		'properties' => array(
			'id'            => array(
				'description' => __( 'ID of sidebar.' ),
				'type'        => 'string',
				'context'     => array( 'embed', 'view', 'edit' ),
				'readonly'    => true,
			),
			'name'          => array(
				'description' => __( 'Unique name identifying the sidebar.' ),
				'type'        => 'string',
				'context'     => array( 'embed', 'view', 'edit' ),
				'readonly'    => true,
			),
			'description'   => array(
				'description' => __( 'Description of sidebar.' ),
				'type'        => 'string',
				'context'     => array( 'embed', 'view', 'edit' ),
				'readonly'    => true,
			),
			'class'         => array(
				'description' => __( 'Extra CSS class to assign to the sidebar in the Widgets interface.' ),
				'type'        => 'string',
				'context'     => array( 'embed', 'view', 'edit' ),
				'readonly'    => true,
			),
			'before_widget' => array(
				'description' => __( 'HTML content to prepend to each widget\'s HTML output when assigned to this sidebar. Default is an opening list item element.' ),
				'type'        => 'string',
				'default'     => '',
				'context'     => array( 'embed', 'view', 'edit' ),
				'readonly'    => true,
			),
			'after_widget'  => array(
				'description' => __( 'HTML content to append to each widget\'s HTML output when assigned to this sidebar. Default is a closing list item element.' ),
				'type'        => 'string',
				'default'     => '',
				'context'     => array( 'embed', 'view', 'edit' ),
				'readonly'    => true,
			),
			'before_title'  => array(
				'description' => __( 'HTML content to prepend to the sidebar title when displayed. Default is an opening h2 element.' ),
				'type'        => 'string',
				'default'     => '',
				'context'     => array( 'embed', 'view', 'edit' ),
				'readonly'    => true,
			),
			'after_title'   => array(
				'description' => __( 'HTML content to append to the sidebar title when displayed. Default is a closing h2 element.' ),
				'type'        => 'string',
				'default'     => '',
				'context'     => array( 'embed', 'view', 'edit' ),
				'readonly'    => true,
			),
			'status'        => array(
				'description' => __( 'Status of sidebar.' ),
				'type'        => 'string',
				'enum'        => array( 'active', 'inactive' ),
				'context'     => array( 'embed', 'view', 'edit' ),
				'readonly'    => true,
			),
			'widgets'       => array(
				'description' => __( 'Nested widgets.' ),
				'type'        => 'array',
				'items'       => array(
					'type' => array( 'object', 'string' ),
				),
				'default'     => array(),
				'context'     => array( 'embed', 'view', 'edit' ),
			),
		),
	);

	$this->schema = $schema;

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

Changelog

VersionDescription
5.8.0Introduced.

User Contributed Notes

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