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:
@@ -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')],
|
||||||
|
Reference in New Issue
Block a user