Closed muhyal closed 2 years ago
Hi @muhyal,
In fact this is not a limitation of carbon fields or my plugin, but a limitation from WooCommerce. The hook used to display the badge is escaping html.
So the workarounds would be to override the products pages in your theme, or to replace WC hook.
Thanks, @CharlieEtienne,
Do you have any guidance on how to do it?
Wait, I'm not sure of what I told in my previous message... Let me check.
I was completely wrong, sorry. I was thinking to another plugin. The HTML is actually escaped in my plugin, in wp-content/plugins/sold-out-badge-for-woocommerce/classes/Settings.php
on line 125.
Could you try this code (in your theme's functions.php
for example) and let me know if it works?
global $post, $product;
add_filter('wcsob_soldout', function($content) {
return htmlspecialchars_decode($content, ENT_QUOTES);
}, $post, $product);
I tested it but this time the theme is broken.
It looks like this:
Yes, I forgot to specify the number of arguments. This is the right function to use:
global $post, $product;
add_filter('wcsob_soldout', function ($content, $post, $product) {
return htmlspecialchars_decode($content, ENT_QUOTES);
}, 10, 3);
You've probably heard this a lot in your life @CharlieEtienne . "You are a great person" :) Thanks for your support.
Looks just like we imagined:
You're welcome!
Hi,
Can I use HTML in the Badge text field in the admin panel?
If I use HTML it shows the entered value as plain text:
For example, for a badge that looks like this:
I want to set it like this:
I did some research and found a document like this, but I couldn't get a successful result: https://carbonfields.net/docs/fields-html/
Thank you for your support.