You are here

function xmlsitemap_sitemap_frequency in XML sitemap 5.2

Same name and namespace in other branches
  1. 6 xmlsitemap.module \xmlsitemap_sitemap_frequency()

Determine the frequency of updates to a link.

Parameters

$interval: The number of seconds since the last change, or the number of seconds between the last change, and the previous change.

Return value

A string representing the update frequency according to the sitemaps.org protocol.

3 calls to xmlsitemap_sitemap_frequency()
theme_xmlsitemap_node_view_news in xmlsitemap_node/xmlsitemap_node.module
Display the nodes of a view as a Google News sitemap.
theme_xmlsitemap_node_view_sitemap in xmlsitemap_node/xmlsitemap_node.module
Display the nodes of a view as an XML sitemap.
_xmlsitemap_output_chunk in xmlsitemap/xmlsitemap.module
Display a chunk of the sitemap.

File

xmlsitemap/xmlsitemap.module, line 437
Creates a sitemap compatible with the sitemaps.org schema.

Code

function xmlsitemap_sitemap_frequency($interval) {
  $frequencies = array(
    'always' => 3600,
    'hourly' => 86400,
    'daily' => 604800,
    'weekly' => 2419200,
    'monthly' => 29030400,
    'yearly' => 100000000,
  );
  if (array_key_exists($interval, $frequencies)) {
    return $interval;
  }
  if ($interval < 0 || !is_numeric($interval)) {
    return 'never';
  }
  foreach ($frequencies as $frequency => $value) {
    if ($interval < $value) {
      break;
    }
  }
  return $frequency;
}