With the current WooCommerce release, try this instead of the make_product_atts_linkable()
function in the question:
function make_product_atts_linkable( $text, $attribute, $values ) {
$vals = array();
if ( $attribute->is_taxonomy() ) {
foreach ( $attribute->get_options() as $i => $id ) {
if ( $url = get_term_meta( $id, 'attribute_url', true ) ) {
$vals[] = '<a href="' . esc_url( $url ) . '">' . esc_html( get_term_field( 'name', $id ) ) . '</a>';
} else {
$vals[] = $values[ $i ];
}
}
} else {
foreach ( $attribute->get_options() as $value ) {
$vals[] = preg_replace_callback( '/\[([^\]]+)\]\(([^) ]+)(?: "([^"]+)"|)\)/', function ( $matches ) {
$title = ( ! empty( $matches[3] ) ) ? ' title="' . esc_attr( $matches[3] ) . '"' : '';
return '<a href="' . esc_url( $matches[2] ) . '"' . $title . '>' . esc_html( $matches[1] ) . '</a>';
}, $value );
}
}
return wpautop( wptexturize( implode( ', ', $vals ) ) );
//return implode( ', ', $vals ); // Use this or the above. Up to you..
}