Ready to get started?Download WordPress


Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/wp kses attr


Removes all attributes, if none are allowed for this element.

If some are allowed it calls wp_kses_hair() to split them further, and then it builds up new HTML code from the data that wp_kses_hair() returns. It also removes '<' and '>' characters, if there are any left. One more thing it does is to check if the tag has a closing XHTML slash, and if it does, it puts one in the returned code as well.


<?php wp_kses_attr$element$attr$allowed_html$allowed_protocols ?>


(string) (required) HTML element/tag
Default: None
(string) (required) HTML attributes from HTML element to closing HTML element tag
Default: None
(array) (required) Allowed HTML elements
Default: None
(array) (required) Allowed protocols to keep
Default: None

Return Values

Sanitized HTML element



Change Log

Since: 1.0.0

Source File

wp_kses_attr() is located in wp-includes/kses.php.


See also index of Function Reference and index of Template Tags.