When visiting Settings > General and changing the Blocks Compatibility to “Off” there’s an error at my site: Fatal error: Uncaught Error: Call to undefined function register_block_type() in...
The plugin that causes this does not check if the function exists, so at first I understood why this is happening. But then I saw that function register_block_type() is declared in CP.
So why the error?
If the function is disabled when turning Blocks Compatibility off, why is this option available? (as it causes a fatal error in some cases)
This is how it’s supposed to work.
You can choose to not have polyfills for block functions (off), to have polyfills (on) or to have polyfills that trace the caller (debug).
Off makes sense if you don’t have block stuff or if you just have plugins handling block functions correctly.
As exemple a plugin can check for has_blocks and then if declared do a lot of block stuff also calling a function that is not polyfilled causing a fatal when not in off mode.
Thanks. Maybe adding a warning at that page is helpful? Please note: turning Blocks Compatibility off may result in a fatal error when a theme or plugin has a block-related feature.
Documentation will only help to a small extent IMO. For example if the impacting plugin is deactivated first, then Blocks Compatibility is configured to Off, and lastly enable the plugin, you’ll get the same error on the plugin screen without any local explanation.
The user then needs to know there is a Blocks Compatibility settings, know where it is and navigate to it to toggle the setting. So, in this situation the documentation is unlikely to help before the event.
Ultimately, this is poor plugin / theme coding that isn’t checking for functions before calling them when presumably reporting support for WordPress versions of 4.9 and lower.