Add newsletter_editor.js using AssetsController

newsletter_editor.js was added via newsletter/editor.html
it's now removed from the template and wpEnqueueScript is
user instead

[MAILPOET-4908]
This commit is contained in:
Sam Najian
2022-12-29 15:33:27 +01:00
committed by Aschepikov
parent cac0c8e93d
commit ece4977d6a
3 changed files with 26 additions and 3 deletions

View File

@@ -160,4 +160,22 @@ EOL;
);
$this->wp->wpSetScriptTranslations('automation_templates', 'mailpoet');
}
public function setupNewsletterEditorDependencies(): void {
$this->wp->wpEnqueueScript(
'newsletter_editor',
Env::$assetsUrl . '/dist/js/' . $this->renderer->getJsAsset('newsletter_editor.js'),
[],
Env::$version,
true
);
/**
* The js file needs to be added immediately since the mailpoet_newsletters_editor_initialize hook is dispatched in template files
* Update and remove this line in MAILPOET-4930
*/
\wp_scripts()->do_item('newsletter_editor');
$this->wp->wpDequeueScript('newsletter_editor');
}
}