You are here

function xmlsitemap_cron in XML sitemap 7.2

Same name and namespace in other branches
  1. 8 xmlsitemap.module \xmlsitemap_cron()
  2. 5.2 xmlsitemap/xmlsitemap.module \xmlsitemap_cron()
  3. 5 xmlsitemap.module \xmlsitemap_cron()
  4. 6.2 xmlsitemap.module \xmlsitemap_cron()
  5. 2.x xmlsitemap.module \xmlsitemap_cron()

Implements hook_cron().

@todo Use new Queue system. Need to add {sitemap}.queued. @todo Regenerate one at a time?

File

./xmlsitemap.module, line 248
xmlsitemap XML sitemap

Code

function xmlsitemap_cron() {

  // If there were no new or changed links, skip.
  if (!variable_get('xmlsitemap_regenerate_needed', FALSE)) {
    return;
  }

  // If cron sitemap file regeneration is disabled, stop.
  if (variable_get('xmlsitemap_disable_cron_regeneration', 0)) {
    return;
  }

  // If the minimum sitemap lifetime hasn't been passed, skip.
  $lifetime = REQUEST_TIME - variable_get('xmlsitemap_generated_last', 0);
  if ($lifetime < variable_get('xmlsitemap_minimum_lifetime', 0)) {
    return;
  }

  // Regenerate the sitemap XML files.
  module_load_include('generate.inc', 'xmlsitemap');
  xmlsitemap_run_unprogressive_batch('xmlsitemap_regenerate_batch');
}