From 6f0894935c0610d0c15f5556794d8ad72b98d33e Mon Sep 17 00:00:00 2001 From: Mats Mikkel Rummelhoff Date: Thu, 5 Sep 2024 14:54:37 +0200 Subject: [PATCH] Fix missing priority values in sitemaps. Bump to 3.1.1 --- CHANGELOG.md | 4 ++++ composer.json | 2 +- src/helpers/SEOMateHelper.php | 4 ++-- src/helpers/SitemapHelper.php | 5 ++++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3638180..0576860 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # SEOMate Changelog +## 3.1.1 - 2024-09-05 +### Fixed +- Fixed a regression error introduced in 3.1.0, where SEOMate could fail to render sitemap priority values + ## 3.1.0 - 2024-08-24 ### Changed - SEOMate now strips preview and token params from canonical and alternate URLs diff --git a/composer.json b/composer.json index 61b26ab..078c559 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "vaersaagod/seomate", "description": "SEO, mate! It's important.", "type": "craft-plugin", - "version": "3.1.0", + "version": "3.1.1", "keywords": [ "craft", "cms", diff --git a/src/helpers/SEOMateHelper.php b/src/helpers/SEOMateHelper.php index 2f81911..087c41e 100644 --- a/src/helpers/SEOMateHelper.php +++ b/src/helpers/SEOMateHelper.php @@ -478,10 +478,10 @@ public static function isElementPreviewable(ElementInterface $element): bool * @param mixed $url * @return string */ - public static function stripTokenParams(mixed $url): string + public static function stripTokenParams(mixed $url): mixed { if (empty($url) || !is_string($url)) { - return ''; + return $url; } $queryParamsToRemove = [ Craft::$app->getConfig()->getGeneral()->tokenParam, diff --git a/src/helpers/SitemapHelper.php b/src/helpers/SitemapHelper.php index 05faab8..fed7078 100644 --- a/src/helpers/SitemapHelper.php +++ b/src/helpers/SitemapHelper.php @@ -222,7 +222,10 @@ public static function addUrlsToSitemap(\DOMDocument $document, \DOMElement $sit unset($url['alternate']); foreach ($url as $key => $val) { - $node = $document->createElement($key, SEOMateHelper::stripTokenParams($val)); + if ($key === 'loc') { + $val = SEOMateHelper::stripTokenParams($val); + } + $node = $document->createElement($key, $val); $topNode->appendChild($node); }