AfterMigrationNotice.php
4 years ago
BlackFridayNotice.php
4 years ago
ChangedTrackingNotice.php
4 years ago
DeprecatedFilterNotice.php
3 years ago
EmailWithInvalidSegmentNotice.php
4 years ago
HeadersAlreadySentNotice.php
4 years ago
InactiveSubscribersNotice.php
4 years ago
PHPVersionWarnings.php
4 years ago
PermanentNotices.php
4 years ago
UnauthorizedEmailInNewslettersNotice.php
4 years ago
UnauthorizedEmailNotice.php
3 years ago
index.php
4 years ago
PermanentNotices.php
139 lines
| 1 | <?php |
| 2 | |
| 3 | namespace MailPoet\Util\Notices; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\Config\Menu; |
| 9 | use MailPoet\Settings\SettingsController; |
| 10 | use MailPoet\Settings\TrackingConfig; |
| 11 | use MailPoet\WP\Functions as WPFunctions; |
| 12 | |
| 13 | class PermanentNotices { |
| 14 | |
| 15 | /** @var WPFunctions */ |
| 16 | private $wp; |
| 17 | |
| 18 | /** @var PHPVersionWarnings */ |
| 19 | private $phpVersionWarnings; |
| 20 | |
| 21 | /** @var AfterMigrationNotice */ |
| 22 | private $afterMigrationNotice; |
| 23 | |
| 24 | /** @var UnauthorizedEmailNotice */ |
| 25 | private $unauthorizedEmailsNotice; |
| 26 | |
| 27 | /** @var UnauthorizedEmailInNewslettersNotice */ |
| 28 | private $unauthorizedEmailsInNewslettersNotice; |
| 29 | |
| 30 | /** @var InactiveSubscribersNotice */ |
| 31 | private $inactiveSubscribersNotice; |
| 32 | |
| 33 | /** @var BlackFridayNotice */ |
| 34 | private $blackFridayNotice; |
| 35 | |
| 36 | /** @var HeadersAlreadySentNotice */ |
| 37 | private $headersAlreadySentNotice; |
| 38 | |
| 39 | /** @var EmailWithInvalidSegmentNotice */ |
| 40 | private $emailWithInvalidListNotice; |
| 41 | |
| 42 | /** @var ChangedTrackingNotice */ |
| 43 | private $changedTrackingNotice; |
| 44 | |
| 45 | /** @var DeprecatedFilterNotice */ |
| 46 | private $deprecatedFilterNotice; |
| 47 | |
| 48 | public function __construct( |
| 49 | WPFunctions $wp, |
| 50 | TrackingConfig $trackingConfig, |
| 51 | SettingsController $settings |
| 52 | ) { |
| 53 | $this->wp = $wp; |
| 54 | $this->phpVersionWarnings = new PHPVersionWarnings(); |
| 55 | $this->afterMigrationNotice = new AfterMigrationNotice(); |
| 56 | $this->unauthorizedEmailsNotice = new UnauthorizedEmailNotice($wp, $settings); |
| 57 | $this->unauthorizedEmailsInNewslettersNotice = new UnauthorizedEmailInNewslettersNotice($settings, $wp); |
| 58 | $this->inactiveSubscribersNotice = new InactiveSubscribersNotice($settings, $wp); |
| 59 | $this->blackFridayNotice = new BlackFridayNotice(); |
| 60 | $this->headersAlreadySentNotice = new HeadersAlreadySentNotice($settings, $trackingConfig, $wp); |
| 61 | $this->emailWithInvalidListNotice = new EmailWithInvalidSegmentNotice($wp); |
| 62 | $this->changedTrackingNotice = new ChangedTrackingNotice($wp); |
| 63 | $this->deprecatedFilterNotice = new DeprecatedFilterNotice($wp); |
| 64 | } |
| 65 | |
| 66 | public function init() { |
| 67 | $excludeWizard = [ |
| 68 | 'mailpoet-welcome-wizard', |
| 69 | 'mailpoet-woocommerce-setup', |
| 70 | ]; |
| 71 | $this->wp->addAction('wp_ajax_dismissed_notice_handler', [ |
| 72 | $this, |
| 73 | 'ajaxDismissNoticeHandler', |
| 74 | ]); |
| 75 | |
| 76 | $this->phpVersionWarnings->init( |
| 77 | phpversion(), |
| 78 | Menu::isOnMailPoetAdminPage($excludeWizard) |
| 79 | ); |
| 80 | $this->afterMigrationNotice->init( |
| 81 | Menu::isOnMailPoetAdminPage($excludeWizard) |
| 82 | ); |
| 83 | $this->unauthorizedEmailsNotice->init( |
| 84 | Menu::isOnMailPoetAdminPage($excludeWizard) |
| 85 | ); |
| 86 | $this->unauthorizedEmailsInNewslettersNotice->init( |
| 87 | Menu::isOnMailPoetAdminPage($exclude = null, $pageId = 'mailpoet-newsletters') |
| 88 | ); |
| 89 | $this->inactiveSubscribersNotice->init( |
| 90 | Menu::isOnMailPoetAdminPage($excludeWizard) |
| 91 | ); |
| 92 | $this->blackFridayNotice->init( |
| 93 | Menu::isOnMailPoetAdminPage($excludeWizard) |
| 94 | ); |
| 95 | $this->headersAlreadySentNotice->init( |
| 96 | Menu::isOnMailPoetAdminPage($excludeWizard) |
| 97 | ); |
| 98 | $this->emailWithInvalidListNotice->init( |
| 99 | Menu::isOnMailPoetAdminPage($exclude = null, $pageId = 'mailpoet-newsletters') |
| 100 | ); |
| 101 | $this->changedTrackingNotice->init( |
| 102 | Menu::isOnMailPoetAdminPage($excludeWizard) |
| 103 | ); |
| 104 | $this->deprecatedFilterNotice->init( |
| 105 | Menu::isOnMailPoetAdminPage($excludeWizard) |
| 106 | ); |
| 107 | } |
| 108 | |
| 109 | public function ajaxDismissNoticeHandler() { |
| 110 | if (!isset($_POST['type'])) return; |
| 111 | switch ($_POST['type']) { |
| 112 | case (PHPVersionWarnings::OPTION_NAME): |
| 113 | $this->phpVersionWarnings->disable(); |
| 114 | break; |
| 115 | case (AfterMigrationNotice::OPTION_NAME): |
| 116 | $this->afterMigrationNotice->disable(); |
| 117 | break; |
| 118 | case (BlackFridayNotice::OPTION_NAME): |
| 119 | $this->blackFridayNotice->disable(); |
| 120 | break; |
| 121 | case (HeadersAlreadySentNotice::OPTION_NAME): |
| 122 | $this->headersAlreadySentNotice->disable(); |
| 123 | break; |
| 124 | case (InactiveSubscribersNotice::OPTION_NAME): |
| 125 | $this->inactiveSubscribersNotice->disable(); |
| 126 | break; |
| 127 | case (EmailWithInvalidSegmentNotice::OPTION_NAME): |
| 128 | $this->emailWithInvalidListNotice->disable(); |
| 129 | break; |
| 130 | case (ChangedTrackingNotice::OPTION_NAME): |
| 131 | $this->changedTrackingNotice->disable(); |
| 132 | break; |
| 133 | case (DeprecatedFilterNotice::OPTION_NAME): |
| 134 | $this->deprecatedFilterNotice->disable(); |
| 135 | break; |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 |