wc_attribute_taxonomy_slug()
Get an unprefixed product attribute name.
No Hooks.
Returns
String.
Usage
wc_attribute_taxonomy_slug( $attribute_name );
- $attribute_name(string) (required)
- Attribute name.
Changelog
| Since 3.6.0 | Introduced. |
wc_attribute_taxonomy_slug() wc attribute taxonomy slug code WC 10.5.0
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 ( false !== $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;
}