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 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);
}
}