wc_get_attribute_slug_max_byte_length()
Get the maximum byte length allowed for a product attribute slug.
WordPress's register_taxonomy() rejects taxonomy names longer than 32 bytes (see wp-includes/taxonomy.php), and WooCommerce prefixes attribute slugs with 'pa_'. That leaves the slug itself a budget of 32 bytes minus the prefix length. The limit is measured in bytes, not characters: multibyte characters (Cyrillic, Chinese, etc.) consume 2-4 bytes each.
No Hooks.
Returns
Int. Maximum attribute slug length, in bytes.
Usage
wc_get_attribute_slug_max_byte_length();
Changelog
| Since 11.0.0 | Introduced. |
wc_get_attribute_slug_max_byte_length() wc get attribute slug max byte length code WC 11.0.0
function wc_get_attribute_slug_max_byte_length() {
return 32 - strlen( 'pa_' );
}