Use wp_strip_all_tags() instead of strip_tags() when available

Supposedly, it's better at stripping the contents of <script> and <style> tags.
This commit is contained in:
Yahnis Elsts 2023-05-01 12:22:04 +03:00
parent ebf5bc21a0
commit a42e1e7346
1 changed files with 5 additions and 1 deletions

View File

@ -241,7 +241,11 @@ class PucReadmeParser {
}
function sanitize_text( $text ) { // not fancy
$text = strip_tags($text);
$text = function_exists('wp_strip_all_tags')
? wp_strip_all_tags($text)
//phpcs:ignore WordPressVIPMinimum.Functions.StripTags.StripTagsOneParameter -- Using wp_strip_all_tags() if available
: strip_tags($text);
$text = esc_html($text);
$text = trim($text);
return $text;