/** * @param string $path * @param bool $flush * @param int $expiration (optional) Time until expiration in seconds from now, defaults to 24 hours * * @return stdClass|mixed */ function get($path = '/', $flush = false, $expiration = WP_FS__TIME_24_HOURS_IN_SEC) { $cache_key = $this->get_cache_key($path); // Always flush during development. if (WP_FS__DEV_MODE || $this->_api->IsSandbox()) { $flush = true; } // Get result from cache. $cache_entry = self::$_cache->get_option($cache_key, false); $fetch = false; if ($flush || false === $cache_entry || !isset($cache_entry->timestamp) || !is_numeric($cache_entry->timestamp) || $cache_entry->timestamp < WP_FS__SCRIPT_START_TIME) { $fetch = true; } if ($fetch) { $result = $this->call($path); if (!is_object($result) || isset($result->error)) { if (is_object($cache_entry) && isset($cache_entry->result) && !isset($cache_entry->result->error)) { // If there was an error during a newer data fetch, // fallback to older data version. $result = $cache_entry->result; } else { // If no older data version, return result without // caching the error. return $result; } } $cache_entry = new stdClass(); $cache_entry->result = $result; $cache_entry->timestamp = WP_FS__SCRIPT_START_TIME + $expiration; self::$_cache->set_option($cache_key, $cache_entry, true); } return $cache_entry->result; }
function get_url($path = '') { return Freemius_Api::GetUrl($path, $this->_api->IsSandbox()); }