Move WP translation function from __construct
According to this post https://make.wordpress.org/core/2024/10/21/i18n-improvements-6-7/, we are currently doing_it_wrong MAILPOET-6298
This commit is contained in:
committed by
Oluwaseun Olorunsola
parent
1f21add146
commit
6ea5074649
@ -7,15 +7,11 @@ use MailPoet\HttpAwareException;
|
|||||||
|
|
||||||
class ErrorHandler {
|
class ErrorHandler {
|
||||||
/** @var string[] */
|
/** @var string[] */
|
||||||
private $defaultErrors;
|
private $defaultErrors = [];
|
||||||
|
|
||||||
public function __construct() {
|
|
||||||
$this->defaultErrors = [
|
|
||||||
Error::UNKNOWN => __('An unknown error occurred.', 'mailpoet'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function convertToResponse(\Throwable $e): ErrorResponse {
|
public function convertToResponse(\Throwable $e): ErrorResponse {
|
||||||
|
$this->defaultErrors[Error::UNKNOWN] = __('An unknown error occurred.', 'mailpoet');
|
||||||
|
|
||||||
if ($e instanceof Exception) {
|
if ($e instanceof Exception) {
|
||||||
$errors = $e->getErrors() ?: $this->defaultErrors;
|
$errors = $e->getErrors() ?: $this->defaultErrors;
|
||||||
$statusCode = $e instanceof HttpAwareException ? $e->getHttpStatusCode() : Response::STATUS_UNKNOWN;
|
$statusCode = $e instanceof HttpAwareException ? $e->getHttpStatusCode() : Response::STATUS_UNKNOWN;
|
||||||
|
@ -56,6 +56,13 @@ class Registry {
|
|||||||
$this->wordPress = $wordPress;
|
$this->wordPress = $wordPress;
|
||||||
$this->steps[$rootStep->getKey()] = $rootStep;
|
$this->steps[$rootStep->getKey()] = $rootStep;
|
||||||
|
|
||||||
|
$this->wordPress->addAction('init', [
|
||||||
|
$this,
|
||||||
|
'setupTemplateCategories',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setupTemplateCategories () {
|
||||||
$this->templateCategories = [
|
$this->templateCategories = [
|
||||||
'welcome' => new AutomationTemplateCategory('welcome', __('Welcome', 'mailpoet')),
|
'welcome' => new AutomationTemplateCategory('welcome', __('Welcome', 'mailpoet')),
|
||||||
'abandoned-cart' => new AutomationTemplateCategory('abandoned-cart', __('Abandoned Cart', 'mailpoet')),
|
'abandoned-cart' => new AutomationTemplateCategory('abandoned-cart', __('Abandoned Cart', 'mailpoet')),
|
||||||
|
@ -42,6 +42,13 @@ class TransactionalEmails {
|
|||||||
$this->template = $template;
|
$this->template = $template;
|
||||||
$this->woocommerceHelper = $woocommerceHelper;
|
$this->woocommerceHelper = $woocommerceHelper;
|
||||||
$this->newslettersRepository = $newslettersRepository;
|
$this->newslettersRepository = $newslettersRepository;
|
||||||
|
$this->wp->addAction('init', [
|
||||||
|
$this,
|
||||||
|
'setupEmailHeadings',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setupEmailHeadings() {
|
||||||
$this->emailHeadings = [
|
$this->emailHeadings = [
|
||||||
'new_account' => [
|
'new_account' => [
|
||||||
'option_name' => 'woocommerce_new_order_settings',
|
'option_name' => 'woocommerce_new_order_settings',
|
||||||
|
Reference in New Issue
Block a user