WC_REST_Product_Categories_V2_Controller::get_item_schema()publicWC 1.0

Get the Category schema, conforming to JSON Schema.

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

Хуков нет.

Возвращает

Массив.

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

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

Код WC_REST_Product_Categories_V2_Controller::get_item_schema() WC 8.7.0

public function get_item_schema() {
	$schema = array(
		'$schema'    => 'http://json-schema.org/draft-04/schema#',
		'title'      => $this->taxonomy,
		'type'       => 'object',
		'properties' => array(
			'id'          => array(
				'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
				'type'        => 'integer',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'name'        => array(
				'description' => __( 'Category 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',
				),
			),
			'parent'      => array(
				'description' => __( 'The ID for the parent of the resource.', 'woocommerce' ),
				'type'        => 'integer',
				'context'     => array( 'view', 'edit' ),
			),
			'description' => array(
				'description' => __( 'HTML description of the resource.', 'woocommerce' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit' ),
				'arg_options' => array(
					'sanitize_callback' => 'wp_filter_post_kses',
				),
			),
			'display'     => array(
				'description' => __( 'Category archive display type.', 'woocommerce' ),
				'type'        => 'string',
				'default'     => 'default',
				'enum'        => array( 'default', 'products', 'subcategories', 'both' ),
				'context'     => array( 'view', 'edit' ),
			),
			'image'       => array(
				'description' => __( 'Image data.', 'woocommerce' ),
				'type'        => 'object',
				'context'     => array( 'view', 'edit' ),
				'properties'  => array(
					'id'                => array(
						'description' => __( 'Image ID.', 'woocommerce' ),
						'type'        => 'integer',
						'context'     => array( 'view', 'edit' ),
					),
					'date_created'      => array(
						'description' => __( "The date the image was created, in the site's timezone.", 'woocommerce' ),
						'type'        => 'date-time',
						'context'     => array( 'view', 'edit' ),
						'readonly'    => true,
					),
					'date_created_gmt'  => array(
						'description' => __( 'The date the image was created, as GMT.', 'woocommerce' ),
						'type'        => 'date-time',
						'context'     => array( 'view', 'edit' ),
						'readonly'    => true,
					),
					'date_modified'     => array(
						'description' => __( "The date the image was last modified, in the site's timezone.", 'woocommerce' ),
						'type'        => 'date-time',
						'context'     => array( 'view', 'edit' ),
						'readonly'    => true,
					),
					'date_modified_gmt' => array(
						'description' => __( 'The date the image was last modified, as GMT.', 'woocommerce' ),
						'type'        => 'date-time',
						'context'     => array( 'view', 'edit' ),
						'readonly'    => true,
					),
					'src'               => array(
						'description' => __( 'Image URL.', 'woocommerce' ),
						'type'        => 'string',
						'format'      => 'uri',
						'context'     => array( 'view', 'edit' ),
					),
					'title'             => array(
						'description' => __( 'Image name.', 'woocommerce' ),
						'type'        => 'string',
						'context'     => array( 'view', 'edit' ),
					),
					'alt'               => array(
						'description' => __( 'Image alternative text.', 'woocommerce' ),
						'type'        => 'string',
						'context'     => array( 'view', 'edit' ),
					),
				),
			),
			'menu_order'  => array(
				'description' => __( 'Menu order, used to custom sort the resource.', 'woocommerce' ),
				'type'        => 'integer',
				'context'     => array( 'view', 'edit' ),
			),
			'count'       => array(
				'description' => __( 'Number of published products for the resource.', 'woocommerce' ),
				'type'        => 'integer',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
		),
	);

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