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
EmailWithInvalidSegmentNotice.php
48 lines
| 1 | <?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing |
| 2 | |
| 3 | namespace MailPoet\Util\Notices; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\Cron\Workers\SendingQueue\SendingQueue; |
| 9 | use MailPoet\WP\Functions as WPFunctions; |
| 10 | use MailPoet\WP\Notice; |
| 11 | |
| 12 | class EmailWithInvalidSegmentNotice { |
| 13 | const OPTION_NAME = SendingQueue::EMAIL_WITH_INVALID_SEGMENT_OPTION; |
| 14 | |
| 15 | /** @var WPFunctions */ |
| 16 | private $wp; |
| 17 | |
| 18 | public function __construct( |
| 19 | WPFunctions $wp |
| 20 | ) { |
| 21 | $this->wp = $wp; |
| 22 | } |
| 23 | |
| 24 | public function init($shouldDisplay) { |
| 25 | if (!$shouldDisplay || !$this->wp->getTransient(self::OPTION_NAME)) { |
| 26 | return; |
| 27 | } |
| 28 | |
| 29 | return $this->display($this->wp->getTransient(self::OPTION_NAME)); |
| 30 | } |
| 31 | |
| 32 | public function disable() { |
| 33 | $this->wp->deleteTransient(self::OPTION_NAME); |
| 34 | } |
| 35 | |
| 36 | private function display($newsletterSubject) { |
| 37 | $notice = sprintf( |
| 38 | // translators: %s is the subject of the newsletter. |
| 39 | __('You are sending “%s“ to the deleted list. To continue sending, please restore the list. Alternatively, delete the newsletter if you no longer want to keep sending it.', 'mailpoet'), |
| 40 | $this->wp->escHtml($newsletterSubject) |
| 41 | ); |
| 42 | $extraClasses = 'mailpoet-dismissible-notice is-dismissible'; |
| 43 | |
| 44 | Notice::displayError($notice, $extraClasses, self::OPTION_NAME, true); |
| 45 | return $notice; |
| 46 | } |
| 47 | } |
| 48 |