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:
@@ -5,6 +5,7 @@ namespace MailPoet\AdminPages\Pages;
|
||||
use MailPoet\AdminPages\PageRenderer;
|
||||
use MailPoet\Config\Menu;
|
||||
use MailPoet\Entities\SubscriberEntity;
|
||||
use MailPoet\Form\AssetsController;
|
||||
use MailPoet\Form\Util\CustomFonts;
|
||||
use MailPoet\Newsletter\Renderer\Blocks\Coupon;
|
||||
use MailPoet\Newsletter\Shortcodes\ShortcodesHelper;
|
||||
@@ -54,6 +55,9 @@ class NewsletterEditor {
|
||||
/** @var CustomFonts */
|
||||
private $customFonts;
|
||||
|
||||
/*** @var AssetsController */
|
||||
private $assetsController;
|
||||
|
||||
public function __construct(
|
||||
PageRenderer $pageRenderer,
|
||||
SettingsController $settings,
|
||||
@@ -65,7 +69,8 @@ class NewsletterEditor {
|
||||
SubscribersRepository $subscribersRepository,
|
||||
TransactionalEmailHooks $wooEmailHooks,
|
||||
WPPostListLoader $wpPostListLoader,
|
||||
CustomFonts $customFonts
|
||||
CustomFonts $customFonts,
|
||||
AssetsController $assetsController
|
||||
) {
|
||||
$this->pageRenderer = $pageRenderer;
|
||||
$this->settings = $settings;
|
||||
@@ -78,9 +83,11 @@ class NewsletterEditor {
|
||||
$this->wooEmailHooks = $wooEmailHooks;
|
||||
$this->wpPostListLoader = $wpPostListLoader;
|
||||
$this->customFonts = $customFonts;
|
||||
$this->assetsController = $assetsController;
|
||||
}
|
||||
|
||||
public function render() {
|
||||
$this->assetsController->setupNewsletterEditorDependencies();
|
||||
$newsletterId = (isset($_GET['id']) ? (int)$_GET['id'] : 0);
|
||||
$woocommerceTemplateId = (int)$this->settings->get(TransactionalEmails::SETTING_EMAIL_ID, null);
|
||||
if (
|
||||
@@ -149,7 +156,6 @@ class NewsletterEditor {
|
||||
];
|
||||
$this->wp->wpEnqueueMedia();
|
||||
$this->wp->wpEnqueueStyle('editor', $this->wp->includesUrl('css/editor.css'));
|
||||
|
||||
$this->pageRenderer->displayPage('newsletter/editor.html', $data);
|
||||
}
|
||||
|
||||
|
@@ -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');
|
||||
}
|
||||
}
|
||||
|
@@ -479,7 +479,6 @@
|
||||
<% endblock %>
|
||||
|
||||
<% block after_javascript %>
|
||||
<%= javascript('newsletter_editor.js') %>
|
||||
|
||||
<%= do_action('mailpoet_newsletter_editor_after_javascript') %>
|
||||
|
||||
|
Reference in New Issue
Block a user