I'm confused about the different uses of esc_html()
and wp_kses()
. I understand that esc_html()
converts special characters to their HTML entity, and that wp_kses()
removes unwanted tags (e.g., <script>
), but I'm not sure in what contexts they should be used together or separately.
If I run some untrusted HTML through esc_html()
, then any JavaScript will be displayed in plain text rather than being rendered by the browser, so it is safe at that point, correct? The only reason to also run it through wp_kses()
would be to avoid having the raw script displayed?
Basically, esc_html()
makes it safe, and wp_kses()
makes it pretty. Is that correct?