Skip to content

Instantly share code, notes, and snippets.

@BryanBarrera
Last active April 22, 2016 17:19
Show Gist options
  • Save BryanBarrera/dbd8aea90bdbbf13f3c61bd11e24868e to your computer and use it in GitHub Desktop.
Save BryanBarrera/dbd8aea90bdbbf13f3c61bd11e24868e to your computer and use it in GitHub Desktop.
Sanitize HTML
<?php
/**
* The force_balance_tags() function ensures that no tags are left unclosed,
* while the wp_kses_post() ensures that only safe tags make it into the database
* (the same tags that are allowed in a standard WordPress post.)
* @param int $input.
* @return int sanitizes html input to display output. force_balance_tags checks to see if any html tags are unclosed.
*/
function example_sanitize_text( $input ) {
return wp_kses_post( force_balance_tags( $input ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment