WC_Helper_Updater::is_autoupdate_forced │ private static │ WC 11.2.0

Checks whether WooCommerce.com flagged this update to be installed automatically.

Uses core's own autoupdate flag, the same one api.wordpress.org sets on WordPress.org plugins, so these updates follow the same path through WP_Automatic_Updater::should_update(). The flag overrides the per-item setting and the site-wide plugins_auto_update_enabled and themes_auto_update_enabled switches. AUTOMATIC_UPDATER_DISABLED, disable_autoupdate and the auto_update_plugin and auto_update_theme filters still apply.

The package checks are required: forcing an update that cannot be installed, either because no package was supplied or because the subscription expired, only produces a failed update email to every admin on the site.

Method of the class: WC_Helper_Updater{}

No Hooks.

Returns

bool.

Usage

$result = WC_Helper_Updater::is_autoupdate_forced( $data, $item );
$data(array) (required)
Product data returned by the Helper API update check.
$item(array) (required)
Update item built for the update transient.

Changelog

Since 11.2.0 Introduced.

WC_Helper_Updater::is_autoupdate_forced() code WC 11.2.2

private static function is_autoupdate_forced( $data, $item ) {
	// The flag arrives from a remote response, so only a value that reads as boolean true
	// counts. A truthy string such as "false", or an array, must not trigger an install.
	if ( true !== filter_var( $data['autoupdate'] ?? null, FILTER_VALIDATE_BOOLEAN ) ) {
		return false;
	}

	if ( empty( $item['package'] ) || ! is_string( $item['package'] ) ) {
		return false;
	}

	return 0 !== strpos( $item['package'], 'woocommerce-com-expired-' );
}