Start by checking your user role, only Administrators have the unfiltered_html capablity by default.
If this is a Multisite install, only Super Admins can save raw <script>tags in the editor unless the unfiltered_html capability was manually added to the Administrator role.
Also check any security plugin settings related to XSS filtering or HTML sanitization.
Otherwise, try deactivating all plugins, then reactivate them one by one and test each time until you find the cause.
If that does not resolve the issue, switch temporarily to a default WordPress theme to rule out a theme-specific issue.
The define('DISALLOW_UNFILTERED_HTML', false) line in wp-config isn’t doing anything. That constant only matters when it’s set to true. On single-site WP, admins already have unfiltered_html, so setting it false just confirms the default.
What I’d do: open DevTools Network tab, drop a <script> tag into a Custom HTML block, save, and grab the PATCH to /wp-json/wp/v2/posts/{id}. Look at two things:
– Request body content: what the editor sent – Response body content.raw: what the server kept after kses
If the script is in the request and gone from the response, it’s wp_filter_post_kses chewing it up server-side. That usually means a plugin (Wordfence, Solid Security, an SEO suite with XSS rules) is hooked in and downgrading your capability. If it’s already missing from the request, the block editor itself stripped it on the way out, which usually means a Gutenberg-side security filter.
That at least tells you whether to disable a server hook or look at the editor’s JS filters before you do the plugin bisect.
That sounds very helpful, @alexfv . Can’t try it right now, but I’ll check it out later. Thanks!