WC_REST_Product_Attributes_V1_Controller::get_item_schema()publicWC 1.0

Get the Attribute's schema, conforming to JSON Schema.

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

Хуков нет.

Возвращает

Массив.

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

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

Код WC_REST_Product_Attributes_V1_Controller::get_item_schema() WC 8.7.0

public function get_item_schema() {
	$schema = array(
		'$schema'    => 'http://json-schema.org/draft-04/schema#',
		'title'      => 'product_attribute',
		'type'       => 'object',
		'properties' => array(
			'id'           => array(
				'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
				'type'        => 'integer',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'name'         => array(
				'description' => __( 'Attribute name.', 'woocommerce' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit' ),
				'arg_options' => array(
					'sanitize_callback' => 'sanitize_text_field',
				),
			),
			'slug'         => array(
				'description' => __( 'An alphanumeric identifier for the resource unique to its type.', 'woocommerce' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit' ),
				'arg_options' => array(
					'sanitize_callback' => 'sanitize_title',
				),
			),
			'type'         => array(
				'description' => __( 'Type of attribute.', 'woocommerce' ),
				'type'        => 'string',
				'default'     => 'select',
				'enum'        => array_keys( wc_get_attribute_types() ),
				'context'     => array( 'view', 'edit' ),
			),
			'order_by'     => array(
				'description' => __( 'Default sort order.', 'woocommerce' ),
				'type'        => 'string',
				'default'     => 'menu_order',
				'enum'        => array( 'menu_order', 'name', 'name_num', 'id' ),
				'context'     => array( 'view', 'edit' ),
			),
			'has_archives' => array(
				'description' => __( 'Enable/Disable attribute archives.', 'woocommerce' ),
				'type'        => 'boolean',
				'default'     => false,
				'context'     => array( 'view', 'edit' ),
			),
		),
	);

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