From b71f8defc818bf1fd378738dcd33e6f68ff02eee Mon Sep 17 00:00:00 2001 From: Rostislav Wolny Date: Tue, 29 Jun 2021 15:21:07 +0200 Subject: [PATCH] Fix dismissing shortcodes notice [MAILPOET-3672] --- lib/Util/Notices/DeprecatedShortcodeNotice.php | 11 +++++++++-- lib/Util/Notices/PermanentNotices.php | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/Util/Notices/DeprecatedShortcodeNotice.php b/lib/Util/Notices/DeprecatedShortcodeNotice.php index 2d097f7b1b..37799036c6 100644 --- a/lib/Util/Notices/DeprecatedShortcodeNotice.php +++ b/lib/Util/Notices/DeprecatedShortcodeNotice.php @@ -13,8 +13,15 @@ class DeprecatedShortcodeNotice { const DISMISS_NOTICE_TIMEOUT_SECONDS = 15552000; // 6 months const OPTION_NAME = 'dismissed-deprecated-shortcode-notice'; + /** @var WPFunctions */ + private $wp; + + public function __construct(WPFunctions $wp) { + $this->wp = $wp; + } + public function init($shouldDisplay) { - if ($shouldDisplay && $this->isUsingDeprecatedShortcode()) { + if ($shouldDisplay && !$this->wp->getTransient(self::OPTION_NAME) && $this->isUsingDeprecatedShortcode()) { return $this->display(); } return null; @@ -53,6 +60,6 @@ class DeprecatedShortcodeNotice { } public function disable() { - WPFunctions::get()->setTransient(self::OPTION_NAME, true, self::DISMISS_NOTICE_TIMEOUT_SECONDS); + $this->wp->setTransient(self::OPTION_NAME, true, self::DISMISS_NOTICE_TIMEOUT_SECONDS); } } diff --git a/lib/Util/Notices/PermanentNotices.php b/lib/Util/Notices/PermanentNotices.php index b4544a6e36..002cb984f3 100644 --- a/lib/Util/Notices/PermanentNotices.php +++ b/lib/Util/Notices/PermanentNotices.php @@ -47,7 +47,7 @@ class PermanentNotices { $this->inactiveSubscribersNotice = new InactiveSubscribersNotice(SettingsController::getInstance(), $wp); $this->blackFridayNotice = new BlackFridayNotice(); $this->headersAlreadySentNotice = new HeadersAlreadySentNotice(SettingsController::getInstance(), $wp); - $this->deprecatedShortcodeNotice = new DeprecatedShortcodeNotice(); + $this->deprecatedShortcodeNotice = new DeprecatedShortcodeNotice($wp); $this->emailWithInvalidListNotice = new EmailWithInvalidSegmentNotice($wp); }