Resolved
Reported for: WPML Multilingual CMS 4.6.3
Resolved in: WPML 4.6.4
Overview of the issue
When using WPML with WordPress 4.7, a fatal error occurs due to the Language Switcher block being registered for translation. This happens even if Gutenberg is not enabled.
This causes compatibility issues with WordPress versions lower than 5.0.
Fatal error: Uncaught Error: Call to undefined function WPML\BlockEditor\Blocks\register_block_type() in …/wp-content/plugins/sitepress-multilingual-cms/classes/block-editor/Blocks/LanguageSwitcher.php:47
Workaround
Our developers are aware of this situation and they are preparing a beta version of WPML to fix it. In the meantime:
- Please, be sure to have a full backup of your site before proceeding.
- Open the …/wp-content/plugins/sitepress-multilingual-cms/classes/block-editor/Loader.php file.
- Look for line 57.
- Change:
1234
public
function
registerBlocks() {
$LSLocalizedScriptData
= make( LanguageSwitcher::
class
)->register();
$this
->localizedScriptData =
array_merge
(
$this
->localizedScriptData,
$LSLocalizedScriptData
);
}
To:
123456public
function
registerBlocks() {
if
( \WPML_Block_Editor_Helper::is_active() ) {
$LSLocalizedScriptData
= make( LanguageSwitcher::
class
)->register();
$this
->localizedScriptData =
array_merge
(
$this
->localizedScriptData,
$LSLocalizedScriptData
);
}
}