You are here

function xmlsitemap_recalculate_changefreq in XML sitemap 2.x

Same name and namespace in other branches
  1. 8 xmlsitemap.module \xmlsitemap_recalculate_changefreq()
  2. 6.2 xmlsitemap.module \xmlsitemap_recalculate_changefreq()
  3. 7.2 xmlsitemap.module \xmlsitemap_recalculate_changefreq()

Recalculate the changefreq of a sitemap link.

Parameters

array $link: A sitemap link array.

1 call to xmlsitemap_recalculate_changefreq()
XmlSitemapUnitTest::testRecalculateChangefreq in tests/src/Functional/XmlSitemapUnitTest.php
Test for xmlsitemap_recalculate_changefreq().

File

./xmlsitemap.module, line 1082
xmlsitemap XML sitemap

Code

function xmlsitemap_recalculate_changefreq(array &$link) {
  $time = \Drupal::time()
    ->getRequestTime();
  $link['changefreq'] = round(($link['changefreq'] * $link['changecount'] + ($time - $link['lastmod'])) / ($link['changecount'] + 1));
  $link['changecount']++;
  $link['lastmod'] = $time;
}