Fix dismissing shortcodes notice

[MAILPOET-3672]
This commit is contained in:
Rostislav Wolny
2021-06-29 15:21:07 +02:00
committed by Veljko V
parent dc393575ad
commit b71f8defc8
2 changed files with 10 additions and 3 deletions

View File

@@ -13,8 +13,15 @@ class DeprecatedShortcodeNotice {
const DISMISS_NOTICE_TIMEOUT_SECONDS = 15552000; // 6 months const DISMISS_NOTICE_TIMEOUT_SECONDS = 15552000; // 6 months
const OPTION_NAME = 'dismissed-deprecated-shortcode-notice'; const OPTION_NAME = 'dismissed-deprecated-shortcode-notice';
/** @var WPFunctions */
private $wp;
public function __construct(WPFunctions $wp) {
$this->wp = $wp;
}
public function init($shouldDisplay) { public function init($shouldDisplay) {
if ($shouldDisplay && $this->isUsingDeprecatedShortcode()) { if ($shouldDisplay && !$this->wp->getTransient(self::OPTION_NAME) && $this->isUsingDeprecatedShortcode()) {
return $this->display(); return $this->display();
} }
return null; return null;
@@ -53,6 +60,6 @@ class DeprecatedShortcodeNotice {
} }
public function disable() { 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);
} }
} }

View File

@@ -47,7 +47,7 @@ class PermanentNotices {
$this->inactiveSubscribersNotice = new InactiveSubscribersNotice(SettingsController::getInstance(), $wp); $this->inactiveSubscribersNotice = new InactiveSubscribersNotice(SettingsController::getInstance(), $wp);
$this->blackFridayNotice = new BlackFridayNotice(); $this->blackFridayNotice = new BlackFridayNotice();
$this->headersAlreadySentNotice = new HeadersAlreadySentNotice(SettingsController::getInstance(), $wp); $this->headersAlreadySentNotice = new HeadersAlreadySentNotice(SettingsController::getInstance(), $wp);
$this->deprecatedShortcodeNotice = new DeprecatedShortcodeNotice(); $this->deprecatedShortcodeNotice = new DeprecatedShortcodeNotice($wp);
$this->emailWithInvalidListNotice = new EmailWithInvalidSegmentNotice($wp); $this->emailWithInvalidListNotice = new EmailWithInvalidSegmentNotice($wp);
} }