HTML tags removed or added in PHP snippet resulting in errors
-
This is just a report on an issue related to PHP snippets and using HTML tags inside of those. The code editor is trying to be intelligent I’m sure by not allowing malformed HTML, but in PHP code, that’s illogical to require proper opening and closing HTML tags. In two examples, I’ve run into this bug where WPCode tries to add closing HTML tags to the end of a PHP snippet or just straight up deletes my closing HTML tag because there was no opening tag. In the case of strip_tags(), I was feeding it a string of allowed tags like so: strip_tags($html, ‘<p><div><ul><li>’) but WP Code would see that there are no closing HTML tags for those HTML tags in the second parameter of the function and just plop them at the end of the PHP snippet messing up the entire thing. In another case, I was searching for closing tags to dynamically insert content using the_content filter after X number of </ul> closing tags and when I saved the code snippet containing a variable assigned to ‘</ul>’, it just removed </ul> completely obviously rendering the code useless. The result is I had to use another code snippets plugin to achieve what I wanted in one situation and was able to reformat the the allowed tags in strip_tags to an array and make it work in the other situation.
- The topic ‘HTML tags removed or added in PHP snippet resulting in errors’ is closed to new replies.