diff --git a/includes/admin/plugin-updates/class-wc-updates-screen-updates.php b/includes/admin/plugin-updates/class-wc-updates-screen-updates.php index 60510100610..7d2cbb9de8d 100644 --- a/includes/admin/plugin-updates/class-wc-updates-screen-updates.php +++ b/includes/admin/plugin-updates/class-wc-updates-screen-updates.php @@ -6,6 +6,8 @@ * @version 3.2.0 */ +use Automattic\Jetpack\Constants; + if ( ! defined( 'ABSPATH' ) ) { exit; } @@ -37,8 +39,13 @@ class WC_Updates_Screen_Updates extends WC_Plugin_Updates { return; } + $version_type = Constants::get_constant( 'WC_SSR_PLUGIN_UPDATE_RELEASE_VERSION_TYPE' ); + if ( ! is_string( $version_type ) ) { + $version_type = 'none'; + } + $this->new_version = wc_clean( $updateable_plugins['woocommerce/woocommerce.php']->update->new_version ); - $this->major_untested_plugins = $this->get_untested_plugins( $this->new_version, 'major' ); + $this->major_untested_plugins = $this->get_untested_plugins( $this->new_version, $version_type ); if ( ! empty( $this->major_untested_plugins ) ) { echo $this->get_extensions_modal_warning(); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped diff --git a/includes/admin/views/html-admin-page-status-report.php b/includes/admin/views/html-admin-page-status-report.php index c1393a42d7e..421040eb023 100644 --- a/includes/admin/views/html-admin-page-status-report.php +++ b/includes/admin/views/html-admin-page-status-report.php @@ -5,16 +5,12 @@ * @package WooCommerce */ +use Automattic\Jetpack\Constants; + defined( 'ABSPATH' ) || exit; global $wpdb; -if ( ! defined( 'WC_SSR_PLUGIN_UPDATE_RELEASE_VERSION_TYPE' ) ) { - // Define if we're checking against major or minor versions. - // Since 5.0 all versions are backwards compatible, so there's no more check. - define( 'WC_SSR_PLUGIN_UPDATE_RELEASE_VERSION_TYPE', 'none' ); -} - $report = wc()->api->get_endpoint_data( '/wc/v3/system_status' ); $environment = $report['environment']; $database = $report['database']; @@ -27,7 +23,7 @@ $security = $report['security']; $settings = $report['settings']; $wp_pages = $report['pages']; $plugin_updates = new WC_Plugin_Updates(); -$untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, WC_SSR_PLUGIN_UPDATE_RELEASE_VERSION_TYPE ); +$untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, Constants::get_constant( 'WC_SSR_PLUGIN_UPDATE_RELEASE_VERSION_TYPE' ) ); ?>

diff --git a/includes/class-woocommerce.php b/includes/class-woocommerce.php index ec163d8efcf..85a7c5bad71 100644 --- a/includes/class-woocommerce.php +++ b/includes/class-woocommerce.php @@ -249,6 +249,18 @@ final class WooCommerce { $this->define( 'WC_NOTICE_MIN_PHP_VERSION', '7.2' ); $this->define( 'WC_NOTICE_MIN_WP_VERSION', '5.2' ); $this->define( 'WC_PHP_MIN_REQUIREMENTS_NOTICE', 'wp_php_min_requirements_' . WC_NOTICE_MIN_PHP_VERSION . '_' . WC_NOTICE_MIN_WP_VERSION ); + /** Define if we're checking against major, minor or no versions in the following places: + * - plugin screen in WP Admin (displaying extra warning when updating to new major versions) + * - System Status Report ('Installed version not tested with active version of WooCommerce' warning) + * - core update screen in WP Admin (displaying extra warning when updating to new major versions) + * - enable/disable automated updates in the plugin screen in WP Admin (if there are any plugins + * that don't declare compatibility, the auto-update is disabled) + * + * We dropped SemVer before WC 5.0, so all versions are backwards compatible now, thus no more check needed. + * The SSR in the name is preserved for bw compatibility, as this was initially used in System Status Report. + */ + $this->define( 'WC_SSR_PLUGIN_UPDATE_RELEASE_VERSION_TYPE', 'none' ); + } /** diff --git a/includes/wc-core-functions.php b/includes/wc-core-functions.php index 47d0167b703..1dece2cebe4 100644 --- a/includes/wc-core-functions.php +++ b/includes/wc-core-functions.php @@ -2255,7 +2255,11 @@ function wc_prevent_dangerous_auto_updates( $should_update, $plugin ) { $new_version = wc_clean( $plugin->new_version ); $plugin_updates = new WC_Plugin_Updates(); - $untested_plugins = $plugin_updates->get_untested_plugins( $new_version, 'major' ); + $version_type = Constants::get_constant( 'WC_SSR_PLUGIN_UPDATE_RELEASE_VERSION_TYPE' ); + if ( ! is_string( $version_type ) ) { + $version_type = 'none'; + } + $untested_plugins = $plugin_updates->get_untested_plugins( $new_version, $version_type ); if ( ! empty( $untested_plugins ) ) { return false; }