I need to sanitize the output of admin_notices which uses certain things like
- a
- id
- href
- title
- strong
Is it good idea to use wp_kses_post
function?
Reading docs I am uncertain what HTML tags are allowed https://developer.wordpress.org/reference/functions/wp_kses_post/
2
Answers
To check the list of allowed tags and attributes for
wp_kses_post
you can useIn your case, where only
a
andstrong
allowed, you can usewp_kses
function (docs) insteadwp_kses_post
allows all HTML that is permitted in post content. So it will load a large array which is redundant in your case. As you need only some specific HTML tags to be sanitized, you should use thewp_kses
function as you have control here and you can mention which HTML tags should be allowed. You can do as follows-