From 0eb7e3d001cee2984e0a12f1b2d8acc0573ca3cb Mon Sep 17 00:00:00 2001 From: Vasily Belolapotkov Date: Mon, 20 Sep 2021 15:03:35 +0300 Subject: [PATCH 01/18] Bump min required WC version to 5.5 --- changelog.txt | 1 + readme.txt | 3 ++- woocommerce-payments.php | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/changelog.txt b/changelog.txt index d124186149d..307b151e596 100644 --- a/changelog.txt +++ b/changelog.txt @@ -7,6 +7,7 @@ * Fix - Fixed missing file error for removed CSS file. * Add - Currency deletion confirmation modal for currencies that are bound to an UPE method. * Fix - Currency switcher does not affect order confirmation screen prices. +* Update - Bump minimum supported version of WooCommerce from 5.4 to 5.5. = 3.0.0 - 2021-09-16 = * Add - Download deposits report in CSV. diff --git a/readme.txt b/readme.txt index 750b86ae137..39edf3227d2 100644 --- a/readme.txt +++ b/readme.txt @@ -39,7 +39,7 @@ Our global support team is available to answer questions you may have about WooC = Requirements = * WordPress 5.6 or newer. -* WooCommerce 5.4 or newer. +* WooCommerce 5.5 or newer. * PHP version 7.0 or newer. PHP 7.2 or newer is recommended. = Try it now = @@ -105,6 +105,7 @@ Please note that our support for the checkout block is still experimental and th * Fix - Fixed missing file error for removed CSS file. * Add - Currency deletion confirmation modal for currencies that are bound to an UPE method. * Fix - Currency switcher does not affect order confirmation screen prices. +* Update - Bump minimum supported version of WooCommerce from 5.4 to 5.5. = 3.0.0 - 2021-09-16 = * Add - Download deposits report in CSV. diff --git a/woocommerce-payments.php b/woocommerce-payments.php index 7144ce7d474..a23778781c0 100644 --- a/woocommerce-payments.php +++ b/woocommerce-payments.php @@ -9,7 +9,7 @@ * Text Domain: woocommerce-payments * Domain Path: /languages * WC requires at least: 4.0 - * WC tested up to: 5.6 + * WC tested up to: 5.7 * Requires WP: 5.6 * Version: 3.0.0 * From a8e21b3227263e0ebacc58a4e73583f48237aafc Mon Sep 17 00:00:00 2001 From: Vasily Belolapotkov Date: Wed, 22 Sep 2021 14:42:00 +0300 Subject: [PATCH 02/18] Bump min required version of WooCommerce in headers --- changelog.txt | 1 + readme.txt | 1 + woocommerce-payments.php | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 307b151e596..fa134418a98 100644 --- a/changelog.txt +++ b/changelog.txt @@ -8,6 +8,7 @@ * Add - Currency deletion confirmation modal for currencies that are bound to an UPE method. * Fix - Currency switcher does not affect order confirmation screen prices. * Update - Bump minimum supported version of WooCommerce from 5.4 to 5.5. +* Update - Bump minimum required version of WooCommerce from 4.0 to 4.4. = 3.0.0 - 2021-09-16 = * Add - Download deposits report in CSV. diff --git a/readme.txt b/readme.txt index 39edf3227d2..293a088fbe5 100644 --- a/readme.txt +++ b/readme.txt @@ -106,6 +106,7 @@ Please note that our support for the checkout block is still experimental and th * Add - Currency deletion confirmation modal for currencies that are bound to an UPE method. * Fix - Currency switcher does not affect order confirmation screen prices. * Update - Bump minimum supported version of WooCommerce from 5.4 to 5.5. +* Update - Bump minimum required version of WooCommerce from 4.0 to 4.4. = 3.0.0 - 2021-09-16 = * Add - Download deposits report in CSV. diff --git a/woocommerce-payments.php b/woocommerce-payments.php index a23778781c0..d7d326f1aaa 100644 --- a/woocommerce-payments.php +++ b/woocommerce-payments.php @@ -8,7 +8,7 @@ * Woo: 5278104:bf3cf30871604e15eec560c962593c1f * Text Domain: woocommerce-payments * Domain Path: /languages - * WC requires at least: 4.0 + * WC requires at least: 4.4 * WC tested up to: 5.7 * Requires WP: 5.6 * Version: 3.0.0 From edd179115a53d5f4e374b4971474fbe9db2bad14 Mon Sep 17 00:00:00 2001 From: Vasily Belolapotkov Date: Wed, 22 Sep 2021 14:46:32 +0300 Subject: [PATCH 03/18] Update WC versions in CI matrix --- .github/workflows/compatibility.yml | 4 ++-- .github/workflows/coverage.yml | 2 +- .github/workflows/e2e-test.yml | 4 ++-- .github/workflows/php-lint-test.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/compatibility.yml b/.github/workflows/compatibility.yml index 0c034d3489f..125dc5693bf 100644 --- a/.github/workflows/compatibility.yml +++ b/.github/workflows/compatibility.yml @@ -11,12 +11,12 @@ jobs: fail-fast: false max-parallel: 10 matrix: - woocommerce: [ '4.0.0', '4.3.0', '4.4.0', '4.5.0', '4.6.0', '4.7.0', '4.8.0', '4.9.0', '5.0.0', '5.1.0', '5.2.0', '5.3.0', '5.4.0', '5.5.0' ] + woocommerce: [ '4.4.0', '4.5.0', '4.6.0', '4.7.0', '4.8.0', '4.9.0', '5.0.0', '5.1.0', '5.2.0', '5.3.0', '5.4.0', '5.5.0', '5.6.0', '5.7.0' ] wordpress: [ 'latest' ] php: [ '7.4' ] include: # Edge case: oldest dependencies compatibility - - woocommerce: '4.0.0' + - woocommerce: '4.4.0' wordpress: '5.4' php: '7.0' env: diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index c18307bdf9b..1c22d0d9861 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -11,7 +11,7 @@ jobs: fail-fast: false max-parallel: 10 matrix: - woocommerce: [ '5.5.0' ] + woocommerce: [ '5.7.0' ] wordpress: [ 'latest' ] php: [ '7.4' ] env: diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index d33ce761961..b1bee94fdf4 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -28,12 +28,12 @@ jobs: strategy: fail-fast: false matrix: - woocommerce: [ '4.0.0', '4.5.0', 'beta' ] + woocommerce: [ '4.4.0', '5.5.0', '5.7.0', 'beta' ] wordpress: [ 'latest' ] php: [ '7.4' ] include: # Edge case: oldest dependencies compatibility - - woocommerce: '4.0.0' + - woocommerce: '4.4.0' wordpress: '5.4' php: '7.0' env: diff --git a/.github/workflows/php-lint-test.yml b/.github/workflows/php-lint-test.yml index 703dc870cd4..1cab2118554 100644 --- a/.github/workflows/php-lint-test.yml +++ b/.github/workflows/php-lint-test.yml @@ -5,7 +5,7 @@ on: env: WP_VERSION: latest - WC_VERSION: 4.5.0 # the most used version here + WC_VERSION: 5.5.0 # the min supported version as per L-2 policy jobs: lint: From e820df45eefb272b5f4fd74be6defc42328a71ac Mon Sep 17 00:00:00 2001 From: Vasily Belolapotkov Date: Wed, 22 Sep 2021 15:12:26 +0300 Subject: [PATCH 04/18] Fix PHPUnit tests bootstrap for WC 4.4 and WP 5.4 --- composer.json | 3 +- composer.lock | 98 ++++++++++++++++++++++++---------------- tests/unit/bootstrap.php | 4 +- 3 files changed, 65 insertions(+), 40 deletions(-) diff --git a/composer.json b/composer.json index 38ebcba2af2..d55d797d95a 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,8 @@ "vimeo/psalm": "4.8.1", "php-stubs/wordpress-stubs": "5.7.2", "php-stubs/woocommerce-stubs": "5.5.0", - "rregeer/phpunit-coverage-check": "0.3.1" + "rregeer/phpunit-coverage-check": "0.3.1", + "yoast/phpunit-polyfills": "^1.0" }, "scripts": { "test": [ diff --git a/composer.lock b/composer.lock index 9be31d03c19..4b39828e80d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "81bbbbbde8503ba46a692f5fcdb70ee4", + "content-hash": "e0e908b38c66745b5ce984d712464ac9", "packages": [ { "name": "automattic/jetpack-a8c-mc-stats", @@ -34,9 +34,6 @@ "GPL-2.0-or-later" ], "description": "Used to record internal usage stats for Automattic. Not visible to site owners.", - "support": { - "source": "https://github.com/Automattic/jetpack-a8c-mc-stats/tree/v1.2.0" - }, "time": "2020-09-17T18:20:50+00:00" }, { @@ -76,9 +73,6 @@ "GPL-2.0-or-later" ], "description": "Creates a custom autoloader for a plugin or theme.", - "support": { - "source": "https://github.com/Automattic/jetpack-autoloader/tree/v2.8.0" - }, "time": "2020-12-18T22:33:59+00:00" }, { @@ -109,9 +103,6 @@ "GPL-2.0-or-later" ], "description": "Jetpack configuration package that initializes other packages and configures Jetpack's functionality. Can be used as a base for all variants of Jetpack package usage.", - "support": { - "source": "https://github.com/Automattic/jetpack-config/tree/v1.4.3" - }, "time": "2021-01-19T14:25:05+00:00" }, { @@ -156,9 +147,6 @@ "GPL-2.0-or-later" ], "description": "Everything needed to connect to the Jetpack infrastructure", - "support": { - "source": "https://github.com/Automattic/jetpack-connection/tree/v1.20.0" - }, "time": "2020-10-29T14:41:13+00:00" }, { @@ -190,9 +178,6 @@ "GPL-2.0-or-later" ], "description": "A wrapper for defining constants in a more testable way.", - "support": { - "source": "https://github.com/Automattic/jetpack-constants/tree/master" - }, "time": "2020-08-13T14:33:09+00:00" }, { @@ -227,9 +212,6 @@ "GPL-2.0-or-later" ], "description": "This adds a cronjob that sends a batch of internal automattic stats to wp.com once a day", - "support": { - "source": "https://github.com/Automattic/jetpack-heartbeat/tree/v1.2.0" - }, "time": "2020-10-27T15:01:23+00:00" }, { @@ -264,9 +246,6 @@ "GPL-2.0-or-later" ], "description": "A wrapper for wp-options to manage specific Jetpack options.", - "support": { - "source": "https://github.com/Automattic/jetpack-options/tree/v1.9.0" - }, "time": "2020-09-29T11:03:43+00:00" }, { @@ -298,9 +277,6 @@ "GPL-2.0-or-later" ], "description": "Utilities, related with user roles and capabilities.", - "support": { - "source": "https://github.com/Automattic/jetpack-roles/tree/master" - }, "time": "2020-08-13T14:33:36+00:00" }, { @@ -333,9 +309,6 @@ "GPL-2.0-or-later" ], "description": "Used to retrieve information about the current status of Jetpack and the site overall.", - "support": { - "source": "https://github.com/Automattic/jetpack-status/tree/v1.5.0" - }, "time": "2020-10-13T20:22:03+00:00" }, { @@ -371,9 +344,6 @@ "GPL-2.0-or-later" ], "description": "Everything need to manage the terms of service state", - "support": { - "source": "https://github.com/Automattic/jetpack-terms-of-service/tree/v1.8.0" - }, "time": "2020-10-27T15:02:49+00:00" }, { @@ -411,9 +381,6 @@ "GPL-2.0-or-later" ], "description": "Tracking for Jetpack", - "support": { - "source": "https://github.com/Automattic/jetpack-tracking/tree/v1.11.0" - }, "time": "2020-10-27T15:03:52+00:00" }, { @@ -460,10 +427,6 @@ "keywords": [ "enum" ], - "support": { - "issues": "https://github.com/myclabs/php-enum/issues", - "source": "https://github.com/myclabs/php-enum/tree/1.7.7" - }, "funding": [ { "url": "https://github.com/mnapoli", @@ -4016,6 +3979,65 @@ "wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki" }, "time": "2020-05-13T23:57:56+00:00" + }, + { + "name": "yoast/phpunit-polyfills", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/Yoast/PHPUnit-Polyfills.git", + "reference": "f014fb21c2b0038fd329515d59025af42fb98715" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Yoast/PHPUnit-Polyfills/zipball/f014fb21c2b0038fd329515d59025af42fb98715", + "reference": "f014fb21c2b0038fd329515d59025af42fb98715", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.0" + }, + "require-dev": { + "php-parallel-lint/php-console-highlighter": "^0.5", + "php-parallel-lint/php-parallel-lint": "^1.3.0", + "yoast/yoastcs": "^2.1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, + "autoload": { + "files": [ + "phpunitpolyfills-autoload.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Team Yoast", + "email": "support@yoast.com", + "homepage": "https://yoast.com" + }, + { + "name": "Contributors", + "homepage": "https://github.com/Yoast/PHPUnit-Polyfills/graphs/contributors" + } + ], + "description": "Set of polyfills for changed PHPUnit functionality to allow for creating PHPUnit cross-version compatible tests", + "homepage": "https://github.com/Yoast/PHPUnit-Polyfills", + "keywords": [ + "phpunit", + "polyfill", + "testing" + ], + "time": "2021-08-09T16:28:08+00:00" } ], "aliases": [], diff --git a/tests/unit/bootstrap.php b/tests/unit/bootstrap.php index 925a9555805..c93b73d007d 100755 --- a/tests/unit/bootstrap.php +++ b/tests/unit/bootstrap.php @@ -27,7 +27,6 @@ // Give access to tests_add_filter() function. require_once $_tests_dir . '/includes/functions.php'; - /** * Manually load the plugin being tested. */ @@ -77,6 +76,9 @@ function _manually_load_plugin() { tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' ); +// Need those polyfills to run tests in CI. +require_once dirname( __FILE__ ) . '/../../vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php'; + // Start up the WP testing environment. require $_tests_dir . '/includes/bootstrap.php'; From 708227b0a48fc0e4e02900033e2ee3fe096526f2 Mon Sep 17 00:00:00 2001 From: Vasily Belolapotkov Date: Wed, 22 Sep 2021 16:16:45 +0300 Subject: [PATCH 05/18] Require missing dependency --- tests/unit/bootstrap.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/bootstrap.php b/tests/unit/bootstrap.php index c93b73d007d..5c880d550fb 100755 --- a/tests/unit/bootstrap.php +++ b/tests/unit/bootstrap.php @@ -57,6 +57,7 @@ function _manually_load_plugin() { require_once $_plugin_dir . 'includes/compat/subscriptions/trait-wc-payments-subscriptions-utilities.php'; require_once $_plugin_dir . 'includes/compat/subscriptions/trait-wc-payment-gateway-wcpay-subscriptions.php'; require_once $_plugin_dir . 'includes/class-wc-payment-gateway-wcpay.php'; + require_once $_plugin_dir . 'includes/payment-methods/class-cc-payment-gateway.php'; require_once $_plugin_dir . 'includes/exceptions/class-rest-request-exception.php'; require_once $_plugin_dir . 'includes/admin/class-wc-payments-admin.php'; From 948ec474150433c9eea97d1cb251a7b84f916058 Mon Sep 17 00:00:00 2001 From: Vasily Belolapotkov Date: Wed, 22 Sep 2021 16:17:56 +0300 Subject: [PATCH 06/18] tmp: most of compatibility tests --- .github/workflows/compatibility.yml | 6 +++--- tests/unit/bootstrap.php | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/.github/workflows/compatibility.yml b/.github/workflows/compatibility.yml index 125dc5693bf..de6db531382 100644 --- a/.github/workflows/compatibility.yml +++ b/.github/workflows/compatibility.yml @@ -11,9 +11,9 @@ jobs: fail-fast: false max-parallel: 10 matrix: - woocommerce: [ '4.4.0', '4.5.0', '4.6.0', '4.7.0', '4.8.0', '4.9.0', '5.0.0', '5.1.0', '5.2.0', '5.3.0', '5.4.0', '5.5.0', '5.6.0', '5.7.0' ] - wordpress: [ 'latest' ] - php: [ '7.4' ] +# woocommerce: [ '4.4.0', '4.5.0', '4.6.0', '4.7.0', '4.8.0', '4.9.0', '5.0.0', '5.1.0', '5.2.0', '5.3.0', '5.4.0', '5.5.0', '5.6.0', '5.7.0' ] +# wordpress: [ 'latest' ] +# php: [ '7.4' ] include: # Edge case: oldest dependencies compatibility - woocommerce: '4.4.0' diff --git a/tests/unit/bootstrap.php b/tests/unit/bootstrap.php index 5c880d550fb..10c2c8d8aef 100755 --- a/tests/unit/bootstrap.php +++ b/tests/unit/bootstrap.php @@ -58,6 +58,25 @@ function _manually_load_plugin() { require_once $_plugin_dir . 'includes/compat/subscriptions/trait-wc-payment-gateway-wcpay-subscriptions.php'; require_once $_plugin_dir . 'includes/class-wc-payment-gateway-wcpay.php'; require_once $_plugin_dir . 'includes/payment-methods/class-cc-payment-gateway.php'; + require_once $_plugin_dir . 'includes/payment-methods/class-giropay-payment-gateway.php'; + require_once $_plugin_dir . 'includes/payment-methods/class-sepa-payment-gateway.php'; + require_once $_plugin_dir . 'includes/payment-methods/class-sofort-payment-gateway.php'; + require_once $_plugin_dir . 'includes/payment-methods/class-upe-payment-gateway.php'; + require_once $_plugin_dir . 'includes/payment-methods/class-upe-payment-method.php'; + require_once $_plugin_dir . 'includes/payment-methods/class-cc-payment-method.php'; + require_once $_plugin_dir . 'includes/payment-methods/class-bancontact-payment-method.php'; + require_once $_plugin_dir . 'includes/payment-methods/class-sepa-payment-method.php'; + require_once $_plugin_dir . 'includes/payment-methods/class-giropay-payment-method.php'; + require_once $_plugin_dir . 'includes/payment-methods/class-p24-payment-method.php'; + require_once $_plugin_dir . 'includes/payment-methods/class-sofort-payment-method.php'; + require_once $_plugin_dir . 'includes/payment-methods/class-ideal-payment-method.php'; + require_once $_plugin_dir . 'includes/class-wc-payment-token-wcpay-sepa.php'; + require_once $_plugin_dir . 'includes/class-wc-payments-token-service.php'; + require_once $_plugin_dir . 'includes/class-wc-payments-payment-request-button-handler.php'; + require_once $_plugin_dir . 'includes/class-wc-payments-apple-pay-registration.php'; + + require_once $_plugin_dir . 'includes/class-wc-payments-features.php'; + require_once $_plugin_dir . 'includes/class-wc-payments-utils.php'; require_once $_plugin_dir . 'includes/exceptions/class-rest-request-exception.php'; require_once $_plugin_dir . 'includes/admin/class-wc-payments-admin.php'; From 35f10723f8b60fd93fa7a4826ed3844180ca7ab9 Mon Sep 17 00:00:00 2001 From: Vasily Belolapotkov Date: Wed, 22 Sep 2021 16:32:27 +0300 Subject: [PATCH 07/18] tmp: test php 7.1 compat --- .github/workflows/compatibility.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compatibility.yml b/.github/workflows/compatibility.yml index de6db531382..09e38a49483 100644 --- a/.github/workflows/compatibility.yml +++ b/.github/workflows/compatibility.yml @@ -18,7 +18,7 @@ jobs: # Edge case: oldest dependencies compatibility - woocommerce: '4.4.0' wordpress: '5.4' - php: '7.0' + php: '7.1' env: WP_VERSION: ${{ matrix.wordpress }} WC_VERSION: ${{ matrix.woocommerce }} From e727b060cc2bfc688028c4b8b5cc7652b4f2a485 Mon Sep 17 00:00:00 2001 From: Vasily Belolapotkov Date: Wed, 22 Sep 2021 16:40:24 +0300 Subject: [PATCH 08/18] Revert "tmp: test php 7.1 compat" This reverts commit 35f10723 --- .github/workflows/compatibility.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compatibility.yml b/.github/workflows/compatibility.yml index 09e38a49483..de6db531382 100644 --- a/.github/workflows/compatibility.yml +++ b/.github/workflows/compatibility.yml @@ -18,7 +18,7 @@ jobs: # Edge case: oldest dependencies compatibility - woocommerce: '4.4.0' wordpress: '5.4' - php: '7.1' + php: '7.0' env: WP_VERSION: ${{ matrix.wordpress }} WC_VERSION: ${{ matrix.woocommerce }} From a47d248e1ed0f356d6547285619ff6a9d3ebcd8f Mon Sep 17 00:00:00 2001 From: Vasily Belolapotkov Date: Wed, 22 Sep 2021 16:42:43 +0300 Subject: [PATCH 09/18] Revert disabled compatibility tests --- .github/workflows/compatibility.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/compatibility.yml b/.github/workflows/compatibility.yml index de6db531382..4fb75110ff4 100644 --- a/.github/workflows/compatibility.yml +++ b/.github/workflows/compatibility.yml @@ -11,14 +11,14 @@ jobs: fail-fast: false max-parallel: 10 matrix: -# woocommerce: [ '4.4.0', '4.5.0', '4.6.0', '4.7.0', '4.8.0', '4.9.0', '5.0.0', '5.1.0', '5.2.0', '5.3.0', '5.4.0', '5.5.0', '5.6.0', '5.7.0' ] -# wordpress: [ 'latest' ] -# php: [ '7.4' ] + woocommerce: [ '4.4.0', '4.5.0', '4.6.0', '4.7.0', '4.8.0', '4.9.0', '5.0.0', '5.1.0', '5.2.0', '5.3.0', '5.4.0', '5.5.0', '5.6.0', '5.7.0' ] + wordpress: [ 'latest' ] + php: [ '7.4' ] include: # Edge case: oldest dependencies compatibility - woocommerce: '4.4.0' wordpress: '5.4' - php: '7.0' + php: '7.1' env: WP_VERSION: ${{ matrix.wordpress }} WC_VERSION: ${{ matrix.woocommerce }} From 533d99bc617249f35d84025465ef0a479979fd89 Mon Sep 17 00:00:00 2001 From: Vasily Belolapotkov Date: Wed, 22 Sep 2021 16:44:08 +0300 Subject: [PATCH 10/18] Revert "Require missing dependency" This reverts commit 708227b0 --- tests/unit/bootstrap.php | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/tests/unit/bootstrap.php b/tests/unit/bootstrap.php index 10c2c8d8aef..c93b73d007d 100755 --- a/tests/unit/bootstrap.php +++ b/tests/unit/bootstrap.php @@ -57,26 +57,6 @@ function _manually_load_plugin() { require_once $_plugin_dir . 'includes/compat/subscriptions/trait-wc-payments-subscriptions-utilities.php'; require_once $_plugin_dir . 'includes/compat/subscriptions/trait-wc-payment-gateway-wcpay-subscriptions.php'; require_once $_plugin_dir . 'includes/class-wc-payment-gateway-wcpay.php'; - require_once $_plugin_dir . 'includes/payment-methods/class-cc-payment-gateway.php'; - require_once $_plugin_dir . 'includes/payment-methods/class-giropay-payment-gateway.php'; - require_once $_plugin_dir . 'includes/payment-methods/class-sepa-payment-gateway.php'; - require_once $_plugin_dir . 'includes/payment-methods/class-sofort-payment-gateway.php'; - require_once $_plugin_dir . 'includes/payment-methods/class-upe-payment-gateway.php'; - require_once $_plugin_dir . 'includes/payment-methods/class-upe-payment-method.php'; - require_once $_plugin_dir . 'includes/payment-methods/class-cc-payment-method.php'; - require_once $_plugin_dir . 'includes/payment-methods/class-bancontact-payment-method.php'; - require_once $_plugin_dir . 'includes/payment-methods/class-sepa-payment-method.php'; - require_once $_plugin_dir . 'includes/payment-methods/class-giropay-payment-method.php'; - require_once $_plugin_dir . 'includes/payment-methods/class-p24-payment-method.php'; - require_once $_plugin_dir . 'includes/payment-methods/class-sofort-payment-method.php'; - require_once $_plugin_dir . 'includes/payment-methods/class-ideal-payment-method.php'; - require_once $_plugin_dir . 'includes/class-wc-payment-token-wcpay-sepa.php'; - require_once $_plugin_dir . 'includes/class-wc-payments-token-service.php'; - require_once $_plugin_dir . 'includes/class-wc-payments-payment-request-button-handler.php'; - require_once $_plugin_dir . 'includes/class-wc-payments-apple-pay-registration.php'; - - require_once $_plugin_dir . 'includes/class-wc-payments-features.php'; - require_once $_plugin_dir . 'includes/class-wc-payments-utils.php'; require_once $_plugin_dir . 'includes/exceptions/class-rest-request-exception.php'; require_once $_plugin_dir . 'includes/admin/class-wc-payments-admin.php'; From 16148f3355b487ec03aa8b7ea858913c0c9a7af4 Mon Sep 17 00:00:00 2001 From: Dat Hoang Date: Wed, 29 Sep 2021 10:04:10 +0700 Subject: [PATCH 11/18] Add comment to explain matrix component `woocommerce` for E2E tests --- .github/workflows/e2e-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index b1bee94fdf4..367b0e84267 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -28,6 +28,7 @@ jobs: strategy: fail-fast: false matrix: + # Min WooCommerce | L-2 | L(atest) | beta woocommerce: [ '4.4.0', '5.5.0', '5.7.0', 'beta' ] wordpress: [ 'latest' ] php: [ '7.4' ] From 0f234a37ca7e7f724ca320473298435a66159863 Mon Sep 17 00:00:00 2001 From: Dat Hoang Date: Wed, 29 Sep 2021 10:09:56 +0700 Subject: [PATCH 12/18] Add TODOs regarding issue #2970 --- .github/workflows/compatibility.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/compatibility.yml b/.github/workflows/compatibility.yml index 4fb75110ff4..3abd450f9fa 100644 --- a/.github/workflows/compatibility.yml +++ b/.github/workflows/compatibility.yml @@ -18,7 +18,7 @@ jobs: # Edge case: oldest dependencies compatibility - woocommerce: '4.4.0' wordpress: '5.4' - php: '7.1' + php: '7.1' # TODO This should be 7.0. Pending to fix in issue #2970. env: WP_VERSION: ${{ matrix.wordpress }} WC_VERSION: ${{ matrix.woocommerce }} @@ -36,8 +36,9 @@ jobs: php-version: ${{ matrix.php }} tools: composer coverage: none + # TODO move this run back when we fix the edge case with PHP 7.0. See #2970. + # run: if [[ "${{ matrix.php }}" == '7.0' ]]; then wget https://phar.phpunit.de/phpunit-6.5.14.phar && mv phpunit-6.5.14.phar phpunit.phar; fi; # run CI checks - - run: if [[ "${{ matrix.php }}" == '7.0' ]]; then wget https://phar.phpunit.de/phpunit-6.5.14.phar && mv phpunit-6.5.14.phar phpunit.phar; fi; - run: bash bin/run-ci-tests.bash # a dedicated job, as allowed to fail From 07ed01de611cb8028dfb842b540cd46bfd6097d9 Mon Sep 17 00:00:00 2001 From: Dat Hoang Date: Wed, 29 Sep 2021 14:57:24 +0700 Subject: [PATCH 13/18] Add a suggestion to downgrade WCPay to let the site continue work. --- includes/class-wc-payments.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/includes/class-wc-payments.php b/includes/class-wc-payments.php index 0d89eee1a9d..c534c51675b 100644 --- a/includes/class-wc-payments.php +++ b/includes/class-wc-payments.php @@ -414,8 +414,9 @@ public static function check_plugin_dependencies( $silent ) { if ( ! $silent ) { $message = WC_Payments_Utils::esc_interpolated_html( sprintf( - /* translators: %1: required WC version number, %2: currently installed WC version number */ - __( 'WooCommerce Payments requires WooCommerce %1$s or greater to be installed (you are using %2$s).', 'woocommerce-payments' ), + /* translators: %1: current WooCommerce Payment version, %2: required WC version number, %3: currently installed WC version number */ + __( 'WooCommerce Payments %1$s requires WooCommerce %2$s or greater to be installed (you are using %3$s). ', 'woocommerce-payments' ), + WCPAY_VERSION_NUMBER, $wc_version, WC_VERSION ), @@ -424,7 +425,22 @@ public static function check_plugin_dependencies( $silent ) { if ( current_user_can( 'update_plugins' ) ) { // Take the user to the "plugins" screen instead of trying to update WooCommerce inline. WooCommerce adds important information // on its plugin row regarding the currently installed extensions and their compatibility with the latest WC version. - $message .= ' ' . __( 'Update WooCommerce', 'woocommerce-payments' ) . ''; + $message .= '
' . __( 'Update WooCommerce', 'woocommerce-payments' ) . ''; + + /** + * Recommend using a previous version of WCPay for out-of-date Woo core version. + * + * @since 3.1.0 + */ + $message .= ' '; + $message .= WC_Payments_Utils::esc_interpolated_html( + /* translators: contain a link to https://wordpress.org/plugins/woocommerce-payments/advanced/#download-previous-link */ + __( 'or (not recommended) manually re-install a previous version of WooCommerce Payments.', 'woocommerce-payments' ), + [ + 'strong' => '', + 'a' => '', + ] + ); } self::display_admin_error( $message ); } From 87c34e476ec97e66f905ab67c49db02fe33c09de Mon Sep 17 00:00:00 2001 From: Dat Hoang Date: Wed, 29 Sep 2021 15:01:28 +0700 Subject: [PATCH 14/18] Continue loading WCPay if the account is currently connected. --- includes/class-wc-payments.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/includes/class-wc-payments.php b/includes/class-wc-payments.php index c534c51675b..6c026692fa6 100644 --- a/includes/class-wc-payments.php +++ b/includes/class-wc-payments.php @@ -159,7 +159,16 @@ public static function init() { if ( ! self::check_plugin_dependencies( true ) ) { add_filter( 'admin_notices', [ __CLASS__, 'check_plugin_dependencies' ] ); - return; + + /** + * After displaying notice errors in WP Admin, still silently load the plugin if the account is connected. + * + * @since 3.1.0 + */ + $account_data = get_option( 'wcpay_account_data' ); + if ( ! isset( $account_data['account'] ) ) { + return; + }; } add_action( 'admin_init', [ __CLASS__, 'add_woo_admin_notes' ] ); From 2d76e585e837cdeabd5f5a91f65f0dd565a0d47e Mon Sep 17 00:00:00 2001 From: Dat Hoang Date: Wed, 29 Sep 2021 15:32:55 +0700 Subject: [PATCH 15/18] Add changelog entries. --- changelog.txt | 2 ++ readme.txt | 2 ++ 2 files changed, 4 insertions(+) diff --git a/changelog.txt b/changelog.txt index a7845a219a7..36b58587f30 100644 --- a/changelog.txt +++ b/changelog.txt @@ -16,6 +16,8 @@ * Fix - Update shipping cost in payment sheet when changing payment method. * Update - Bump minimum supported version of WooCommerce from 5.4 to 5.5. * Update - Bump minimum required version of WooCommerce from 4.0 to 4.4. +* Update - Continue loading WCPay if the account is connected. +* Add - Message to suggest using the previous version of WooCommerce Payments for old Woo core versions. = 3.0.0 - 2021-09-16 = * Add - Download deposits report in CSV. diff --git a/readme.txt b/readme.txt index 8d724d40044..20ebebe4b51 100644 --- a/readme.txt +++ b/readme.txt @@ -114,6 +114,8 @@ Please note that our support for the checkout block is still experimental and th * Fix - Update shipping cost in payment sheet when changing payment method. * Update - Bump minimum supported version of WooCommerce from 5.4 to 5.5. * Update - Bump minimum required version of WooCommerce from 4.0 to 4.4. +* Update - Continue loading WCPay if the account is connected. +* Add - Message to suggest using the previous version of WooCommerce Payments for old Woo core versions. = 3.0.0 - 2021-09-16 = * Add - Download deposits report in CSV. From fd960b810689aa1afce72038b5105144b889f7a9 Mon Sep 17 00:00:00 2001 From: Dat Hoang Date: Thu, 30 Sep 2021 15:08:11 +0700 Subject: [PATCH 16/18] Update the message. --- includes/class-wc-payments.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/includes/class-wc-payments.php b/includes/class-wc-payments.php index 6c026692fa6..f7ca3ce4806 100644 --- a/includes/class-wc-payments.php +++ b/includes/class-wc-payments.php @@ -434,20 +434,15 @@ public static function check_plugin_dependencies( $silent ) { if ( current_user_can( 'update_plugins' ) ) { // Take the user to the "plugins" screen instead of trying to update WooCommerce inline. WooCommerce adds important information // on its plugin row regarding the currently installed extensions and their compatibility with the latest WC version. - $message .= '
' . __( 'Update WooCommerce', 'woocommerce-payments' ) . ''; - - /** - * Recommend using a previous version of WCPay for out-of-date Woo core version. - * - * @since 3.1.0 - */ - $message .= ' '; + $message .= '
'; $message .= WC_Payments_Utils::esc_interpolated_html( - /* translators: contain a link to https://wordpress.org/plugins/woocommerce-payments/advanced/#download-previous-link */ - __( 'or (not recommended) manually re-install a previous version of WooCommerce Payments.', 'woocommerce-payments' ), + /* translators: a1: link to the Plugins page, a2: link to the page having all previous versions */ + __( 'Update WooCommerce (recommended) or manually re-install a previous version of WooCommerce Payments.', 'woocommerce-payments' ), [ + + 'a1' => '', 'strong' => '', - 'a' => '', + 'a2' => '', ] ); } From a453a88e09c39331642397de848dd3e73ba3fcb3 Mon Sep 17 00:00:00 2001 From: Dat Hoang Date: Fri, 1 Oct 2021 16:13:35 +0700 Subject: [PATCH 17/18] check_plugin_dependencies: remove $silent, return notice message and dependency status flag. --- includes/class-wc-payments.php | 224 +++++++++++++++++---------------- 1 file changed, 113 insertions(+), 111 deletions(-) diff --git a/includes/class-wc-payments.php b/includes/class-wc-payments.php index f7ca3ce4806..b6a3deb70e7 100644 --- a/includes/class-wc-payments.php +++ b/includes/class-wc-payments.php @@ -157,18 +157,26 @@ public static function init() { include_once __DIR__ . '/class-wc-payments-features.php'; include_once __DIR__ . '/class-wc-payments-utils.php'; - if ( ! self::check_plugin_dependencies( true ) ) { - add_filter( 'admin_notices', [ __CLASS__, 'check_plugin_dependencies' ] ); + $check = self::check_plugin_dependencies(); + $message = $check['message']; + $passed = $check['passed']; + + if ( null !== $message ) { + add_action( + 'admin_notices', + function() use ( $message ) { + // Do not show alerts while installing plugins. + if ( self::is_at_plugin_install_page() ) { + return; + } + + self::display_admin_error( $message ); + } + ); + } - /** - * After displaying notice errors in WP Admin, still silently load the plugin if the account is connected. - * - * @since 3.1.0 - */ - $account_data = get_option( 'wcpay_account_data' ); - if ( ! isset( $account_data['account'] ) ) { - return; - }; + if ( false === $passed ) { + return; } add_action( 'admin_init', [ __CLASS__, 'add_woo_admin_notes' ] ); @@ -374,141 +382,135 @@ public static function get_plugin_headers() { /** * Checks if all the dependencies needed to run this plugin are present * - * @param bool $silent True if the function should just return true/false, False if this function should display notice messages for failed dependencies. - * @return bool True if all dependencies are met, false otherwise + * @return array{message: ?string, passed: bool} An array including a notice message for admins, and a flag with value True if dependencies are met or False other wise. */ - public static function check_plugin_dependencies( $silent ) { + public static function check_plugin_dependencies() { + $res = [ + 'message' => null, + 'passed' => false, + ]; + if ( defined( 'WCPAY_TEST_ENV' ) && WCPAY_TEST_ENV ) { - return true; + $res['passed'] = true; + return $res; } $plugin_headers = self::get_plugin_headers(); - - // Do not show alerts while installing plugins. - if ( ! $silent && self::is_at_plugin_install_page() ) { - return true; - } - - $wc_version = $plugin_headers['WCRequires']; - $wp_version = $plugin_headers['RequiresWP']; + $wc_version = $plugin_headers['WCRequires']; + $wp_version = $plugin_headers['RequiresWP']; // Check if WooCommerce is installed and active. if ( ! class_exists( 'WooCommerce' ) ) { - if ( ! $silent ) { - $message = WC_Payments_Utils::esc_interpolated_html( - __( 'WooCommerce Payments requires WooCommerce to be installed and active.', 'woocommerce-payments' ), - [ 'a' => '' ] - ); + $res['message'] = WC_Payments_Utils::esc_interpolated_html( + __( 'WooCommerce Payments requires WooCommerce to be installed and active.', 'woocommerce-payments' ), + [ 'a' => '' ] + ); - if ( current_user_can( 'install_plugins' ) ) { - if ( is_wp_error( validate_plugin( 'woocommerce/woocommerce.php' ) ) ) { - // WooCommerce is not installed. - $activate_url = wp_nonce_url( admin_url( 'update.php?action=install-plugin&plugin=woocommerce' ), 'install-plugin_woocommerce' ); - $activate_text = __( 'Install WooCommerce', 'woocommerce-payments' ); - } else { - // WooCommerce is installed, so it just needs to be enabled. - $activate_url = wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=woocommerce/woocommerce.php' ), 'activate-plugin_woocommerce/woocommerce.php' ); - $activate_text = __( 'Activate WooCommerce', 'woocommerce-payments' ); - } - $message .= ' ' . $activate_text . ''; + if ( current_user_can( 'install_plugins' ) ) { + if ( is_wp_error( validate_plugin( 'woocommerce/woocommerce.php' ) ) ) { + // WooCommerce is not installed. + $activate_url = wp_nonce_url( admin_url( 'update.php?action=install-plugin&plugin=woocommerce' ), 'install-plugin_woocommerce' ); + $activate_text = __( 'Install WooCommerce', 'woocommerce-payments' ); + } else { + // WooCommerce is installed, so it just needs to be enabled. + $activate_url = wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=woocommerce/woocommerce.php' ), 'activate-plugin_woocommerce/woocommerce.php' ); + $activate_text = __( 'Activate WooCommerce', 'woocommerce-payments' ); } - - self::display_admin_error( $message ); + $res['message'] .= ' ' . $activate_text . ''; } - return false; + + $res['passed'] = false; + return $res; } // Check if the version of WooCommerce is compatible with WooCommerce Payments. if ( version_compare( WC_VERSION, $wc_version, '<' ) ) { - if ( ! $silent ) { - $message = WC_Payments_Utils::esc_interpolated_html( - sprintf( - /* translators: %1: current WooCommerce Payment version, %2: required WC version number, %3: currently installed WC version number */ - __( 'WooCommerce Payments %1$s requires WooCommerce %2$s or greater to be installed (you are using %3$s). ', 'woocommerce-payments' ), - WCPAY_VERSION_NUMBER, - $wc_version, - WC_VERSION - ), - [ 'strong' => '' ] - ); - if ( current_user_can( 'update_plugins' ) ) { - // Take the user to the "plugins" screen instead of trying to update WooCommerce inline. WooCommerce adds important information - // on its plugin row regarding the currently installed extensions and their compatibility with the latest WC version. - $message .= '
'; - $message .= WC_Payments_Utils::esc_interpolated_html( + $res['message'] = WC_Payments_Utils::esc_interpolated_html( + sprintf( + /* translators: %1: current WooCommerce Payment version, %2: required WC version number, %3: currently installed WC version number */ + __( 'WooCommerce Payments %1$s requires WooCommerce %2$s or greater to be installed (you are using %3$s). ', 'woocommerce-payments' ), + WCPAY_VERSION_NUMBER, + $wc_version, + WC_VERSION + ), + [ 'strong' => '' ] + ); + + if ( current_user_can( 'update_plugins' ) ) { + // Take the user to the "plugins" screen instead of trying to update WooCommerce inline. WooCommerce adds important information + // on its plugin row regarding the currently installed extensions and their compatibility with the latest WC version. + $res['message'] .= '
' . WC_Payments_Utils::esc_interpolated_html( /* translators: a1: link to the Plugins page, a2: link to the page having all previous versions */ - __( 'Update WooCommerce (recommended) or manually re-install a previous version of WooCommerce Payments.', 'woocommerce-payments' ), - [ - - 'a1' => '', - 'strong' => '', - 'a2' => '', - ] - ); - } - self::display_admin_error( $message ); + __( 'Update WooCommerce (recommended) or manually re-install a previous version of WooCommerce Payments.', 'woocommerce-payments' ), + [ + + 'a1' => '', + 'strong' => '', + 'a2' => '', + ] + ); } - return false; + + $res['passed'] = false; + return $res; } // Check if the current WooCommerce version has WooCommerce Admin bundled (WC 4.0+) but it's disabled using a filter. if ( ! defined( 'WC_ADMIN_VERSION_NUMBER' ) ) { - if ( ! $silent ) { - self::display_admin_error( - WC_Payments_Utils::esc_interpolated_html( - __( 'WooCommerce Payments requires WooCommerce Admin to be enabled. Please remove the woocommerce_admin_disabled filter to use WooCommerce Payments.', 'woocommerce-payments' ), - [ 'code' => '' ] - ) - ); - } - return false; + $res['message'] = WC_Payments_Utils::esc_interpolated_html( + __( 'WooCommerce Payments requires WooCommerce Admin to be enabled. Please remove the woocommerce_admin_disabled filter to use WooCommerce Payments.', 'woocommerce-payments' ), + [ 'code' => '' ] + ); + + $res['passed'] = false; + return $res; } // Check if the version of WooCommerce Admin is compatible with WooCommerce Payments. if ( version_compare( WC_ADMIN_VERSION_NUMBER, WCPAY_MIN_WC_ADMIN_VERSION, '<' ) ) { - if ( ! $silent ) { - $message = WC_Payments_Utils::esc_interpolated_html( - sprintf( - /* translators: %1: required WC-Admin version number, %2: currently installed WC-Admin version number */ - __( 'WooCommerce Payments requires WooCommerce Admin %1$s or greater to be installed (you are using %2$s).', 'woocommerce-payments' ), - WCPAY_MIN_WC_ADMIN_VERSION, - WC_ADMIN_VERSION_NUMBER - ), - [ 'strong' => '' ] - ); + $res['message'] = WC_Payments_Utils::esc_interpolated_html( + sprintf( + /* translators: %1: required WC-Admin version number, %2: currently installed WC-Admin version number */ + __( 'WooCommerce Payments requires WooCommerce Admin %1$s or greater to be installed (you are using %2$s).', 'woocommerce-payments' ), + WCPAY_MIN_WC_ADMIN_VERSION, + WC_ADMIN_VERSION_NUMBER + ), + [ 'strong' => '' ] + ); // Let's assume for now that any WC-Admin version bundled with WooCommerce will meet our minimum requirements. - $message .= ' ' . __( 'There is a newer version of WooCommerce Admin bundled with WooCommerce.', 'woocommerce-payments' ); - if ( current_user_can( 'deactivate_plugins' ) ) { - $deactivate_url = wp_nonce_url( admin_url( 'plugins.php?action=deactivate&plugin=woocommerce-admin/woocommerce-admin.php' ), 'deactivate-plugin_woocommerce-admin/woocommerce-admin.php' ); - $message .= ' ' . __( 'Use the bundled version of WooCommerce Admin', 'woocommerce-payments' ) . ''; - } - self::display_admin_error( $message ); + $res['message'] .= ' ' . __( 'There is a newer version of WooCommerce Admin bundled with WooCommerce.', 'woocommerce-payments' ); + + if ( current_user_can( 'deactivate_plugins' ) ) { + $deactivate_url = wp_nonce_url( admin_url( 'plugins.php?action=deactivate&plugin=woocommerce-admin/woocommerce-admin.php' ), 'deactivate-plugin_woocommerce-admin/woocommerce-admin.php' ); + $res['message'] .= ' ' . __( 'Use the bundled version of WooCommerce Admin', 'woocommerce-payments' ) . ''; } - return false; + + $res['passed'] = false; + return $res; } // Check if the version of WordPress is compatible with WooCommerce Payments. if ( version_compare( get_bloginfo( 'version' ), $wp_version, '<' ) ) { - if ( ! $silent ) { - $message = WC_Payments_Utils::esc_interpolated_html( - sprintf( - /* translators: %1: required WP version number, %2: currently installed WP version number */ - __( 'WooCommerce Payments requires WordPress %1$s or greater (you are using %2$s).', 'woocommerce-payments' ), - $wp_version, - get_bloginfo( 'version' ) - ), - [ 'strong' => '' ] - ); - if ( current_user_can( 'update_core' ) ) { - $message .= ' ' . __( 'Update WordPress', 'woocommerce-payments' ) . ''; - } - self::display_admin_error( $message ); + $res['message'] = WC_Payments_Utils::esc_interpolated_html( + sprintf( + /* translators: %1: required WP version number, %2: currently installed WP version number */ + __( 'WooCommerce Payments requires WordPress %1$s or greater (you are using %2$s).', 'woocommerce-payments' ), + $wp_version, + get_bloginfo( 'version' ) + ), + [ 'strong' => '' ] + ); + if ( current_user_can( 'update_core' ) ) { + $res['message'] .= ' ' . __( 'Update WordPress', 'woocommerce-payments' ) . ''; } - return false; + + $res['passed'] = false; + return $res; } - return true; + $res['passed'] = true; + return $res; } /** From f03f18c50d1a18b909247595d6f96b3bc7d4bf56 Mon Sep 17 00:00:00 2001 From: Dat Hoang Date: Fri, 1 Oct 2021 16:41:12 +0700 Subject: [PATCH 18/18] Use has_cached_account_connection to decide loading the plugin. --- includes/class-wc-payments.php | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/includes/class-wc-payments.php b/includes/class-wc-payments.php index b6a3deb70e7..84a30b33e80 100644 --- a/includes/class-wc-payments.php +++ b/includes/class-wc-payments.php @@ -451,7 +451,13 @@ public static function check_plugin_dependencies() { ); } - $res['passed'] = false; + /** + * If WCPay account is connected, still silently load the plugin. + * Can not use self::$account->is_stripe_connected() as many dependencies are not loaded at this point. + * + * @since 3.1.0 + */ + $res['passed'] = self::has_cached_account_connection(); return $res; } @@ -486,7 +492,13 @@ public static function check_plugin_dependencies() { $res['message'] .= ' ' . __( 'Use the bundled version of WooCommerce Admin', 'woocommerce-payments' ) . ''; } - $res['passed'] = false; + /** + * If WCPay account is connected, still silently load the plugin. + * Can not use self::$account->is_stripe_connected() as many dependencies are not loaded at this point. + * + * @since 3.1.0 + */ + $res['passed'] = self::has_cached_account_connection(); return $res; } @@ -523,6 +535,16 @@ private static function is_at_plugin_install_page() { return 'update' === $cur_screen->id && 'plugins' === $cur_screen->parent_base; } + /** + * Check if the current WCPay Account has cache data. + * + * @return bool True if the cache data exists in wp_options. + */ + private static function has_cached_account_connection(): bool { + $account_data = get_option( 'wcpay_account_data' ); + return isset( $account_data['account'] ) && is_array( $account_data['account'] ); + } + /** * Adds links to the plugin's row in the "Plugins" Wp-Admin page. *