Automattic\WooCommerce\Blocks\BlockTypes

AbstractProductGrid::parse_attributes()protectedWC 1.0

Get the block's attributes.

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

Хуков нет.

Возвращает

Массив. Block attributes merged with defaults.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->parse_attributes( $attributes );
$attributes(массив) (обязательный)
Block attributes.
По умолчанию: empty array

Код AbstractProductGrid::parse_attributes() WC 8.7.0

protected function parse_attributes( $attributes ) {
	// These should match what's set in JS `registerBlockType`.
	$defaults = array(
		'columns'           => wc_get_theme_support( 'product_blocks::default_columns', 3 ),
		'rows'              => wc_get_theme_support( 'product_blocks::default_rows', 3 ),
		'alignButtons'      => false,
		'categories'        => array(),
		'catOperator'       => 'any',
		'contentVisibility' => array(
			'image'  => true,
			'title'  => true,
			'price'  => true,
			'rating' => true,
			'button' => true,
		),
		'stockStatus'       => array_keys( wc_get_product_stock_status_options() ),
	);

	return wp_parse_args( $attributes, $defaults );
}