wc_attribute_taxonomy_slug()WC 3.6.0

Get an unprefixed product attribute name.

Хуков нет.

Возвращает

Строку.

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

wc_attribute_taxonomy_slug( $attribute_name );
$attribute_name(строка) (обязательный)
Attribute name.

Список изменений

С версии 3.6.0 Введена.

Код wc_attribute_taxonomy_slug() WC 8.7.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;
}