What we need in order to meet our project requirements is the ability for a property owner to post an HTML snippet and have that placed onto the listing “as is” without any changes.
I tried using the “TextArea” listing attribute, which escapes HTML characters.
I also tried this code snippet in an attempt to convert the encoded text back to plain HTML during the display format step. However, this didn’t work either, either because my code isn’t doing the right thing, or because the text is being further modified before being output to the screen.
So after further testing, I have discovered that the ‘hivepress/v1/models/listing/attributes’ filter only sets the format, but the value itself isn’t actually modified.
This now makes the question:
Where can I get access to the value AFTER it has been produced based on the format?
OR
How can we modify TextArea attributes to allow HTML code?
Please note that the HTML parameter takes not only true/false but also an array of available HTML tags. The format is the same as this function in allowed_htmlwp_kses() – Function | Developer.WordPress.org.
It is not possible to allow full editing because it is not secured, but you can list HTML tags.
Thanks for the reply. I have spent some time trying to get this to work, but I may be misunderstanding your direction or am just not putting my code in the right place.
Here is a simplified example, one where I just want to allow the span tag. However, if I enter something like test, the only thing that is saved in the Text field is “test”.
Do I need to use a different filter or hook that allows specific HTML at the point in time where it is saved, rather than trying to format the output?
If you use this hook, you need to set the parameters as follows: $attribute[‘fieldnamehere’][‘edit_field’][‘html’]=….
Also, you can check these samples: