Make WooCommerce import check public

[MAILPOET-4042]
This commit is contained in:
Ján Mikláš
2021-12-28 11:48:41 +01:00
committed by Veljko V
parent 37fa9203a2
commit c250d852f1

View File

@@ -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'));
}