Skip to content

Instantly share code, notes, and snippets.

@juniovitorino
Last active December 17, 2015 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juniovitorino/5619856 to your computer and use it in GitHub Desktop.
Save juniovitorino/5619856 to your computer and use it in GitHub Desktop.
WordPress Recursive XSS Sanitization
// XSS HTTP Treatment
add_filter('init', 'xssTreatment');
function xssTreatment() {
foreach(array($_GET, $_POST, $_REQUEST) as $httpConst) XSSSanitization( $httpConst );
}
function XSSSanitization(&$param) {
if(!is_array( $param ) && is_string( $param ) ) $param = filter_var($param, FILTER_SANITIZE_STRING);
else if( is_array( $param ) ) foreach( $param as $key => $value ) XSSSanitization( $param[$key] );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment