private static function _init() { if (!class_exists('Freemius_Api')) { require_once WP_FS__DIR_SDK . '/Freemius.php'; } self::$_options = FS_Option_Manager::get_manager(WP_FS__OPTIONS_OPTION_NAME, true); self::$_cache = FS_Option_Manager::get_manager(WP_FS__API_CACHE_OPTION_NAME, true); self::$_clock_diff = self::$_options->get_option('api_clock_diff', 0); Freemius_Api::SetClockDiff(self::$_clock_diff); if (self::$_options->get_option('api_force_http', false)) { Freemius_Api::SetHttp(); } }
/** * Find clock diff between server and API server, and store the diff locally. * * @param bool|int $diff * * @return bool|int False if clock diff didn't change, otherwise returns the clock diff in seconds. */ private function _sync_clock_diff($diff = false) { $this->_logger->entrance(); // Sync clock and store. $new_clock_diff = false === $diff ? $this->_api->FindClockDiff() : $diff; if ($new_clock_diff === self::$_clock_diff) { return false; } self::$_clock_diff = $new_clock_diff; // Update API clock's diff. $this->_api->SetClockDiff(self::$_clock_diff); // Store new clock diff in storage. self::$_options->set_option('api_clock_diff', self::$_clock_diff, true); return $new_clock_diff; }