Automattic\WooCommerce\Blocks\BlockTypes
AbstractProductGrid::parse_attributes
Get the block's attributes.
Method of the class: AbstractProductGrid{}
No Hooks.
Returns
Array. Block attributes merged with defaults.
Usage
// protected - for code of main (parent) or child class $result = $this->parse_attributes( $attributes );
- $attributes(array) (required)
- Block attributes.
Default:empty array
AbstractProductGrid::parse_attributes() AbstractProductGrid::parse attributes code WC 10.4.3
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 );
}