Advertisement
majeedraza

WooCommerce - Attribute value containing html

Jan 24th, 2021
772
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.48 KB | None | 0 0
  1. <?php
  2. WooCommerce - Attribute value containing html
  3. add_filter( 'woocommerce_attribute', 'custom_attribute_filter', 10, 2 );
  4. function custom_attribute_filter( $value, $attribute ) {
  5.   // $value is filtered
  6.   $attribute_name = $attribute->get_name();
  7.   if( 'attribute_with html_name' == $attribute_name ) {
  8.     $options = $attribute->get_options();
  9.     $value = $options[0]; // unfiltered value
  10.     $value = html_entity_decode( $value, ENT_COMPAT | ENT_HTML5 );
  11.   }
  12.   return $value;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement