Created
April 8, 2023 14:42
-
-
Save lilumi/c2d76d26e885b6c02360c9faaebf6ee2 to your computer and use it in GitHub Desktop.
Disable WPML String Translations for Gutenberg Blocks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
WPML checks for gutenberg like this: | |
\WPML_Page_Builders_Defined->has() | |
``` | |
if ( 'gutenberg' === $page_builder ) { | |
if ( version_compare( $wp_version, '5.0-beta1', '>=' ) ) { | |
return true; | |
} | |
} | |
``` | |
so I created a hooks to override $wp_version during this checks. | |
*/ | |
add_action('after_setup_theme', 'lm_init_wpml'); | |
function lm_init_wpml() { | |
add_action('wpml_load_page_builders_integration', 'lm_disable_wpml_gutenberg_integration_before', 9); | |
add_action('wpml_load_page_builders_integration', 'lm_disable_wpml_gutenberg_integration_after', 11); | |
} | |
function lm_disable_wpml_gutenberg_integration_before() { | |
global $wp_version, $site_wp_version; | |
$site_wp_version = $wp_version; | |
$wp_version = 3; // anything lower than 5.0-beta1 | |
} | |
function lm_disable_wpml_gutenberg_integration_after() { | |
global $wp_version, $site_wp_version; | |
$wp_version = $site_wp_version; | |
unset($site_wp_version); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment