@Howdy_McGee okay maybe I should've put an asterisk in there. Not 100% exactly like post_content, I don't want to run the_content filter on there, because it's not "the main content".
so maybe what ever callbacks are fired on the_content might be wise to also fire on my value?
minus what possibly other plugins might be adding to the_content filter
@TomJNowell Are you advising to literally just use echo wp_kses_post( $value ); for output then?
if you're having to escape something and return it as a string then, nope, game over, you're dead, they broke through
the only exceptions are places were core prevents you from following good practice, in which case you have the concept of trusted filters
e.g. we have to trust shortcodes are implemented properly, and that everything that hooks into the_content escapes and sanitises anything it adds correctly
Couldn't you say that about any of the WordPress functions though? For instance, if I call the_content() in the loop the same issues you've described could happen.
the_content escapes internally, the only issue is the_content filter, hence trusted filters
it's suboptimal ofcourse, but we're stuck with it
think of it this way, you do QA on the finished result, you don't repeatedly test the end product as if it were finished throughout the production process
In the example in your answer it seems to me we're re-sanitizing what's returned from the database, then passing that into filters which could modify the re-sanitized result.
I guess it's a very defensive approach but it seems unnecessarily so.