Initialise hooks early
[MAILPOET-2307]
This commit is contained in:
committed by
Jack Kitterhing
parent
198b04fe24
commit
952b9d7dd4
@ -85,6 +85,9 @@ class Hooks {
|
||||
$this->setupSubscriptionEvents();
|
||||
$this->setupWooCommerceSubscriptionEvents();
|
||||
$this->setupPostNotifications();
|
||||
}
|
||||
|
||||
function initEarlyHooks() {
|
||||
$this->setupMailer();
|
||||
}
|
||||
|
||||
@ -189,6 +192,10 @@ class Hooks {
|
||||
$this->wordpress_mailer_replacer,
|
||||
'replaceWordPressMailer',
|
||||
]);
|
||||
$this->wp->addAction('lostpassword_post', [
|
||||
$this->wordpress_mailer_replacer,
|
||||
'replaceWordPressMailer',
|
||||
]);
|
||||
}
|
||||
|
||||
function setupWooCommerceSubscriptionEvents() {
|
||||
|
@ -158,6 +158,7 @@ class Initializer {
|
||||
new DeferredAdminNotices,
|
||||
'printAndClean',
|
||||
]);
|
||||
$this->hooks->initEarlyHooks();
|
||||
}
|
||||
|
||||
function checkRequirements() {
|
||||
|
@ -38,7 +38,7 @@ class WordPressMailer extends \PHPMailer {
|
||||
if ($result['response']) {
|
||||
return true;
|
||||
} else {
|
||||
throw new \phpmailerException($result['error']);
|
||||
throw new \phpmailerException($result['error']->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ if (!class_exists('PHPMailer')) {
|
||||
}
|
||||
|
||||
use MailPoet\Mailer\Mailer;
|
||||
use MailPoet\Mailer\MailerError;
|
||||
|
||||
class WordpressMailerTest extends \MailPoetTest {
|
||||
|
||||
@ -95,7 +96,7 @@ class WordpressMailerTest extends \MailPoetTest {
|
||||
$mailer
|
||||
->expects($this->once())
|
||||
->method('send')
|
||||
->willReturn(['response' => false, 'error' => 'Big Error']);
|
||||
->willReturn(['response' => false, 'error' => new MailerError('send', 1, 'Big Error')]);
|
||||
$wpMailer = new WordPressMailer($mailer);
|
||||
$wpMailer->addAddress('email@example.com');
|
||||
$wpMailer->Body = 'body';
|
||||
|
Reference in New Issue
Block a user