Files
piratepoet/mailpoet/lib/Util/Notices/DatabaseEngineNotice.php
Pavel Dohnal 64c75fd0ca Create a new class for database notice
[MAILPOET-6184]
2024-08-22 14:33:54 +02:00

37 lines
776 B
PHP

<?php declare(strict_types = 1);
namespace MailPoet\Util\Notices;
use MailPoet\WP\Functions as WPFunctions;
use MailPoet\WP\Notice;
class DatabaseEngineNotice {
const OPTION_NAME = 'database-engine-notice';
const DISMISS_NOTICE_TIMEOUT_SECONDS = 15_552_000; // 6 months
/** @var WPFunctions */
private $wp;
public function __construct(
WPFunctions $wp
) {
$this->wp = $wp;
}
public function init($shouldDisplay): ?Notice {
if (!$shouldDisplay || $this->wp->getTransient(self::OPTION_NAME)) {
return null;
}
return $this->display();
}
private function display(): ?Notice {
return null;
}
public function disable() {
$this->wp->setTransient(self::OPTION_NAME, true, self::DISMISS_NOTICE_TIMEOUT_SECONDS);
}
}