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.

Метод класса: WC_Helper_Updater{}

Хуков нет.

Возвращает

bool.

Использование

$result = WC_Helper_Updater::is_autoupdate_forced( $data, $item );
$data(массив) (обязательный)
Product data returned by the Helper API update check.
$item(массив) (обязательный)
Update item built for the update transient.

Список изменений

С версии 11.2.0 Введена.

Код WC_Helper_Updater::is_autoupdate_forced() WC 11.2.1

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