Sanitize content from wp_editor
I built a custom post type where we can find a standard textarea/tinymce generated by wp_editor()
and I'm facing an issue for the saving part.
If I save the content with the following code :
update_post_meta( $post_id, $prefix.'content', $_POST['content'] );
Everything is working fine but there is no security (sanitization, validation etc...)
If I save the content with the following code :
update_post_meta( $post_id, $prefix.'content', sanitize_text_field($_POST['content']) );
I solve the security issue but I lose all the style, media etc.. in the content.
What could be a good way to save the content with all the style applied, the media inserted but including a sanitization ?
I read a bit about wp_kses()
but I don't know how I could apply a good filter. (Allowing common tags, which one should I block ? etc..)
Topic wp-editor sanitization Wordpress
Category Web