wc_get_attribute_types()
Get attribute types.
Hooks from the function
Returns
Array.
Usage
wc_get_attribute_types();
Changelog
| Since 2.4.0 | Introduced. |
wc_get_attribute_types() wc get attribute types code WC 10.9.1
function wc_get_attribute_types() {
$attribute_types = array(
'select' => __( 'Text', 'woocommerce' ),
);
$allow_visual_attribute_type =
wp_is_block_theme() &&
FeaturesUtil::feature_is_enabled( 'wc-visual-attribute' );
// If the store already has some visual attributes, let's allow them even
// if the current theme is not a block theme.
if ( ! $allow_visual_attribute_type ) {
foreach ( wc_get_attribute_taxonomies() as $attribute_taxonomy ) {
if ( isset( $attribute_taxonomy->attribute_type ) && 'wc-visual' === $attribute_taxonomy->attribute_type ) {
$allow_visual_attribute_type = true;
break;
}
}
}
if ( $allow_visual_attribute_type ) {
$attribute_types['wc-visual'] = __( 'Color / image', 'woocommerce' );
}
return (array) apply_filters(
'product_attributes_type_selector',
$attribute_types
);
}