Automattic\WooCommerce\Internal\Logging

RemoteLogger::fetch_new_woocommerce_version()privateWC 1.0

Fetch the new version of WooCommerce from the WordPress API.

Method of the class: RemoteLogger{}

No Hooks.

Return

String|null. New version if an update is available, null otherwise.

Usage

// private - for code of main (parent) class only
$result = $this->fetch_new_woocommerce_version();

RemoteLogger::fetch_new_woocommerce_version() code WC 9.6.0

private function fetch_new_woocommerce_version() {
	$plugin_updates = SafeGlobalFunctionProxy::get_plugin_updates();

	// Check if WooCommerce plugin update information is available.
	if ( ! is_array( $plugin_updates ) || ! isset( $plugin_updates[ WC_PLUGIN_BASENAME ] ) ) {
		return null;
	}

	$wc_plugin_update = $plugin_updates[ WC_PLUGIN_BASENAME ];

	// Ensure the update object exists and has the required information.
	if ( ! $wc_plugin_update || ! isset( $wc_plugin_update->update->new_version ) ) {
		return null;
	}

	$new_version = $wc_plugin_update->update->new_version;
	return is_string( $new_version ) ? $new_version : null;
}