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
BlackFridayNotice.php
46 lines
| 1 | <?php |
| 2 | |
| 3 | namespace MailPoet\Util\Notices; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\Models\Subscriber; |
| 9 | use MailPoet\WP\Functions as WPFunctions; |
| 10 | use MailPoet\WP\Notice as WPNotice; |
| 11 | |
| 12 | class BlackFridayNotice { |
| 13 | |
| 14 | const OPTION_NAME = 'dismissed-black-friday-notice'; |
| 15 | const DISMISS_NOTICE_TIMEOUT_SECONDS = 2592000; // 30 days |
| 16 | |
| 17 | public function init($shouldDisplay) { |
| 18 | $shouldDisplay = $shouldDisplay |
| 19 | && (time() <= strtotime('2021-11-30 12:00:00')) |
| 20 | && (time() >= strtotime('2021-11-24 12:00:00')) |
| 21 | && !get_transient(self::OPTION_NAME); |
| 22 | if ($shouldDisplay) { |
| 23 | $this->display(); |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | private function display() { |
| 28 | $subscribers = Subscriber |
| 29 | ::whereNull('deleted_at') |
| 30 | ->count(); |
| 31 | $header = '<h3 class="mailpoet-h3">' . __('Save big on MailPoet – 40% off this Black Friday', 'mailpoet') . '</h3>'; |
| 32 | $body = '<h5 class="mailpoet-h5">' . __('Our biggest ever sale is here! Save 40% on all annual plans and licenses until 8 am UTC, November 30. Terms and conditions apply.', 'mailpoet') . '</h5>'; |
| 33 | $link = "<p><a href='https://account.mailpoet.com/?s=$subscribers' class='mailpoet-button button-primary' target='_blank'>" |
| 34 | . __('Shop now', 'mailpoet') |
| 35 | . '</a></p>'; |
| 36 | |
| 37 | $extraClasses = 'mailpoet-dismissible-notice is-dismissible'; |
| 38 | |
| 39 | WPNotice::displaySuccess($header . $body . $link, $extraClasses, self::OPTION_NAME, false); |
| 40 | } |
| 41 | |
| 42 | public function disable() { |
| 43 | WPFunctions::get()->setTransient(self::OPTION_NAME, true, self::DISMISS_NOTICE_TIMEOUT_SECONDS); |
| 44 | } |
| 45 | } |
| 46 |