Fix the issue of marketing optin block translation not getting added

Since WP 6.0 we can no longer leave translation_path in block
settings empty and expect to receive the fallback thus we need
to add the fallback ourselves.

[MAILPOET-4435]
This commit is contained in:
Sam Najian
2022-06-15 10:15:52 +02:00
committed by Veljko V
parent d3a5525095
commit fe6013f0cf

View File

@@ -86,11 +86,14 @@ class MarketingOptinBlock implements IntegrationInterface {
*/ */
private function registerEditorTranslations() { private function registerEditorTranslations() {
$handle = 'mailpoet-marketing-optin-block-editor-script'; $handle = 'mailpoet-marketing-optin-block-editor-script';
$editorTranslations = $this->wp->getWpScripts()->print_translations($handle, false); $editorTranslations = <<<JS
// mailpoet-marketing-optin-block-editor-script is not enqueued ( function( domain, translations ) {
if ($editorTranslations === false) { var localeData = translations.locale_data[ domain ] || translations.locale_data.messages;
return; localeData[""].domain = domain;
} wp.i18n.setLocaleData( localeData, domain );
} )( "mailpoet", { "locale_data": { "messages": { "": {} } } } );
JS;
$translations = [ $translations = [
'' => ['domain' => 'messages'], '' => ['domain' => 'messages'],
'marketing-opt-in-label' => [__('Marketing opt-in', 'mailpoet')], 'marketing-opt-in-label' => [__('Marketing opt-in', 'mailpoet')],