WP_REST_Sidebars_Controller::get_item_schema()publicWP 5.8.0

Retrieves the block type' schema, conforming to JSON Schema.

Метод класса: WP_REST_Sidebars_Controller{}

Хуков нет.

Возвращает

Массив. Item schema data.

Использование

$WP_REST_Sidebars_Controller = new WP_REST_Sidebars_Controller();
$WP_REST_Sidebars_Controller->get_item_schema();

Список изменений

С версии 5.8.0 Введена.

Код WP_REST_Sidebars_Controller::get_item_schema() WP 6.6.2

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 );
}