AfterMigrationNotice.php
2 years ago
BlackFridayNotice.php
2 months ago
ChangedTrackingNotice.php
3 years ago
DatabaseEngineNotice.php
1 year ago
DeprecatedFilterNotice.php
4 years ago
DisabledMailFunctionNotice.php
2 months ago
DisabledWPCronNotice.php
1 year ago
EmailWithInvalidSegmentNotice.php
3 years ago
HeadersAlreadySentNotice.php
2 months ago
InactiveSubscribersNotice.php
2 years ago
PHPVersionWarnings.php
2 months ago
PendingApprovalNotice.php
2 years ago
PermanentNotices.php
2 months ago
PremiumFeaturesAvailableNotice.php
2 years ago
SenderDomainAuthenticationNotices.php
5 months ago
SendingQueueBodyCleanupNotice.php
2 months ago
StuckPostNotificationNotice.php
2 months ago
UnauthorizedEmailInNewslettersNotice.php
5 months ago
UnauthorizedEmailNotice.php
5 months ago
WooCommerceVersionWarning.php
1 year ago
WordPressPlaygroundNotice.php
1 year ago
index.php
3 years ago
PendingApprovalNotice.php
99 lines
| 1 | <?php declare(strict_types = 1); |
| 2 | |
| 3 | namespace MailPoet\Util\Notices; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\Mailer\Mailer; |
| 9 | use MailPoet\Services\Bridge; |
| 10 | use MailPoet\Settings\SettingsController; |
| 11 | use MailPoet\Util\Helpers; |
| 12 | use MailPoet\WP\Notice as WPNotice; |
| 13 | |
| 14 | class PendingApprovalNotice { |
| 15 | |
| 16 | const OPTION_NAME = 'mailpoet-pending-approval-notice'; |
| 17 | |
| 18 | /** @var SettingsController */ |
| 19 | private $settings; |
| 20 | |
| 21 | public function __construct( |
| 22 | SettingsController $settings |
| 23 | ) { |
| 24 | $this->settings = $settings; |
| 25 | } |
| 26 | |
| 27 | public function init($shouldDisplay): ?string { |
| 28 | // We should display the notice if the user is using MSS and the subscription is not approved |
| 29 | if ( |
| 30 | $shouldDisplay |
| 31 | && $this->settings->get('mta.method') === Mailer::METHOD_MAILPOET |
| 32 | && $this->settings->get('mta.mailpoet_api_key_state') |
| 33 | && $this->settings->get('mta.mailpoet_api_key_state.state', null) === Bridge::KEY_VALID |
| 34 | && !$this->settings->get('mta.mailpoet_api_key_state.data.is_approved', false) |
| 35 | ) { |
| 36 | return $this->display(); |
| 37 | } |
| 38 | |
| 39 | return null; |
| 40 | } |
| 41 | |
| 42 | public function getPendingApprovalTitle(): string { |
| 43 | $message = __("MailPoet is [link]reviewing your subscription[/link].", 'mailpoet'); |
| 44 | return Helpers::replaceLinkTags( |
| 45 | $message, |
| 46 | 'https://kb.mailpoet.com/article/379-our-approval-process', |
| 47 | [ |
| 48 | 'target' => '_blank', |
| 49 | 'rel' => 'noreferrer', |
| 50 | ], |
| 51 | 'link' |
| 52 | ); |
| 53 | } |
| 54 | |
| 55 | public function getPendingApprovalBody(): string { |
| 56 | // translators: %s is the email subject, which will always be in English |
| 57 | $message = sprintf(__("You can use all MailPoet features and send [link1]email previews[/link1] to your [link2]authorized email addresses[/link2], but sending to your email list contacts is temporarily paused until we review your subscription. If you don't hear from us within 48 hours, please check the inbox and spam folders of your MailPoet account email for follow-up emails with the subject \"%s\" and reply, or [link3]contact us[/link3].", 'mailpoet'), 'Your MailPoet Subscription Review'); |
| 58 | $message = Helpers::replaceLinkTags( |
| 59 | $message, |
| 60 | 'https://kb.mailpoet.com/article/290-check-your-newsletter-before-sending-it', |
| 61 | [ |
| 62 | 'target' => '_blank', |
| 63 | 'rel' => 'noreferrer', |
| 64 | ], |
| 65 | 'link1' |
| 66 | ); |
| 67 | $message = Helpers::replaceLinkTags( |
| 68 | $message, |
| 69 | 'https://kb.mailpoet.com/article/266-how-to-add-an-authorized-email-address-as-the-from-address#how-to-authorize-an-email-address', |
| 70 | [ |
| 71 | 'target' => '_blank', |
| 72 | 'rel' => 'noreferrer', |
| 73 | ], |
| 74 | 'link2' |
| 75 | ); |
| 76 | $message = Helpers::replaceLinkTags( |
| 77 | $message, |
| 78 | 'https://www.mailpoet.com/support/', |
| 79 | [ |
| 80 | 'target' => '_blank', |
| 81 | 'rel' => 'noreferrer', |
| 82 | ], |
| 83 | 'link3' |
| 84 | ); |
| 85 | |
| 86 | return $message; |
| 87 | } |
| 88 | |
| 89 | public function getPendingApprovalMessage(): string { |
| 90 | return sprintf('%s %s', $this->getPendingApprovalTitle(), $this->getPendingApprovalBody()); |
| 91 | } |
| 92 | |
| 93 | private function display(): string { |
| 94 | $message = $this->getPendingApprovalMessage(); |
| 95 | WPNotice::displayWarning($message, '', self::OPTION_NAME); |
| 96 | return $message; |
| 97 | } |
| 98 | } |
| 99 |