Hide inactive subscribers notice behind a feture flag

[MAILPOET-2088]
This commit is contained in:
Jan Jakeš
2019-05-31 15:40:16 +02:00
committed by M. Shull
parent 74a4ff5a2f
commit 21e3c5b1e9
2 changed files with 10 additions and 2 deletions

View File

@ -10,12 +10,14 @@ class FeaturesController {
// const FEATURE_NAME_OF_FEATURE = 'name-of-feature';
const FEATURE_DISPLAY_WOOCOMMERCE_REVENUES = 'display-woocommerce-revenues'; // may also have 'display_revenues' setting
const FEATURE_ABANDONED_SHOPPING_CART = 'abandoned-shopping-cart';
const FEATURE_INACTIVE_SUBSCRIBERS_NOTICE = 'inactive-subscribers-notice';
// Define feature defaults in the array below in the following form:
// self::FEATURE_NAME_OF_FEATURE => true,
private $defaults = [
self::FEATURE_DISPLAY_WOOCOMMERCE_REVENUES => false,
self::FEATURE_ABANDONED_SHOPPING_CART => false,
self::FEATURE_INACTIVE_SUBSCRIBERS_NOTICE => false,
];
/** @var array */

View File

@ -3,6 +3,7 @@
namespace MailPoet\Util\Notices;
use MailPoet\Config\Menu;
use MailPoet\Features\FeaturesController;
use MailPoet\Settings\SettingsController;
use MailPoet\WP\Functions as WPFunctions;
@ -29,7 +30,10 @@ class PermanentNotices {
/** @var InactiveSubscribersNotice */
private $inactive_subscribers_notice;
public function __construct(WPFunctions $wp) {
/** @var FeaturesController */
private $features_controller;
public function __construct(WPFunctions $wp, FeaturesController $features_controller) {
$this->wp = $wp;
$this->php_version_warnings = new PHPVersionWarnings();
$this->after_migration_notice = new AfterMigrationNotice();
@ -37,6 +41,7 @@ class PermanentNotices {
$this->unauthorized_emails_notice = new UnauthorizedEmailNotice(new SettingsController, $wp);
$this->unauthorized_emails_in_newsletters_notice = new UnauthorizedEmailInNewslettersNotice(new SettingsController, $wp);
$this->inactive_subscribers_notice = new InactiveSubscribersNotice(new SettingsController, $wp);
$this->features_controller = $features_controller;
}
public function init() {
@ -59,7 +64,8 @@ class PermanentNotices {
Menu::isOnMailPoetAdminPage($exclude = null, $page_id = 'mailpoet-newsletters')
);
$this->inactive_subscribers_notice->init(
Menu::isOnMailPoetAdminPage($exclude = ['mailpoet-welcome-wizard'])
$this->features_controller->isSupported(FeaturesController::FEATURE_INACTIVE_SUBSCRIBERS_NOTICE)
&& Menu::isOnMailPoetAdminPage($exclude = ['mailpoet-welcome-wizard'])
);
$this->discounts_announcement->init(
empty($_GET['page'])