Recently I stumped upon a handy WordPress function which closes HTML tags.
The function name is force_balance_tags()
.
Taking as an example unclosed list items:
echo force_balance_tags( '<ul>
<li>this
<li>is
<li>a
<li>list
</ul>' );
It will produce something like this:
<ul>
<li>this
</li><li>is
</li><li>a
</li><li>list
</li></ul>
Thank you! Where should I add this code? There is no explanation in the article so I don’t know what actions I need to take.
Well, it’s not meant to “be put”. It should fit into your process, whatever that is, ie. saving user data.
Thanks for the hint!
I guess you could modify it a bit, to actually wrap all the text in the lists aswell.
It is wrapping, just before the opening next tag, on the new line. It’s not pretty but it works 🤷♂️
Oh dang!
I missed that!
For me it looked like:
One
Now I get it!
But hey! It’s good as long as it’s working 😀