AfterMigrationNotice.php
4 years ago
BlackFridayNotice.php
4 years ago
ChangedTrackingNotice.php
4 years ago
DeprecatedFilterNotice.php
3 years ago
EmailWithInvalidSegmentNotice.php
4 years ago
HeadersAlreadySentNotice.php
4 years ago
InactiveSubscribersNotice.php
4 years ago
PHPVersionWarnings.php
4 years ago
PermanentNotices.php
4 years ago
UnauthorizedEmailInNewslettersNotice.php
4 years ago
UnauthorizedEmailNotice.php
3 years ago
index.php
4 years ago
DeprecatedFilterNotice.php
53 lines
| 1 | <?php declare(strict_types = 1); |
| 2 | |
| 3 | namespace MailPoet\Util\Notices; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\Util\Helpers; |
| 9 | use MailPoet\WP\Functions as WPFunctions; |
| 10 | use MailPoet\WP\Notice; |
| 11 | |
| 12 | /** |
| 13 | * This can be removed after 2022-12-01 |
| 14 | */ |
| 15 | class DeprecatedFilterNotice { |
| 16 | const DISMISS_NOTICE_TIMEOUT_SECONDS = 15552000; // 6 months |
| 17 | const OPTION_NAME = 'dismissed-deprecated-filter-notice'; |
| 18 | |
| 19 | const DEPRECATED_FILTER_NAME = 'mailpoet_mailer_smtp_transport_agent'; |
| 20 | const NEW_FILTER_NAME = 'mailpoet_mailer_smtp_options'; |
| 21 | |
| 22 | /** @var WPFunctions */ |
| 23 | private $wp; |
| 24 | |
| 25 | public function __construct( |
| 26 | WPFunctions $wp |
| 27 | ) { |
| 28 | $this->wp = $wp; |
| 29 | } |
| 30 | |
| 31 | public function init($shouldDisplay): ?Notice { |
| 32 | if ($shouldDisplay && !$this->wp->getTransient(self::OPTION_NAME) && $this->wp->hasFilter('mailpoet_mailer_smtp_transport_agent')) { |
| 33 | return $this->display(); |
| 34 | } |
| 35 | return null; |
| 36 | } |
| 37 | |
| 38 | public function display(): Notice { |
| 39 | $message = Helpers::replaceLinkTags( |
| 40 | __('The <i>mailpoet_mailer_smtp_transport_agent</i> filter no longer works. Please replace it with <i>mailpoet_mailer_smtp_options</i>. Read more in [link]documentation[/link].', 'mailpoet'), |
| 41 | 'https://kb.mailpoet.com/article/193-tls-encryption-does-not-work', |
| 42 | ['target' => '_blank'] |
| 43 | ); |
| 44 | $extraClasses = 'mailpoet-dismissible-notice is-dismissible'; |
| 45 | |
| 46 | return Notice::displayWarning($message, $extraClasses, self::OPTION_NAME); |
| 47 | } |
| 48 | |
| 49 | public function disable(): void { |
| 50 | $this->wp->setTransient(self::OPTION_NAME, true, self::DISMISS_NOTICE_TIMEOUT_SECONDS); |
| 51 | } |
| 52 | } |
| 53 |