preg_match_all( $re, $src ) ) { // Whole script/style elements go, not only their tags: kses would leave "alert(1)" as text. $translated = (string) preg_replace( '#<(script|style)\b[^>]*>.*?#is', '', $translated ); return wp_kses_post( $translated ); } } return $translated; } /** Entities and whitespace tricks undone, so "javascript:" counts too. */ private static function decoded( string $html ): string { $text = html_entity_decode( $html, ENT_QUOTES | ENT_HTML5, 'UTF-8' ); return (string) preg_replace( '/[\x00-\x1F]+/', '', $text ); } }