wc_attribute_taxonomy_slug( string $attribute_name )
Get an unprefixed product attribute name.
Description Description
Parameters Parameters
- $attribute_name
-
(Required) Attribute name.
Return Return
(string)
Source Source
File: includes/wc-attribute-functions.php
function wc_attribute_taxonomy_slug( $attribute_name ) {
$prefix = WC_Cache_Helper::get_cache_prefix( 'woocommerce-attributes' );
$cache_key = $prefix . 'slug-' . $attribute_name;
$cache_value = wp_cache_get( $cache_key, 'woocommerce-attributes' );
if ( $cache_value ) {
return $cache_value;
}
$attribute_name = wc_sanitize_taxonomy_name( $attribute_name );
$attribute_slug = 0 === strpos( $attribute_name, 'pa_' ) ? substr( $attribute_name, 3 ) : $attribute_name;
wp_cache_set( $cache_key, $attribute_slug, 'woocommerce-attributes' );
return $attribute_slug;
}
Changelog Changelog
| Version | Description |
|---|---|
| 3.6.0 | Introduced. |