Skip to content

Commit

Permalink
feat: The sitemaps now check enabledForSite to determine whether el…
Browse files Browse the repository at this point in the history
…ements should be included in the sitemap ([#1388](#1388))
  • Loading branch information
khalwat committed Nov 28, 2023
1 parent 5765f11 commit 6a483e2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/helpers/Sitemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,12 @@ public static function generateSitemap(array $params)
$robotsEnabled = $metaBundle->metaGlobalVars->robots !== 'none' &&
$metaBundle->metaGlobalVars->robots !== 'noindex';
}
$enabled = true;
if (Seomatic::$craft34) {
$enabled = $element->getEnabledForSite($metaBundle->sourceSiteId);
}
// Only add in a sitemap entry if it meets our criteria
if ($path !== null && $metaBundle->metaSitemapVars->sitemapUrls && $robotsEnabled) {
if ($enabled && $path !== null && $metaBundle->metaSitemapVars->sitemapUrls && $robotsEnabled) {
// Get the url and canonicalUrl
try {
$url = UrlHelper::siteUrl($path, null, null, $metaBundle->sourceSiteId);
Expand Down Expand Up @@ -233,9 +237,13 @@ public static function generateSitemap(array $params)
$altSourceSiteId
);
if ($altMetaBundle) {
$altEnabled = true;
if (Seomatic::$craft34) {
$altEnabled = $altElement->getEnabledForSite($altMetaBundle->sourceSiteId);
}
// Make sure this entry isn't disabled
self::combineFieldSettings($altElement, $altMetaBundle);
if ($altMetaBundle->metaSitemapVars->sitemapUrls) {
if ($altEnabled && $altMetaBundle->metaSitemapVars->sitemapUrls) {
try {
$altUrl = UrlHelper::siteUrl($altElement->url, null, null, $altSourceId);
} catch (Exception $e) {
Expand Down

0 comments on commit 6a483e2

Please sign in to comment.