How safe / sanitized is wp_insert_posts()?

You don’t have to do anything.

On WP load:

'init' hook -> kses_init() -> kses_init_filters()

Later:

wp_insert_post() -> sanitize_post() -> sanitize_post_field() -> 'content_save_pre' -> wp_filter_post_kses()

Similarly for post titles, comment text etc.

Conclusion: wp_insert_post() is very sanitized. 🙂

Leave a Comment