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
SendingQueueBodyCleanupNotice.php
56 lines
| 1 | <?php declare(strict_types = 1); |
| 2 | |
| 3 | namespace MailPoet\Util\Notices; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\Settings\SettingsController; |
| 9 | use MailPoet\Util\Helpers; |
| 10 | use MailPoet\WP\Functions as WPFunctions; |
| 11 | |
| 12 | class SendingQueueBodyCleanupNotice { |
| 13 | const OPTION_NAME = 'mailpoet_display_sending_queue_body_cleanup_notice'; |
| 14 | |
| 15 | /** @var SettingsController */ |
| 16 | private $settings; |
| 17 | |
| 18 | /** @var WPFunctions */ |
| 19 | private $wp; |
| 20 | |
| 21 | public function __construct( |
| 22 | SettingsController $settings, |
| 23 | WPFunctions $wp |
| 24 | ) { |
| 25 | $this->settings = $settings; |
| 26 | $this->wp = $wp; |
| 27 | } |
| 28 | |
| 29 | public function enable(): void { |
| 30 | $this->settings->set(self::OPTION_NAME, true); |
| 31 | } |
| 32 | |
| 33 | public function disable(): void { |
| 34 | $this->settings->set(self::OPTION_NAME, false); |
| 35 | } |
| 36 | |
| 37 | public function init(bool $shouldDisplay): ?string { |
| 38 | if ($shouldDisplay && $this->settings->get(self::OPTION_NAME, false)) { |
| 39 | return $this->display(); |
| 40 | } |
| 41 | return null; |
| 42 | } |
| 43 | |
| 44 | private function display(): string { |
| 45 | $settingsUrl = $this->wp->adminUrl('admin.php?page=mailpoet-settings#/advanced'); |
| 46 | $message = Helpers::replaceLinkTags( |
| 47 | __('MailPoet now includes a setting to automatically purge rendered email bodies from completed sends to reduce database size. By default, sends older than 30 days are purged. The "View in browser" link for purged emails will re-render from the original template. You can change this in [link]Settings → Advanced[/link].', 'mailpoet'), |
| 48 | $settingsUrl |
| 49 | ); |
| 50 | |
| 51 | $extraClasses = 'mailpoet-dismissible-notice is-dismissible'; |
| 52 | \MailPoet\WP\Notice::displayInfo($message, $extraClasses, self::OPTION_NAME); |
| 53 | return $message; |
| 54 | } |
| 55 | } |
| 56 |