Move Mailer error tests to unit [MAILPOET-2009]

This commit is contained in:
wxa
2019-04-25 11:10:29 +03:00
committed by M. Shull
parent f2e0dc7d2f
commit 994fae79d2
14 changed files with 59 additions and 24 deletions

View File

@@ -92,20 +92,20 @@ class MailPoetMapper {
private function getUnauthorizedEmailMessage($sender, $newsletter) {
$email = $sender ? $sender['from_email'] : null;
if ($email && (new FreeDomains())->isEmailOnFreeDomain($email)) {
$message = '<p>' . sprintf(__('The MailPoet Sending Service cant send email with the email address <i>%s</i>. You need to use an address like <i>you@yourdomain.com</i>.', 'mailpoet'), $email) . '</p>';
$message = '<p>' . sprintf(WPFunctions::get()->__('The MailPoet Sending Service cant send email with the email address <i>%s</i>. You need to use an address like <i>you@yourdomain.com</i>.', 'mailpoet'), $email) . '</p>';
$message .= '<p>';
if ($newsletter && $newsletter['id']) {
$message .= '<a class="button button-primary" href="admin.php?page=mailpoet-newsletters#/send/' . $newsletter['id'] .'">';
} else {
$message .= '<a class="button button-primary" href="admin.php?page=mailpoet-settings">';
}
$message .= __('Change my email address', 'mailpoet');
$message .= WPFunctions::get()->__('Change my email address', 'mailpoet');
$message .= '</a>';
} else {
$message = sprintf(__('<p>The MailPoet Sending Service did not send your latest email because the address <i>%s</i> is not yet authorized.</p>', 'mailpoet'), $email ?: __('Unknown address'));
$message = sprintf(WPFunctions::get()->__('<p>The MailPoet Sending Service did not send your latest email because the address <i>%s</i> is not yet authorized.</p>', 'mailpoet'), $email ?: WPFunctions::get()->__('Unknown address'));
$message .= '<p>';
$message .= Helpers::replaceLinkTags(
__('[link]Authorize your email in your account now.[/link]', 'mailpoet'),
WPFunctions::get()->__('[link]Authorize your email in your account now.[/link]', 'mailpoet'),
'https://account.mailpoet.com/authorization',
array(
'class' => 'button button-primary',
@@ -114,15 +114,15 @@ class MailPoetMapper {
)
);
}
$message .= ' &nbsp; <button class="button js-button-resume-sending">' . __('Resume sending', 'mailpoet') . '</button>';
$message .= ' &nbsp; <button class="button js-button-resume-sending">' . WPFunctions::get()->__('Resume sending', 'mailpoet') . '</button>';
$message .= '</p>';
$message .= "<script>jQuery('.js-button-resume-sending').on('click', function() { MailPoet.Ajax.post({ api_version: window.mailpoet_api_version, endpoint: 'mailer', action: 'resumeSending' }).done(function() { jQuery('.js-error-unauthorized-email').slideUp(); MailPoet.Notice.success('" . __('Sending has been resumed.') . "'); if (window.mailpoet_listing) { window.mailpoet_listing.forceUpdate(); }}).fail(function(response) { if (response.errors.length > 0) { MailPoet.Notice.error(response.errors.map(function(error) { return error.message }), { scroll: true }); }}); })</script>";
$message .= "<script>jQuery('.js-button-resume-sending').on('click', function() { MailPoet.Ajax.post({ api_version: window.mailpoet_api_version, endpoint: 'mailer', action: 'resumeSending' }).done(function() { jQuery('.js-error-unauthorized-email').slideUp(); MailPoet.Notice.success('" . WPFunctions::get()->__('Sending has been resumed.') . "'); if (window.mailpoet_listing) { window.mailpoet_listing.forceUpdate(); }}).fail(function(response) { if (response.errors.length > 0) { MailPoet.Notice.error(response.errors.map(function(error) { return error.message }), { scroll: true }); }}); })</script>";
return $message;
}
private function getAccountBannedMessage() {
return Helpers::replaceLinkTags(
__('You currently are not permitted to send any emails with MailPoet Sending Service, which may have happened due to poor deliverability. Please [link]contact our support team[/link] to resolve the issue.', 'mailpoet'),
WPFunctions::get()->__('You currently are not permitted to send any emails with MailPoet Sending Service, which may have happened due to poor deliverability. Please [link]contact our support team[/link] to resolve the issue.', 'mailpoet'),
'https://www.mailpoet.com/support/',
array(
'target' => '_blank',