WC_REST_Setting_Options_V2_Controller::get_item_schema()publicWC 3.0.0

Get the settings schema, conforming to JSON Schema.

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

Хуков нет.

Возвращает

Массив.

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

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

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

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

Код WC_REST_Setting_Options_V2_Controller::get_item_schema() WC 9.3.3

public function get_item_schema() {
	$schema = array(
		'$schema'    => 'http://json-schema.org/draft-04/schema#',
		'title'      => 'setting',
		'type'       => 'object',
		'properties' => array(
			'id'          => array(
				'description' => __( 'A unique identifier for the setting.', 'woocommerce' ),
				'type'        => 'string',
				'arg_options' => array(
					'sanitize_callback' => 'sanitize_title',
				),
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'label'       => array(
				'description' => __( 'A human readable label for the setting used in interfaces.', 'woocommerce' ),
				'type'        => 'string',
				'arg_options' => array(
					'sanitize_callback' => 'sanitize_text_field',
				),
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'description' => array(
				'description' => __( 'A human readable description for the setting used in interfaces.', 'woocommerce' ),
				'type'        => 'string',
				'arg_options' => array(
					'sanitize_callback' => 'sanitize_text_field',
				),
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'value'       => array(
				'description' => __( 'Setting value.', 'woocommerce' ),
				'type'        => 'mixed',
				'context'     => array( 'view', 'edit' ),
			),
			'default'     => array(
				'description' => __( 'Default value for the setting.', 'woocommerce' ),
				'type'        => 'mixed',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'tip'         => array(
				'description' => __( 'Additional help text shown to the user about the setting.', 'woocommerce' ),
				'type'        => 'string',
				'arg_options' => array(
					'sanitize_callback' => 'sanitize_text_field',
				),
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'placeholder' => array(
				'description' => __( 'Placeholder text to be displayed in text inputs.', 'woocommerce' ),
				'type'        => 'string',
				'arg_options' => array(
					'sanitize_callback' => 'sanitize_text_field',
				),
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'type'        => array(
				'description' => __( 'Type of setting.', 'woocommerce' ),
				'type'        => 'string',
				'arg_options' => array(
					'sanitize_callback' => 'sanitize_text_field',
				),
				'context'     => array( 'view', 'edit' ),
				'enum'        => array( 'text', 'email', 'number', 'color', 'password', 'textarea', 'select', 'multiselect', 'radio', 'image_width', 'checkbox', 'thumbnail_cropping' ),
				'readonly'    => true,
			),
			'options'     => array(
				'description' => __( 'Array of options (key value pairs) for inputs such as select, multiselect, and radio buttons.', 'woocommerce' ),
				'type'        => 'object',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
		),
	);

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