Automattic\WooCommerce\Admin\API

ShippingPartnerSuggestions::get_suggestions_schema()public staticWC 1.0

Get the schema, conforming to JSON Schema.

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

Хуков нет.

Возвращает

Массив.

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

$result = ShippingPartnerSuggestions::get_suggestions_schema();

Код ShippingPartnerSuggestions::get_suggestions_schema() WC 8.7.0

public static function get_suggestions_schema() {
	$feature_def = array(
		'type'  => 'array',
		'items' => array(
			'type'       => 'object',
			'properties' => array(
				'icon'        => array(
					'type' => 'string',
				),
				'title'       => array(
					'type' => 'string',
				),
				'description' => array(
					'type' => 'string',
				),
			),
		),
	);
	$layout_def  = array(
		'type'       => 'object',
		'properties' => array(
			'image'    => array(
				'type'        => 'string',
				'description' => '',
			),
			'features' => $feature_def,
		),
	);

	$item_schema = array(
		'type'       => 'object',
		'required'   => array( 'name', 'is_visible', 'available_layouts' ),
		// require layout_row or layout_column. One of them must exist.
		'anyOf'      => array(
			array(
				'required' => 'layout_row',
			),
			array(
				'required' => 'layout_column',
			),
		),
		'properties' => array(
			'name'              => array(
				'description' => __( 'Plugin name.', 'woocommerce' ),
				'type'        => 'string',
				'required'    => true,
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'slug'              => array(
				'description' => __( 'Plugin slug used in https://wordpress.org/plugins/{slug}.', 'woocommerce' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'layout_row'        => $layout_def,
			'layout_column'     => $layout_def,
			'description'       => array(
				'description' => __( 'Description', 'woocommerce' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'learn_more_link'   => array(
				'description' => __( 'Learn more link .', 'woocommerce' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'is_visible'        => array(
				'description' => __( 'Suggestion visibility.', 'woocommerce' ),
				'type'        => 'boolean',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'available_layouts' => array(
				'description' => __( 'Available layouts -- single, dual, or both', 'woocommerce' ),
				'type'        => 'array',
				'items'       => array(
					'type' => 'string',
					'enum' => array( 'row', 'column' ),
				),
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
		),
	);

	$schema = array(
		'$schema' => 'http://json-schema.org/draft-04/schema#',
		'title'   => 'shipping-partner-suggestions',
		'type'    => 'array',
		'items'   => array( $item_schema ),
	);

	return $schema;
}