Guest User

Untitled

a guest
May 31st, 2017
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.67 KB | None | 0 0
  1. add_filter( 'woocommerce_attribute', 'make_product_atts_linkable', 10, 3 );
  2. function make_product_atts_linkable( $text, $attribute, $values ) {
  3.     $new_values = array();
  4.     foreach ( $values as $value ) {
  5.         if ( $attribute['is_taxonomy'] ) {
  6.  
  7.             $url = "http://link.com/" . $value;
  8.             if ( ! empty( $url ) ) {
  9.                 $val = '<a href="' . esc_url( $url ) . '" title="' . esc_attr( $value ) . '">' . $value . '</a>';
  10.                 array_push( $new_values, $val );
  11.             } else {
  12.                 array_push( $new_values, $value );
  13.             }
  14.         }
  15.     }
  16.     $text = implode( ', ', $new_values );
  17.     return $text;
  18. }
Add Comment
Please, Sign In to add comment