Notice: This thread is over two years old; the information may be outdated. Please consider creating a new thread if you require free support. If you have an active SiteOrigin Premium license, you can email our premium support desk at [email protected].
Hi Guys!
I need to use html tags in widget titles, in my case the tag. The only way to accomplish this is to edit the file “wp-content/plugins/so-widgets-bundle/widgets/editor/tpl/default.php” and remove the esc_html function from “esc_html($instance[‘title’])”.
This works but is not upgrade-safe. How can I manage this upgrade-safe?
Already there is a widget-tile section in the PageBuilder settings. Please, do the community a favour and just add there a checkbox whether the titels should be escaped or not…
Hi :)
Thanks for reaching out.
The widget title field is intended to be a simple text field which is why, for maximum simplicity, HTML isn’t supported. This is the same for core WordPress widgets used in theme widget areas.
Please, let us know the use case you’re working on and we’ll try to advise a way forward.
(Leaving the Title field blank and using the Custom HTML widget is one simple use case option.)
Hello Andrew!
I need to enter the correct content without fiddeling around. If a company insists writing a trademark or copyright symbol in the title that isn’t possible with your widget title fields.
About WordPress: that is not in all cases true. Eg. in the menu link texts additional HTML code is allowed and is also correctly interpreted in the frontend. Eg. if you wrap a word in a tag, this word will displayed as small caps.
Further more, it is easily possible to enable HTML-code also in widget titles. Reade more there: https://www.isitwp.com/simple-html-in-widget-title/
Basically you say with your reply, that, for “simplicity”, companies are not allowed to write (perhaps legal) important symbols in the title text. That is not acceptable as you can imagine. Content comes always first.
I knew already the workaround with the Custom HTML widget – which means to define extra css styles and fiddeling around with them.
A more simple solution: just remove the title escaping from the file “wp-content/plugins/so-widgets-bundle/widgets/editor/tpl/default.php” in your next update completely. Escaping makes no sense there.
Thanks for your feedback, I understand the use case requirement. I’ve chatted with Braam here at SiteOrigin about the request and logged it on the GitHub repo for the Widgets Bundle.
Is the title or trademark at the beginning or end of the widget title field? If you can show me the page and heading in question, I’d be happy to write up a CSS solution for you.
Hi Andrew,
Thank you for pushing my request further and thank you for your offer to write a css solution. I don’t need that css solution.
In my special case I need small caps in the title, that also points to a reference list, eg. “Diversity Managementxi”. This is not achievable via pure css and the :after and :before pseudo elements. This is only achieveable by removing the HTML escape function.
As I said, I removed the escape function from default.php, so I have only to worry if your next update of the page builder will overwrite that again. I have to keep that in mind.
People who wonder how to enable the onclick attribute in wordpress text fields read more here: https://stackoverflow.com/questions/26333000/how-to-include-onclick-object-in-wordpress-html
Thanks for your replies.
Ok, the title tag is not correctly display in the forum post, I try it again:
Thanks for the feedback.
After the next update, you would need to redo the escaping change you’ve made. It’s unlikely, given the queue of issues that we have at the moment that this request will be looked at for the next update. Unfortunately, that isn’t something I have control over.
If you want help with an update safe solution, please, let me know. The
sup
tag could be inserted into the widget body and absolute positioned into place or the entire heading inserted into the widget body and styling adjusted as needed.Ok, perhaps there is a solution you can help me with.
With the SiteOrigin page builder it is possible to create custom widgets. I played around with that recently, but i’m not really into it.
So, a custom template is update-overwrite-safe, right? I would copy the standard editor template and just remove the escape function in the new template.
How do I manage this exactly? Maybe you have some hints for me?
A custom widget would be contained a custom theme or a child theme or a custom plugin, all would be update safe.
It’s a bit beyond what we can offer here within our free support scope though to cover how to copy the Editor widget from the Widgets Bundle plugin, register it in a custom plugin and change the necessary namespaces. I wish I could. We’re a small operation working with limited resources. Normally, our free support scope only covers basic usage and troubleshooting.
The Black Studio Visual Editor, Text and Custom HTML widgets are all the same in terms of escaping title. I checked those for you.
Hey Andrew,
ok, i’m fine with that. I expect no complicate work from you.
I think escaping titles is maybe for security reasons. But the escaped title shows possible “bad” tags in the browser. Like
will be displayed as
in the browser.
So, for security reasons escaping text is maybe not enough. Better would be removing the whole tag with its contents. Further more, I see at the moment no reason for escaping titles, but not escape HTML in the adjacent textbox.
I will try to figure out to build a custom widget on my own.
Thanks for your understanding.
The easiest would be to put the title in the widget body. I hear you when you say when you don’t want to do that. I’d be happy to assist if you change your mind.
I’ve logged your request to allow HTML in widget titles. Thanks again for your feedback.