Created
April 10, 2020 17:46
-
-
Save dangoodman/cae2e6d75e2582ba9714fdf33beab894 to your computer and use it in GitHub Desktop.
WooCommerce: allow HTML in shipping option labels
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Paste everything below this line to your child-theme's functions.php file. | |
// Cancel sanitizing for all shipping option labels starting with 'HTML:'. | |
remove_filter('woocommerce_shipping_rate_label', 'sanitize_text_field'); | |
add_filter('woocommerce_shipping_rate_label', function($label) { | |
if (substr_compare($label, 'HTML:', 0, 5) === 0) { | |
$label = ltrim(substr($label, 5)); | |
} | |
else { | |
$label = sanitize_text_field($label); | |
} | |
return $label; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment