Automattic\WooCommerce\Internal\Logging
RemoteLogger::fetch_latest_woocommerce_version()
Fetch the latest WooCommerce version using the WordPress API and cache it.
Method of the class: RemoteLogger{}
No Hooks.
Return
String|null
.
Usage
// private - for code of main (parent) class only $result = $this->fetch_latest_woocommerce_version();
RemoteLogger::fetch_latest_woocommerce_version() RemoteLogger::fetch latest woocommerce version code WC 9.3.3
private function fetch_latest_woocommerce_version() { $cached_version = get_transient( self::WC_LATEST_VERSION_TRANSIENT ); if ( $cached_version ) { return $cached_version; } $retry_count = get_transient( self::FETCH_LATEST_VERSION_RETRY ); if ( false === $retry_count || ! is_numeric( $retry_count ) ) { $retry_count = 0; } if ( $retry_count >= 3 ) { return null; } if ( ! function_exists( 'plugins_api' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; } // Fetch the latest version from the WordPress API. $plugin_info = plugins_api( 'plugin_information', array( 'slug' => 'woocommerce' ) ); if ( is_wp_error( $plugin_info ) ) { ++$retry_count; set_transient( self::FETCH_LATEST_VERSION_RETRY, $retry_count, HOUR_IN_SECONDS ); return null; } if ( ! empty( $plugin_info->version ) ) { $latest_version = $plugin_info->version; set_transient( self::WC_LATEST_VERSION_TRANSIENT, $latest_version, WEEK_IN_SECONDS ); delete_transient( self::FETCH_LATEST_VERSION_RETRY ); return $latest_version; } return null; }