From c250d852f122a6210ae0876f0f4178bd4ad5b735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Tue, 28 Dec 2021 11:48:41 +0100 Subject: [PATCH] Make WooCommerce import check public [MAILPOET-4042] --- lib/Config/Changelog.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/Config/Changelog.php b/lib/Config/Changelog.php index 08dae037e9..2776f7365a 100644 --- a/lib/Config/Changelog.php +++ b/lib/Config/Changelog.php @@ -84,6 +84,16 @@ class Changelog { return $this->settings->get('version') === null; } + public function shouldShowWooCommerceListImportPage() { + if ($this->wp->applyFilters('mailpoet_skip_woocommerce_import_page', false)) { + return false; + } + return !$this->settings->get('woocommerce_import_screen_displayed') + && $this->wooCommerceHelper->isWooCommerceActive() + && $this->wooCommerceHelper->getOrdersCountCreatedBefore($this->settings->get('installed_at')) > 0 + && $this->wp->currentUserCan('administrator'); + } + public function isMp2MigrationInProgress() { return $this->mp2Migrator->isMigrationStartedAndNotCompleted(); } @@ -114,15 +124,9 @@ class Changelog { } private function checkWooCommerceListImportPage() { - if ($this->wp->applyFilters('mailpoet_skip_woocommerce_import_page', false)) { - return; - } if ( !in_array($_GET['page'], ['mailpoet-woocommerce-setup', 'mailpoet-welcome-wizard', 'mailpoet-migration']) - && !$this->settings->get('woocommerce_import_screen_displayed') - && $this->wooCommerceHelper->isWooCommerceActive() - && $this->wooCommerceHelper->getOrdersCountCreatedBefore($this->settings->get('installed_at')) > 0 - && $this->wp->currentUserCan('administrator') + && $this->shouldShowWooCommerceListImportPage() ) { $this->urlHelper->redirectTo($this->wp->adminUrl('admin.php?page=mailpoet-woocommerce-setup')); }