Files
piratepoet/lib/Util/Notices/PermanentNotices.php
Jan Jakeš b39dac75d6 Autofix number of newlines between methods
[MAILPOET-2715]
2020-02-19 19:12:53 +00:00

92 lines
2.7 KiB
PHP

<?php
namespace MailPoet\Util\Notices;
use MailPoet\Config\Menu;
use MailPoet\Settings\SettingsController;
use MailPoet\WP\Functions as WPFunctions;
class PermanentNotices {
/** @var WPFunctions */
private $wp;
/** @var PHPVersionWarnings */
private $phpVersionWarnings;
/** @var AfterMigrationNotice */
private $afterMigrationNotice;
/** @var UnauthorizedEmailNotice */
private $unauthorizedEmailsNotice;
/** @var UnauthorizedEmailInNewslettersNotice */
private $unauthorizedEmailsInNewslettersNotice;
/** @var InactiveSubscribersNotice */
private $inactiveSubscribersNotice;
/** @var BlackFridayNotice */
private $blackFridayNotice;
public function __construct(WPFunctions $wp) {
$this->wp = $wp;
$this->phpVersionWarnings = new PHPVersionWarnings();
$this->afterMigrationNotice = new AfterMigrationNotice();
$this->unauthorizedEmailsNotice = new UnauthorizedEmailNotice(SettingsController::getInstance(), $wp);
$this->unauthorizedEmailsInNewslettersNotice = new UnauthorizedEmailInNewslettersNotice(SettingsController::getInstance(), $wp);
$this->inactiveSubscribersNotice = new InactiveSubscribersNotice(SettingsController::getInstance(), $wp);
$this->blackFridayNotice = new BlackFridayNotice();
}
public function init() {
$excludeWizard = [
'mailpoet-welcome-wizard',
'mailpoet-woocommerce-list-import',
'mailpoet-revenue-tracking-permission',
];
$this->wp->addAction('wp_ajax_dismissed_notice_handler', [
$this,
'ajaxDismissNoticeHandler',
]);
$this->phpVersionWarnings->init(
phpversion(),
Menu::isOnMailPoetAdminPage($excludeWizard)
);
$this->afterMigrationNotice->init(
Menu::isOnMailPoetAdminPage($excludeWizard)
);
$this->unauthorizedEmailsNotice->init(
Menu::isOnMailPoetAdminPage($excludeWizard)
);
$this->unauthorizedEmailsInNewslettersNotice->init(
Menu::isOnMailPoetAdminPage($exclude = null, $pageId = 'mailpoet-newsletters')
);
$this->inactiveSubscribersNotice->init(
Menu::isOnMailPoetAdminPage($excludeWizard)
);
$this->blackFridayNotice->init(
Menu::isOnMailPoetAdminPage($excludeWizard)
);
}
public function ajaxDismissNoticeHandler() {
if (!isset($_POST['type'])) return;
switch ($_POST['type']) {
case (PHPVersionWarnings::OPTION_NAME):
$this->phpVersionWarnings->disable();
break;
case (AfterMigrationNotice::OPTION_NAME):
$this->afterMigrationNotice->disable();
break;
case (BlackFridayNotice::OPTION_NAME):
$this->blackFridayNotice->disable();
break;
case (InactiveSubscribersNotice::OPTION_NAME):
$this->inactiveSubscribersNotice->disable();
break;
}
}
}