WordPress Block Editor Gutenberg running code inside ! is_admin()
It appears this is a known issue with the block editor (aka Gutenberg). That Trac ticket suggests a workaround, too: replace your if ( ! is_admin() ) { … } with something like this: global $current_screen; if ( ( ! is_admin() ) && ( ! ( // Checks the value of WP_Screen::is_block_editor(). $current_screen instanceof \WP_Screen …