Now and then, whenever I’m working with pre-existing source code or performing a code audit, I’ll see others modifying the post content of a post object like this:
At this point, some will drop in and immediately say you’re doing it wrong. I hate that phrase (and it’s even littered throughout the WordPress codebase, but I digress).
There are ways to use other existing WordPress API functions to sanitize the data before setting it equal to the value of the post_content attribute, using those functions isn’t the best way to go about doing it.
Instead, we all should be using apply_filters. The problem? Some don’t know, some don’t know how it works, and some don’t know how to use it. That is it’s not clear how to go about properly filtering post content.

Raw content filtered by WordPress then written to the database.
But for those who may fall into any of the categories above, then perhaps this can help.



