/** * Try to get the sitemap from cache * * @param string $type Sitemap type. * @param int $page_number The page number to retrieve. * * @return bool If the sitemap has been retrieved from cache. */ private function get_sitemap_from_cache($type, $page_number) { $this->transient = false; if (true !== $this->cache->is_enabled()) { return false; } /** * Fires before the attempt to retrieve XML sitemap from the transient cache. * * @param WPSEO_Sitemaps $sitemaps Sitemaps object. */ do_action('wpseo_sitemap_stylesheet_cache_' . $type, $this); $sitemap_cache_data = $this->cache->get_sitemap_data($type, $page_number); // No cache was found, refresh it because cache is enabled. if (empty($sitemap_cache_data)) { return $this->refresh_sitemap_cache($type, $page_number); } // Cache object was found, parse information. $this->transient = true; $this->sitemap = $sitemap_cache_data->get_sitemap(); $this->bad_sitemap = !$sitemap_cache_data->is_usable(); return true; }
/** * Setup context for static calls. */ public function init() { self::$is_enabled = $this->is_enabled(); }