Migration_20221028_105818_App.php
3 years ago
Migration_20230109_144830.php
3 years ago
Migration_20230131_121621.php
3 years ago
Migration_20230419_080000.php
3 years ago
Migration_20230425_211517.php
3 years ago
Migration_20230712_180341.php
3 years ago
Migration_20230803_200413_App.php
2 years ago
Migration_20230825_093531_App.php
1 year ago
Migration_20231128_120355_App.php
1 year ago
Migration_20240202_130053_App.php
2 years ago
Migration_20240207_105912_App.php
1 year ago
Migration_20240322_110443_App.php
2 years ago
Migration_20240730_212419_App.php
2 years ago
Migration_20241015_105511_App.php
1 year ago
Migration_20241128_114257_App.php
1 year ago
Migration_20250120_094614_App.php
1 year ago
Migration_20250501_114655_App.php
11 months ago
Migration_20260421_155908_App.php
3 months ago
Migration_20260515_120000_App.php
3 months ago
Migration_20260623_120000_App.php
1 month ago
Migration_20260805_120000_App.php
1 week ago
index.php
3 years ago
Migration_20230131_121621.php
45 lines
| 1 | <?php declare(strict_types = 1); |
| 2 | |
| 3 | namespace MailPoet\Migrations\App; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\Homepage\HomepageDataController; |
| 9 | use MailPoet\Migrator\AppMigration; |
| 10 | use MailPoet\Settings\SettingsController; |
| 11 | use MailPoet\WooCommerce\Helper; |
| 12 | |
| 13 | class Migration_20230131_121621 extends AppMigration { |
| 14 | /** |
| 15 | * This migration detect whether we should display Task List and Product Discovery sections |
| 16 | * on the homepage for the old users. |
| 17 | */ |
| 18 | public function run(): void { |
| 19 | // Hide task list for users who installed the plugin more than 2 weeks ago |
| 20 | $settings = $this->container->get(SettingsController::class); |
| 21 | $installedAt = strtotime($settings->get('installed_at', date('Y-m-d H:i:s'))); |
| 22 | $twoWeeksAgo = strtotime('-2 weeks'); |
| 23 | if ($installedAt < $twoWeeksAgo) { |
| 24 | $settings->set('homepage.task_list_dismissed', true); |
| 25 | } |
| 26 | |
| 27 | // Hide product discovery for users who completed all tasks |
| 28 | $homepageDataController = $this->container->get(HomepageDataController::class); |
| 29 | $wooCommerceHelper = $this->container->get(Helper::class); |
| 30 | $homepageData = $homepageDataController->getPageData(); |
| 31 | $productDiscoveryStatus = $homepageData['productDiscoveryStatus']; |
| 32 | if ($wooCommerceHelper->isWooCommerceActive()) { |
| 33 | $productDiscoveryIsComplete = $productDiscoveryStatus['addSubscriptionForm'] && |
| 34 | $productDiscoveryStatus['setUpWelcomeCampaign'] && |
| 35 | $productDiscoveryStatus['setUpAbandonedCartEmail'] && |
| 36 | $productDiscoveryStatus['brandWooEmails']; |
| 37 | } else { |
| 38 | $productDiscoveryIsComplete = $productDiscoveryStatus['addSubscriptionForm'] && |
| 39 | $productDiscoveryStatus['setUpWelcomeCampaign'] && |
| 40 | $productDiscoveryStatus['sendFirstNewsletter']; |
| 41 | } |
| 42 | $settings->set('homepage.product_discovery_dismissed', $productDiscoveryIsComplete); |
| 43 | } |
| 44 | } |
| 45 |