Sanitize user input fields before wp_insert_post

If calling, sanitize_text_field(), it actually call an internal function _sanitize_text_fields() and add a filter for override. So

First look at _sanitize_text_fields(), which actually do

  • Checks for invalid UTF-8,
  • Converts single < characters to entities
  • Strips all tags <——— including wp_strip_all_tags() here
  • Removes line breaks, tabs, and extra whitespace
  • Strips octets

That’s mean if calling sanitize_text_field(), it already includes wp_strip_all_tags() in the task list.

It is a pretty safe and generic method to sanitize any text.

By referring to the source code, it is known that the following use wp_strip_all_tags()

  • sanitize_user() including some special characters checking
  • wp_trim_words()
  • wp_html_excerpt()
  • wp_setup_nav_menu_item()
  • comment’s wp_blacklist_check()
  • send_recovery_mode_email()
    … etc

Because wp_strip_all_tags() strips all tags including styles and script and its content.
So it is a very useful tools and good for making any custom solutions if needed.

And according to source code, IDs and http status code are being sanitize by absint().
So I think what you are doing is enough.