diff --git a/mailpoet/lib/API/JSON/ErrorHandler.php b/mailpoet/lib/API/JSON/ErrorHandler.php index dd935471b9..693476f1fd 100644 --- a/mailpoet/lib/API/JSON/ErrorHandler.php +++ b/mailpoet/lib/API/JSON/ErrorHandler.php @@ -7,15 +7,11 @@ use MailPoet\HttpAwareException; class ErrorHandler { /** @var string[] */ - private $defaultErrors; - - public function __construct() { - $this->defaultErrors = [ - Error::UNKNOWN => __('An unknown error occurred.', 'mailpoet'), - ]; - } + private $defaultErrors = []; public function convertToResponse(\Throwable $e): ErrorResponse { + $this->defaultErrors[Error::UNKNOWN] = __('An unknown error occurred.', 'mailpoet'); + if ($e instanceof Exception) { $errors = $e->getErrors() ?: $this->defaultErrors; $statusCode = $e instanceof HttpAwareException ? $e->getHttpStatusCode() : Response::STATUS_UNKNOWN; diff --git a/mailpoet/lib/Automation/Engine/Registry.php b/mailpoet/lib/Automation/Engine/Registry.php index 0cf9fc6631..ce0715b942 100644 --- a/mailpoet/lib/Automation/Engine/Registry.php +++ b/mailpoet/lib/Automation/Engine/Registry.php @@ -56,6 +56,13 @@ class Registry { $this->wordPress = $wordPress; $this->steps[$rootStep->getKey()] = $rootStep; + $this->wordPress->addAction('init', [ + $this, + 'setupTemplateCategories', + ]); + } + + public function setupTemplateCategories () { $this->templateCategories = [ 'welcome' => new AutomationTemplateCategory('welcome', __('Welcome', 'mailpoet')), 'abandoned-cart' => new AutomationTemplateCategory('abandoned-cart', __('Abandoned Cart', 'mailpoet')), diff --git a/mailpoet/lib/WooCommerce/TransactionalEmails.php b/mailpoet/lib/WooCommerce/TransactionalEmails.php index 7d0e800f9f..31ec946d4e 100644 --- a/mailpoet/lib/WooCommerce/TransactionalEmails.php +++ b/mailpoet/lib/WooCommerce/TransactionalEmails.php @@ -42,6 +42,13 @@ class TransactionalEmails { $this->template = $template; $this->woocommerceHelper = $woocommerceHelper; $this->newslettersRepository = $newslettersRepository; + $this->wp->addAction('init', [ + $this, + 'setupEmailHeadings', + ]); + } + + public function setupEmailHeadings() { $this->emailHeadings = [ 'new_account' => [ 'option_name' => 'woocommerce_new_order_settings',