wc_prevent_dangerous_auto_updates( bool $should_update, object $plugin )

Prevent auto-updating the WooCommerce plugin on major releases if there are untested extensions active.


Description Description


Parameters Parameters

$should_update

(Required) If should update.

$plugin

(Required) Plugin data.


Top ↑

Return Return

(bool)


Top ↑

Source Source

File: includes/wc-core-functions.php

function wc_prevent_dangerous_auto_updates( $should_update, $plugin ) {
	if ( ! isset( $plugin->plugin, $plugin->new_version ) ) {
		return $should_update;
	}

	if ( 'woocommerce/woocommerce.php' !== $plugin->plugin ) {
		return $should_update;
	}

	if ( ! class_exists( 'WC_Plugin_Updates' ) ) {
		include_once dirname( __FILE__ ) . '/admin/plugin-updates/class-wc-plugin-updates.php';
	}

	$new_version      = wc_clean( $plugin->new_version );
	$plugin_updates   = new WC_Plugin_Updates();
	$untested_plugins = $plugin_updates->get_untested_plugins( $new_version, 'major' );
	if ( ! empty( $untested_plugins ) ) {
		return false;
	}

	return $should_update;
}

Top ↑

Changelog Changelog

Changelog
Version Description
3.2.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.