@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | } |
150 | 150 | |
151 | 151 | $cache = Craft::$app->getCache(); |
152 | - $pageCacheSuffix = 's' . (int)$metaBundle->metaSitemapVars->sitemapPageSize . 'p' . $page; |
|
152 | + $pageCacheSuffix = 's'.(int) $metaBundle->metaSitemapVars->sitemapPageSize.'p'.$page; |
|
153 | 153 | |
154 | - $uniqueKey = $groupId . $type . $handle . $siteId . $pageCacheSuffix; |
|
155 | - $cacheKey = self::CACHE_KEY . $uniqueKey; |
|
154 | + $uniqueKey = $groupId.$type.$handle.$siteId.$pageCacheSuffix; |
|
155 | + $cacheKey = self::CACHE_KEY.$uniqueKey; |
|
156 | 156 | $result = $cache->get($cacheKey); |
157 | 157 | |
158 | 158 | // If the sitemap isn't cached, start a job to create it |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | $dependency = new TagDependency([ |
172 | 172 | 'tags' => [ |
173 | 173 | self::GLOBAL_SITEMAP_CACHE_TAG, |
174 | - self::SITEMAP_CACHE_TAG . $handle . $siteId . $pageCacheSuffix, |
|
174 | + self::SITEMAP_CACHE_TAG.$handle.$siteId.$pageCacheSuffix, |
|
175 | 175 | ], |
176 | 176 | ]); |
177 | 177 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | |
184 | 184 | // Output some info if this is a console app |
185 | 185 | if (Craft::$app instanceof ConsoleApplication) { |
186 | - echo 'Sitemap cache result: ' . print_r($result, true) . ' for cache key: ' . $cacheKey . PHP_EOL; |
|
186 | + echo 'Sitemap cache result: '.print_r($result, true).' for cache key: '.$cacheKey.PHP_EOL; |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | // If the FastCGI Cache Bust plugin is installed, clear its caches too |
@@ -211,11 +211,11 @@ discard block |
||
211 | 211 | // Return an empty XML document |
212 | 212 | $lines[] = '<?xml version="1.0" encoding="UTF-8"?>'; |
213 | 213 | $lines[] = '<?xml-stylesheet type="text/xsl" href="sitemap-empty.xsl"?>'; |
214 | - $lines[] = '<!-- ' . Craft::t('seomatic', 'This sitemap has not been generated yet.') . ' -->'; |
|
215 | - $lines[] = '<!-- ' . Craft::t('seomatic', 'If you are seeing this in local dev or an') . ' -->'; |
|
216 | - $lines[] = '<!-- ' . Craft::t('seomatic', 'environment with `devMode` on, caches only') . ' -->'; |
|
217 | - $lines[] = '<!-- ' . Craft::t('seomatic', 'last for 30 seconds in local dev, so it is') . ' -->'; |
|
218 | - $lines[] = '<!-- ' . Craft::t('seomatic', 'normal for the sitemap to not be cached.') . ' -->'; |
|
214 | + $lines[] = '<!-- '.Craft::t('seomatic', 'This sitemap has not been generated yet.').' -->'; |
|
215 | + $lines[] = '<!-- '.Craft::t('seomatic', 'If you are seeing this in local dev or an').' -->'; |
|
216 | + $lines[] = '<!-- '.Craft::t('seomatic', 'environment with `devMode` on, caches only').' -->'; |
|
217 | + $lines[] = '<!-- '.Craft::t('seomatic', 'last for 30 seconds in local dev, so it is').' -->'; |
|
218 | + $lines[] = '<!-- '.Craft::t('seomatic', 'normal for the sitemap to not be cached.').' -->'; |
|
219 | 219 | $lines[] = '<urlset>'; |
220 | 220 | $lines[] = '</urlset>'; |
221 | 221 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | return $lines; |
225 | 225 | } else { |
226 | 226 | if (Craft::$app instanceof ConsoleApplication) { |
227 | - echo 'Found in cache' . PHP_EOL; |
|
227 | + echo 'Found in cache'.PHP_EOL; |
|
228 | 228 | } |
229 | 229 | } |
230 | 230 | |
@@ -240,9 +240,9 @@ discard block |
||
240 | 240 | public function invalidateCache(string $handle, int $siteId) |
241 | 241 | { |
242 | 242 | $cache = Craft::$app->getCache(); |
243 | - TagDependency::invalidate($cache, self::SITEMAP_CACHE_TAG . $handle . $siteId); |
|
243 | + TagDependency::invalidate($cache, self::SITEMAP_CACHE_TAG.$handle.$siteId); |
|
244 | 244 | Craft::info( |
245 | - 'Sitemap cache cleared: ' . $handle, |
|
245 | + 'Sitemap cache cleared: '.$handle, |
|
246 | 246 | __METHOD__ |
247 | 247 | ); |
248 | 248 | } |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | // Constants |
44 | 44 | // ========================================================================= |
45 | 45 | |
46 | - public const SEOMATIC_SITEMAPINDEX_CONTAINER = Seomatic::SEOMATIC_HANDLE . SitemapIndexTemplate::TEMPLATE_TYPE; |
|
46 | + public const SEOMATIC_SITEMAPINDEX_CONTAINER = Seomatic::SEOMATIC_HANDLE.SitemapIndexTemplate::TEMPLATE_TYPE; |
|
47 | 47 | |
48 | - public const SEOMATIC_SITEMAP_CONTAINER = Seomatic::SEOMATIC_HANDLE . SitemapTemplate::TEMPLATE_TYPE; |
|
48 | + public const SEOMATIC_SITEMAP_CONTAINER = Seomatic::SEOMATIC_HANDLE.SitemapTemplate::TEMPLATE_TYPE; |
|
49 | 49 | |
50 | - public const SEOMATIC_SITEMAPCUSTOM_CONTAINER = Seomatic::SEOMATIC_HANDLE . SitemapCustomTemplate::TEMPLATE_TYPE; |
|
50 | + public const SEOMATIC_SITEMAPCUSTOM_CONTAINER = Seomatic::SEOMATIC_HANDLE.SitemapCustomTemplate::TEMPLATE_TYPE; |
|
51 | 51 | |
52 | 52 | public const SEARCH_ENGINE_SUBMISSION_URLS = [ |
53 | 53 | ]; |
@@ -238,19 +238,19 @@ discard block |
||
238 | 238 | $siteId = $groupSiteIds[0]; |
239 | 239 | $sitemapIndexUrl = $this->sitemapIndexUrlForSiteId($siteId); |
240 | 240 | if (!empty($sitemapIndexUrl)) { |
241 | - $submissionUrl = $url . urlencode($sitemapIndexUrl); |
|
241 | + $submissionUrl = $url.urlencode($sitemapIndexUrl); |
|
242 | 242 | // create new guzzle client |
243 | 243 | $guzzleClient = Craft::createGuzzleClient(['timeout' => 5, 'connect_timeout' => 5]); |
244 | 244 | // Submit the sitemap index to each search engine |
245 | 245 | try { |
246 | 246 | $guzzleClient->post($submissionUrl); |
247 | 247 | Craft::info( |
248 | - 'Sitemap index submitted to: ' . $submissionUrl, |
|
248 | + 'Sitemap index submitted to: '.$submissionUrl, |
|
249 | 249 | __METHOD__ |
250 | 250 | ); |
251 | 251 | } catch (\Exception $e) { |
252 | 252 | Craft::error( |
253 | - 'Error submitting sitemap index to: ' . $submissionUrl . ' - ' . $e->getMessage(), |
|
253 | + 'Error submitting sitemap index to: '.$submissionUrl.' - '.$e->getMessage(), |
|
254 | 254 | __METHOD__ |
255 | 255 | ); |
256 | 256 | } |
@@ -312,19 +312,19 @@ discard block |
||
312 | 312 | foreach ($searchEngineUrls as &$url) { |
313 | 313 | $sitemapUrl = $this->sitemapUrlForBundle($sourceBundleType, $sourceHandle, $sourceSiteId); |
314 | 314 | if (!empty($sitemapUrl)) { |
315 | - $submissionUrl = $url . urlencode($sitemapUrl); |
|
315 | + $submissionUrl = $url.urlencode($sitemapUrl); |
|
316 | 316 | // create new guzzle client |
317 | 317 | $guzzleClient = Craft::createGuzzleClient(['timeout' => 5, 'connect_timeout' => 5]); |
318 | 318 | // Submit the sitemap index to each search engine |
319 | 319 | try { |
320 | 320 | $guzzleClient->post($submissionUrl); |
321 | 321 | Craft::info( |
322 | - 'Sitemap index submitted to: ' . $submissionUrl, |
|
322 | + 'Sitemap index submitted to: '.$submissionUrl, |
|
323 | 323 | __METHOD__ |
324 | 324 | ); |
325 | 325 | } catch (\Exception $e) { |
326 | 326 | Craft::error( |
327 | - 'Error submitting sitemap index to: ' . $submissionUrl . ' - ' . $e->getMessage(), |
|
327 | + 'Error submitting sitemap index to: '.$submissionUrl.' - '.$e->getMessage(), |
|
328 | 328 | __METHOD__ |
329 | 329 | ); |
330 | 330 | } |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | . '-' |
366 | 366 | . $metaBundle->sourceSiteId |
367 | 367 | . '-sitemap' |
368 | - . (!empty($page) ? '-p' . $page : '') |
|
368 | + . (!empty($page) ? '-p'.$page : '') |
|
369 | 369 | . '.xml', |
370 | 370 | null, |
371 | 371 | null, |
@@ -394,19 +394,19 @@ discard block |
||
394 | 394 | foreach ($searchEngineUrls as &$url) { |
395 | 395 | $sitemapUrl = $this->sitemapCustomUrlForSiteId($siteId); |
396 | 396 | if (!empty($sitemapUrl)) { |
397 | - $submissionUrl = $url . urlencode($sitemapUrl); |
|
397 | + $submissionUrl = $url.urlencode($sitemapUrl); |
|
398 | 398 | // create new guzzle client |
399 | 399 | $guzzleClient = Craft::createGuzzleClient(['timeout' => 5, 'connect_timeout' => 5]); |
400 | 400 | // Submit the sitemap index to each search engine |
401 | 401 | try { |
402 | 402 | $guzzleClient->post($submissionUrl); |
403 | 403 | Craft::info( |
404 | - 'Sitemap Custom submitted to: ' . $submissionUrl, |
|
404 | + 'Sitemap Custom submitted to: '.$submissionUrl, |
|
405 | 405 | __METHOD__ |
406 | 406 | ); |
407 | 407 | } catch (\Exception $e) { |
408 | 408 | Craft::error( |
409 | - 'Error submitting sitemap index to: ' . $submissionUrl . ' - ' . $e->getMessage(), |
|
409 | + 'Error submitting sitemap index to: '.$submissionUrl.' - '.$e->getMessage(), |
|
410 | 410 | __METHOD__ |
411 | 411 | ); |
412 | 412 | } |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | } |
485 | 485 | |
486 | 486 | foreach ($sites as $site) { |
487 | - $result .= 'sitemap: ' . $this->sitemapIndexUrlForSiteId($site->id) . PHP_EOL; |
|
487 | + $result .= 'sitemap: '.$this->sitemapIndexUrlForSiteId($site->id).PHP_EOL; |
|
488 | 488 | } |
489 | 489 | |
490 | 490 | return rtrim($result, PHP_EOL); |
@@ -516,9 +516,9 @@ discard block |
||
516 | 516 | // Since we want a stale-while-revalidate pattern, only invalidate the cache if we're asked to |
517 | 517 | if ($invalidateCache) { |
518 | 518 | $cache = Craft::$app->getCache(); |
519 | - TagDependency::invalidate($cache, SitemapTemplate::SITEMAP_CACHE_TAG . $handle . $siteId); |
|
519 | + TagDependency::invalidate($cache, SitemapTemplate::SITEMAP_CACHE_TAG.$handle.$siteId); |
|
520 | 520 | Craft::info( |
521 | - 'Sitemap cache cleared: ' . $handle, |
|
521 | + 'Sitemap cache cleared: '.$handle, |
|
522 | 522 | __METHOD__ |
523 | 523 | ); |
524 | 524 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | /** |
45 | 45 | * @var bool|array |
46 | 46 | */ |
47 | - protected array|bool|int $allowAnonymous = [ |
|
47 | + protected array | bool | int $allowAnonymous = [ |
|
48 | 48 | ]; |
49 | 49 | |
50 | 50 | // Public Methods |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function actionGenerate() |
70 | 70 | { |
71 | - echo 'Generating sitemap' . PHP_EOL; |
|
71 | + echo 'Generating sitemap'.PHP_EOL; |
|
72 | 72 | if ($this->siteId !== null) { |
73 | 73 | $siteIds[] = $this->siteId; |
74 | 74 | } else { |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $sitemap = SitemapTemplate::create(); |
116 | 116 | if ($site) { |
117 | 117 | for ($pageNum = 1; $pageNum <= $pageCount; $pageNum++) { |
118 | - echo sprintf('Generating page %d of %d' . PHP_EOL, $pageNum, $pageCount); |
|
118 | + echo sprintf('Generating page %d of %d'.PHP_EOL, $pageNum, $pageCount); |
|
119 | 119 | $sitemap->render([ |
120 | 120 | 'groupId' => $site->groupId, |
121 | 121 | 'siteId' => $metaBundle->sourceSiteId, |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | // Generate the sitemap so it is in the cache |
128 | 128 | } |
129 | 129 | |
130 | - echo '---' . PHP_EOL; |
|
130 | + echo '---'.PHP_EOL; |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | if ($multiSite) { |
121 | 121 | $urlsetLine .= ' xmlns:xhtml="http://www.w3.org/1999/xhtml"'; |
122 | 122 | } |
123 | - if ((bool)$metaBundle->metaSitemapVars->newsSitemap) { |
|
123 | + if ((bool) $metaBundle->metaSitemapVars->newsSitemap) { |
|
124 | 124 | $urlsetLine .= ' xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"'; |
125 | 125 | } |
126 | 126 | $urlsetLine .= '>'; |
@@ -188,13 +188,13 @@ discard block |
||
188 | 188 | $paginator->getTotalPages(), |
189 | 189 | $paginator->getTotalResults()); |
190 | 190 | } |
191 | - echo $message . PHP_EOL; |
|
191 | + echo $message.PHP_EOL; |
|
192 | 192 | } |
193 | 193 | /** @var Element $element */ |
194 | 194 | foreach ($elements as $element) { |
195 | 195 | // Output some info if this is a console app |
196 | 196 | if (Craft::$app instanceof ConsoleApplication) { |
197 | - echo "Processing element {$currentElement}/{$totalElements} - {$element->title}" . PHP_EOL; |
|
197 | + echo "Processing element {$currentElement}/{$totalElements} - {$element->title}".PHP_EOL; |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | $metaBundle->metaSitemapVars->setAttributes($stashedSitemapAttrs, false); |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | } |
240 | 240 | $canonicalUrl = UrlHelper::absoluteUrlWithProtocol($canonicalUrl); |
241 | 241 | if ($url !== $canonicalUrl) { |
242 | - Craft::info("Excluding URL: {$url} from the sitemap because it does not match the Canonical URL: {$canonicalUrl} - " . $metaBundle->metaGlobalVars->canonicalUrl . " - " . $element->uri); |
|
242 | + Craft::info("Excluding URL: {$url} from the sitemap because it does not match the Canonical URL: {$canonicalUrl} - ".$metaBundle->metaGlobalVars->canonicalUrl." - ".$element->uri); |
|
243 | 243 | continue; |
244 | 244 | } |
245 | 245 | } |
@@ -297,12 +297,12 @@ discard block |
||
297 | 297 | if ($primarySiteId === $altSourceSiteId && Seomatic::$settings->addXDefaultHrefLang) { |
298 | 298 | $lines[] = '<xhtml:link rel="alternate"' |
299 | 299 | . ' hreflang="x-default"' |
300 | - . ' href="' . Html::encode($altUrl) . '"' |
|
300 | + . ' href="'.Html::encode($altUrl).'"' |
|
301 | 301 | . ' />'; |
302 | 302 | } |
303 | 303 | $lines[] = '<xhtml:link rel="alternate"' |
304 | - . ' hreflang="' . $altSiteSettings['language'] . '"' |
|
305 | - . ' href="' . Html::encode($altUrl) . '"' |
|
304 | + . ' hreflang="'.$altSiteSettings['language'].'"' |
|
305 | + . ' href="'.Html::encode($altUrl).'"' |
|
306 | 306 | . ' />'; |
307 | 307 | } |
308 | 308 | } |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | } |
312 | 312 | } |
313 | 313 | // Handle news sitemaps https://developers.google.com/search/docs/crawling-indexing/sitemaps/news-sitemap |
314 | - if ((bool)$metaBundle->metaSitemapVars->newsSitemap) { |
|
314 | + if ((bool) $metaBundle->metaSitemapVars->newsSitemap) { |
|
315 | 315 | $now = new DateTime(); |
316 | 316 | $interval = $now->diff($dateUpdated); |
317 | 317 | if ($interval->days <= 2) { |
@@ -321,11 +321,11 @@ discard block |
||
321 | 321 | } |
322 | 322 | $lines[] = '<news:news>'; |
323 | 323 | $lines[] = '<news:publication>'; |
324 | - $lines[] = '<news:name>' . $metaBundle->metaSitemapVars->newsPublicationName . '</news:name>'; |
|
325 | - $lines[] = '<news:language>' . $language . '</news:language>'; |
|
324 | + $lines[] = '<news:name>'.$metaBundle->metaSitemapVars->newsPublicationName.'</news:name>'; |
|
325 | + $lines[] = '<news:language>'.$language.'</news:language>'; |
|
326 | 326 | $lines[] = '</news:publication>'; |
327 | - $lines[] = '<news:publication_date>' . $dateUpdated->format(DateTime::W3C) . '</news:publication_date>'; |
|
328 | - $lines[] = '<news:title>' . $element->title . '</news:title>'; |
|
327 | + $lines[] = '<news:publication_date>'.$dateUpdated->format(DateTime::W3C).'</news:publication_date>'; |
|
328 | + $lines[] = '<news:title>'.$element->title.'</news:title>'; |
|
329 | 329 | $lines[] = '</news:news>'; |
330 | 330 | } |
331 | 331 | } |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | |
510 | 510 | $attributes = array_intersect_key( |
511 | 511 | $attributes, |
512 | - array_flip((array)$seoSettingsField->sitemapEnabledFields) |
|
512 | + array_flip((array) $seoSettingsField->sitemapEnabledFields) |
|
513 | 513 | ); |
514 | 514 | $attributes = array_filter( |
515 | 515 | $attributes, |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | */ |
542 | 542 | protected static function assetSitemapItem(Asset $asset, MetaBundle $metaBundle, array &$lines) |
543 | 543 | { |
544 | - if ((bool)$asset->enabledForSite && $asset->getUrl() !== null) { |
|
544 | + if ((bool) $asset->enabledForSite && $asset->getUrl() !== null) { |
|
545 | 545 | switch ($asset->kind) { |
546 | 546 | case 'image': |
547 | 547 | $transform = Craft::$app->getImageTransforms()->getTransformByHandle($metaBundle->metaSitemapVars->sitemapAssetTransform ?? ''); |
@@ -554,9 +554,9 @@ discard block |
||
554 | 554 | $fieldName = $row['field'] ?? ''; |
555 | 555 | $propName = $row['property'] ?? ''; |
556 | 556 | if (!empty($fieldName) && !empty($asset[$fieldName]) && !empty($propName)) { |
557 | - $lines[] = '<image:' . $propName . '>'; |
|
557 | + $lines[] = '<image:'.$propName.'>'; |
|
558 | 558 | $lines[] = Html::encode($asset[$fieldName]); |
559 | - $lines[] = '</image:' . $propName . '>'; |
|
559 | + $lines[] = '</image:'.$propName.'>'; |
|
560 | 560 | } |
561 | 561 | } |
562 | 562 | $lines[] = '</image:image>'; |
@@ -572,9 +572,9 @@ discard block |
||
572 | 572 | $fieldName = $row['field'] ?? ''; |
573 | 573 | $propName = $row['property'] ?? ''; |
574 | 574 | if (!empty($fieldName) && !empty($asset[$fieldName]) && !empty($propName)) { |
575 | - $lines[] = '<video:' . $propName . '>'; |
|
575 | + $lines[] = '<video:'.$propName.'>'; |
|
576 | 576 | $lines[] = Html::encode($asset[$fieldName]); |
577 | - $lines[] = '</video:' . $propName . '>'; |
|
577 | + $lines[] = '</video:'.$propName.'>'; |
|
578 | 578 | } |
579 | 579 | } |
580 | 580 | $lines[] = '</video:video>'; |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | */ |
591 | 591 | protected static function assetFilesSitemapLink(Asset $asset, MetaBundle $metaBundle, array &$lines) |
592 | 592 | { |
593 | - if ((bool)$asset->enabledForSite && $asset->getUrl() !== null) { |
|
593 | + if ((bool) $asset->enabledForSite && $asset->getUrl() !== null) { |
|
594 | 594 | if (in_array($asset->kind, SitemapTemplate::FILE_TYPES, false)) { |
595 | 595 | $dateUpdated = $asset->dateUpdated ?? $asset->dateCreated ?? new DateTime(); |
596 | 596 | $lines[] = '<url>'; |