diff --git a/lib/Config/Initializer.php b/lib/Config/Initializer.php index 2e8beb5899..c563b5fdde 100644 --- a/lib/Config/Initializer.php +++ b/lib/Config/Initializer.php @@ -3,6 +3,7 @@ namespace MailPoet\Config; use MailPoet\API\JSON\API; +use MailPoet\AutomaticEmails\AutomaticEmails; use MailPoet\Cron\CronTrigger; use MailPoet\Router; use MailPoet\Settings\SettingsController; @@ -15,6 +16,7 @@ use MailPoet\WP\Notice as WPNotice; require_once(ABSPATH . 'wp-admin/includes/plugin.php'); class Initializer { + public $automatic_emails; /** @var AccessControl */ private $access_control; @@ -200,6 +202,7 @@ class Initializer { $this->setupPermanentNotices(); $this->setupDeactivationSurvey(); + $this->setupAutomaticEmails(); WPFunctions::get()->doAction('mailpoet_initialized', MAILPOET_VERSION); } catch (\Exception $e) { @@ -327,4 +330,29 @@ class Initializer { $survey = new DeactivationSurvey($this->renderer); $survey->init(); } + + function setupAutomaticEmails() { + $automatic_emails = new AutomaticEmails(); + $automatic_emails->init(); + $this->automatic_emails = $automatic_emails->getAutomaticEmails(); + + WPFunctions::get()->addAction( + 'mailpoet_newsletters_translations_after', + [$this, 'includeAutomaticEmailsData'] + ); + + WPFunctions::get()->addAction( + 'mailpoet_newsletter_editor_after_javascript', + [$this, 'includeAutomaticEmailsData'] + ); + } + + function includeAutomaticEmailsData() { + $data = [ + 'automatic_emails' => $this->automatic_emails, + 'woocommerce_optin_on_checkout' => $this->settings->get('woocommerce.optin_on_checkout.enabled', false), + ]; + + echo $this->renderer->render('automatic_emails.html', $data); + } } diff --git a/views/automatic_emails.html b/views/automatic_emails.html new file mode 100644 index 0000000000..dc8cab38f4 --- /dev/null +++ b/views/automatic_emails.html @@ -0,0 +1,19 @@ + + +<% block translations %> + <%= localize({ + 'automaticEmail': __('Automatic Email'), + 'tip': __('Tip:'), + 'selectAutomaticEmailsEventsConditionsHeading': __("Select %1s events conditions"), + 'sendAutomaticEmailWhenHeading': __('Send this %1s Automatic Email when...'), + 'automaticEmailActivated': __('Your %1s Automatic Email is now activated!'), + 'automaticEmailActivationFailed': __('Your %1s Automatic Email could not be activated, please check the settings.'), + 'automaticEmailEventOptionsNotConfigured': __('You need to configure email options before this email can be sent.'), + 'sentToXCustomers': __('Sent to %$1d customers'), + 'wooCommerceEmailsWarning': __('WooCommerce emails won’t be sent to new customers because the opt-in on checkout is disabled. Enable it so they can immediately get your emails after their first purchase.'), + 'wooCommerceEmailsWarningLink': __('Edit WooCommerce settings'), + }) %> +<% endblock %>