I'm using wp-db.php on a non-Wordpress site which allows a apply_filters function to be used. I initially did this:
function apply_filters($type, $input) {
return strip_tags($input);
}
I want to stop html from being saved. I thought I fixed the problem but then noticed that sql queries that included things like <= weren't working.
What I want it to do is to strip tags that begin with a character e.g. <b...
but if there is a space or equals sign after the bracket e.g. <
or <=
then it shouldn't remove it.
I found this code but it doesn't work how I want it to:
preg_replace('/<[^>]*>/', '', $input);
e.g.
<b>test</b> abc <= def < ok? ilj >= xyz >
gets returned as:
test abc = xyz >
it should only remove <x...>
where x is not a space or equals sign and remove </....>
BTW I noticed that < script> doesn't work so I think it's ok for < with a space after to stay.