Skip to content

Instantly share code, notes, and snippets.

@petenelson
Created November 2, 2022 13:56
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 petenelson/a0db87a42238cf645c1c21cb4ceab103 to your computer and use it in GitHub Desktop.
Save petenelson/a0db87a42238cf645c1c21cb4ceab103 to your computer and use it in GitHub Desktop.
WordPress: FILTER_SANITIZE_STRING for PHP8
<?php
/**
* Callback filter for filter_var_array() to strip HTML tags.
*
* @return array
*/
function filter_strip_all_tags() {
return [
'filter' => FILTER_CALLBACK,
'options' => '\wp_strip_all_tags',
];
}
// Example Usage.
$get = filter_var_array(
$_GET,
[
'string_param' => filter_strip_all_tags(),
]
);
// Get sanitized string.
$param = $get['string_param'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment