@@ -46,12 +46,12 @@ discard block |
||
| 46 | 46 | $siteUrl = MetaValue::parseString($siteUrl); |
| 47 | 47 | // Extract out just the path part |
| 48 | 48 | $parts = self::decomposeUrl($path); |
| 49 | - $path = $parts['path'] . $parts['suffix']; |
|
| 49 | + $path = $parts['path'].$parts['suffix']; |
|
| 50 | 50 | $url = self::mergeUrlWithPath($siteUrl, $path); |
| 51 | 51 | // Handle trailing slashes properly for generated URLs |
| 52 | 52 | $generalConfig = Craft::$app->getConfig()->getGeneral(); |
| 53 | 53 | if ($generalConfig->addTrailingSlashesToUrls && !preg_match('/(.+\?.*)|(\.[^\/]+$)/', $url)) { |
| 54 | - $url = rtrim($url, '/') . '/'; |
|
| 54 | + $url = rtrim($url, '/').'/'; |
|
| 55 | 55 | } |
| 56 | 56 | if (!$generalConfig->addTrailingSlashesToUrls) { |
| 57 | 57 | $url = rtrim($url, '/'); |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - return rtrim($url, '/') . '/' . ltrim(substr($path, $overlap), '/'); |
|
| 87 | + return rtrim($url, '/').'/'.ltrim(substr($path, $overlap), '/'); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | // Handle trailing slashes properly for generated URLs |
| 153 | 153 | $generalConfig = Craft::$app->getConfig()->getGeneral(); |
| 154 | 154 | if ($generalConfig->addTrailingSlashesToUrls && !preg_match('/(.+\?.*)|(\.[^\/]+$)/', $url)) { |
| 155 | - $url = rtrim($url, '/') . '/'; |
|
| 155 | + $url = rtrim($url, '/').'/'; |
|
| 156 | 156 | } |
| 157 | 157 | if (!$generalConfig->addTrailingSlashesToUrls) { |
| 158 | 158 | $url = rtrim($url, '/'); |
@@ -172,13 +172,13 @@ discard block |
||
| 172 | 172 | $urlParts = parse_url($url); |
| 173 | 173 | $encodedUrl = ""; |
| 174 | 174 | if (isset($urlParts['scheme'])) { |
| 175 | - $encodedUrl .= $urlParts['scheme'] . '://'; |
|
| 175 | + $encodedUrl .= $urlParts['scheme'].'://'; |
|
| 176 | 176 | } |
| 177 | 177 | if (isset($urlParts['host'])) { |
| 178 | 178 | $encodedUrl .= $urlParts['host']; |
| 179 | 179 | } |
| 180 | 180 | if (isset($urlParts['port'])) { |
| 181 | - $encodedUrl .= ':' . $urlParts['port']; |
|
| 181 | + $encodedUrl .= ':'.$urlParts['port']; |
|
| 182 | 182 | } |
| 183 | 183 | if (isset($urlParts['path'])) { |
| 184 | 184 | $encodedUrl .= $urlParts['path']; |
@@ -188,15 +188,15 @@ discard block |
||
| 188 | 188 | foreach ($query as $j => $value) { |
| 189 | 189 | $value = explode('=', $value, 2); |
| 190 | 190 | if (count($value) === 2) { |
| 191 | - $query[$j] = urlencode($value[0]) . '=' . urlencode($value[1]); |
|
| 191 | + $query[$j] = urlencode($value[0]).'='.urlencode($value[1]); |
|
| 192 | 192 | } else { |
| 193 | 193 | $query[$j] = urlencode($value[0]); |
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | - $encodedUrl .= '?' . implode('&', $query); |
|
| 196 | + $encodedUrl .= '?'.implode('&', $query); |
|
| 197 | 197 | } |
| 198 | 198 | if (isset($urlParts['fragment'])) { |
| 199 | - $encodedUrl .= '#' . $urlParts['fragment']; |
|
| 199 | + $encodedUrl .= '#'.$urlParts['fragment']; |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | return $encodedUrl; |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | if ($siteId !== null) { |
| 237 | 237 | $site = $sites->getSiteById($siteId, true); |
| 238 | 238 | if (!$site) { |
| 239 | - throw new Exception('Invalid site ID: ' . $siteId); |
|
| 239 | + throw new Exception('Invalid site ID: '.$siteId); |
|
| 240 | 240 | } |
| 241 | 241 | } |
| 242 | 242 | |
@@ -260,11 +260,11 @@ discard block |
||
| 260 | 260 | |
| 261 | 261 | if (filter_var($pathOrUrl, FILTER_VALIDATE_URL)) { |
| 262 | 262 | $url_parts = parse_url($pathOrUrl); |
| 263 | - $result['prefix'] = $url_parts['scheme'] . '://' . $url_parts['host']; |
|
| 263 | + $result['prefix'] = $url_parts['scheme'].'://'.$url_parts['host']; |
|
| 264 | 264 | $result['path'] = $url_parts['path'] ?? ''; |
| 265 | 265 | $result['suffix'] = ''; |
| 266 | - $result['suffix'] .= empty($url_parts['query']) ? '' : '?' . $url_parts['query']; |
|
| 267 | - $result['suffix'] .= empty($url_parts['fragment']) ? '' : '#' . $url_parts['fragment']; |
|
| 266 | + $result['suffix'] .= empty($url_parts['query']) ? '' : '?'.$url_parts['query']; |
|
| 267 | + $result['suffix'] .= empty($url_parts['fragment']) ? '' : '#'.$url_parts['fragment']; |
|
| 268 | 268 | } else { |
| 269 | 269 | $result['prefix'] = ''; |
| 270 | 270 | $result['path'] = $pathOrUrl; |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | $lastSegment = end($segments); |
| 350 | 350 | $site = Craft::$app->getSites()->getSiteByHandle($lastSegment); |
| 351 | 351 | if ($site !== null) { |
| 352 | - $siteSuffix = '/' . $lastSegment; |
|
| 352 | + $siteSuffix = '/'.$lastSegment; |
|
| 353 | 353 | } |
| 354 | 354 | } |
| 355 | 355 | $currentUser = Craft::$app->getUser()->getIdentity(); |
@@ -357,31 +357,31 @@ discard block |
||
| 357 | 357 | if ($currentUser->can('seomatic:dashboard')) { |
| 358 | 358 | $subNavs['dashboard'] = [ |
| 359 | 359 | 'label' => Craft::t('seomatic', 'Dashboard'), |
| 360 | - 'url' => 'seomatic/dashboard' . $siteSuffix, |
|
| 360 | + 'url' => 'seomatic/dashboard'.$siteSuffix, |
|
| 361 | 361 | ]; |
| 362 | 362 | } |
| 363 | 363 | if ($currentUser->can('seomatic:global-meta')) { |
| 364 | 364 | $subNavs['global'] = [ |
| 365 | 365 | 'label' => Craft::t('seomatic', 'Global SEO'), |
| 366 | - 'url' => 'seomatic/global/general' . $siteSuffix, |
|
| 366 | + 'url' => 'seomatic/global/general'.$siteSuffix, |
|
| 367 | 367 | ]; |
| 368 | 368 | } |
| 369 | 369 | if ($currentUser->can('seomatic:content-meta')) { |
| 370 | 370 | $subNavs['content'] = [ |
| 371 | 371 | 'label' => Craft::t('seomatic', 'Content SEO'), |
| 372 | - 'url' => 'seomatic/content' . $siteSuffix, |
|
| 372 | + 'url' => 'seomatic/content'.$siteSuffix, |
|
| 373 | 373 | ]; |
| 374 | 374 | } |
| 375 | 375 | if ($currentUser->can('seomatic:site-settings')) { |
| 376 | 376 | $subNavs['site'] = [ |
| 377 | 377 | 'label' => Craft::t('seomatic', 'Site Settings'), |
| 378 | - 'url' => 'seomatic/site/identity' . $siteSuffix, |
|
| 378 | + 'url' => 'seomatic/site/identity'.$siteSuffix, |
|
| 379 | 379 | ]; |
| 380 | 380 | } |
| 381 | 381 | if ($currentUser->can('seomatic:tracking-scripts')) { |
| 382 | 382 | $subNavs['tracking'] = [ |
| 383 | 383 | 'label' => Craft::t('seomatic', 'Tracking Scripts'), |
| 384 | - 'url' => 'seomatic/tracking/gtag' . $siteSuffix, |
|
| 384 | + 'url' => 'seomatic/tracking/gtag'.$siteSuffix, |
|
| 385 | 385 | ]; |
| 386 | 386 | } |
| 387 | 387 | $editableSettings = true; |
@@ -575,14 +575,14 @@ discard block |
||
| 575 | 575 | $element = $e->sender; |
| 576 | 576 | if ($element->uri !== null) { |
| 577 | 577 | $e->previewTargets[] = [ |
| 578 | - 'label' => ' |
|
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | // Output some info if this is a console app |
| 112 | 112 | if ($job && Craft::$app instanceof ConsoleApplication) { |
| 113 | - echo $job->description . PHP_EOL; |
|
| 113 | + echo $job->description.PHP_EOL; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | $lines = []; |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | if ($multiSite) { |
| 138 | 138 | $urlsetLine .= ' xmlns:xhtml="http://www.w3.org/1999/xhtml"'; |
| 139 | 139 | } |
| 140 | - if ((bool)$metaBundle->metaSitemapVars->newsSitemap) { |
|
| 140 | + if ((bool) $metaBundle->metaSitemapVars->newsSitemap) { |
|
| 141 | 141 | $urlsetLine .= ' xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"'; |
| 142 | 142 | } |
| 143 | 143 | $urlsetLine .= '>'; |
@@ -172,8 +172,8 @@ discard block |
||
| 172 | 172 | while ($currentElement < $totalElements) { |
| 173 | 173 | $elements = $paginator->getPageResults(); |
| 174 | 174 | if (Craft::$app instanceof ConsoleApplication) { |
| 175 | - echo 'Query ' . $paginator->getCurrentPage() . '/' . $paginator->getTotalPages() |
|
| 176 | - . ' - elements: ' . $paginator->getTotalResults() |
|
| 175 | + echo 'Query '.$paginator->getCurrentPage().'/'.$paginator->getTotalPages() |
|
| 176 | + . ' - elements: '.$paginator->getTotalResults() |
|
| 177 | 177 | . PHP_EOL; |
| 178 | 178 | } |
| 179 | 179 | /** @var Element $element */ |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | } |
| 186 | 186 | // Output some info if this is a console app |
| 187 | 187 | if (Craft::$app instanceof ConsoleApplication) { |
| 188 | - echo "Processing element {$currentElement}/{$totalElements} - {$element->title}" . PHP_EOL; |
|
| 188 | + echo "Processing element {$currentElement}/{$totalElements} - {$element->title}".PHP_EOL; |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | $metaBundle->metaSitemapVars->setAttributes($stashedSitemapAttrs, false); |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | } |
| 231 | 231 | $canonicalUrl = UrlHelper::absoluteUrlWithProtocol($canonicalUrl); |
| 232 | 232 | if ($url !== $canonicalUrl) { |
| 233 | - Craft::info("Excluding URL: {$url} from the sitemap because it does not match the Canonical URL: {$canonicalUrl} - " . $metaBundle->metaGlobalVars->canonicalUrl . " - " . $element->uri); |
|
| 233 | + Craft::info("Excluding URL: {$url} from the sitemap because it does not match the Canonical URL: {$canonicalUrl} - ".$metaBundle->metaGlobalVars->canonicalUrl." - ".$element->uri); |
|
| 234 | 234 | continue; |
| 235 | 235 | } |
| 236 | 236 | } |
@@ -288,12 +288,12 @@ discard block |
||
| 288 | 288 | if ($primarySiteId === $altSourceSiteId && Seomatic::$settings->addXDefaultHrefLang) { |
| 289 | 289 | $lines[] = '<xhtml:link rel="alternate"' |
| 290 | 290 | . ' hreflang="x-default"' |
| 291 | - . ' href="' . Html::encode($altUrl) . '"' |
|
| 291 | + . ' href="'.Html::encode($altUrl).'"' |
|
| 292 | 292 | . ' />'; |
| 293 | 293 | } |
| 294 | 294 | $lines[] = '<xhtml:link rel="alternate"' |
| 295 | - . ' hreflang="' . $altSiteSettings['language'] . '"' |
|
| 296 | - . ' href="' . Html::encode($altUrl) . '"' |
|
| 295 | + . ' hreflang="'.$altSiteSettings['language'].'"' |
|
| 296 | + . ' href="'.Html::encode($altUrl).'"' |
|
| 297 | 297 | . ' />'; |
| 298 | 298 | } |
| 299 | 299 | } |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | } |
| 303 | 303 | } |
| 304 | 304 | // Handle news sitemaps https://developers.google.com/search/docs/crawling-indexing/sitemaps/news-sitemap |
| 305 | - if ((bool)$metaBundle->metaSitemapVars->newsSitemap) { |
|
| 305 | + if ((bool) $metaBundle->metaSitemapVars->newsSitemap) { |
|
| 306 | 306 | $now = new DateTime(); |
| 307 | 307 | $interval = $now->diff($dateUpdated); |
| 308 | 308 | if ($interval->days <= 2) { |
@@ -312,11 +312,11 @@ discard block |
||
| 312 | 312 | } |
| 313 | 313 | $lines[] = '<news:news>'; |
| 314 | 314 | $lines[] = '<news:publication>'; |
| 315 | - $lines[] = '<news:name>' . $metaBundle->metaSitemapVars->newsPublicationName . '</news:name>'; |
|
| 316 | - $lines[] = '<news:language>' . $language . '</news:language>'; |
|
| 315 | + $lines[] = '<news:name>'.$metaBundle->metaSitemapVars->newsPublicationName.'</news:name>'; |
|
| 316 | + $lines[] = '<news:language>'.$language.'</news:language>'; |
|
| 317 | 317 | $lines[] = '</news:publication>'; |
| 318 | - $lines[] = '<news:publication_date>' . $dateUpdated->format(DateTime::W3C) . '</news:publication_date>'; |
|
| 319 | - $lines[] = '<news:title>' . $element->title . '</news:title>'; |
|
| 318 | + $lines[] = '<news:publication_date>'.$dateUpdated->format(DateTime::W3C).'</news:publication_date>'; |
|
| 319 | + $lines[] = '<news:title>'.$element->title.'</news:title>'; |
|
| 320 | 320 | $lines[] = '</news:news>'; |
| 321 | 321 | } |
| 322 | 322 | } |
@@ -414,11 +414,11 @@ discard block |
||
| 414 | 414 | $lines[] = '</urlset>'; |
| 415 | 415 | |
| 416 | 416 | $cache = Craft::$app->getCache(); |
| 417 | - $cacheKey = SitemapTemplate::CACHE_KEY . $groupId . $type . $handle . $siteId; |
|
| 417 | + $cacheKey = SitemapTemplate::CACHE_KEY.$groupId.$type.$handle.$siteId; |
|
| 418 | 418 | $dependency = new TagDependency([ |
| 419 | 419 | 'tags' => [ |
| 420 | 420 | SitemapTemplate::GLOBAL_SITEMAP_CACHE_TAG, |
| 421 | - SitemapTemplate::SITEMAP_CACHE_TAG . $handle . $siteId, |
|
| 421 | + SitemapTemplate::SITEMAP_CACHE_TAG.$handle.$siteId, |
|
| 422 | 422 | ], |
| 423 | 423 | ]); |
| 424 | 424 | $lines = implode('', $lines); |
@@ -431,10 +431,10 @@ discard block |
||
| 431 | 431 | $result = $cache->set($cacheKey, $lines, $cacheDuration, $dependency); |
| 432 | 432 | // Remove the queue job id from the cache too |
| 433 | 433 | $cache->delete($queueJobCacheKey); |
| 434 | - Craft::debug('Sitemap cache result: ' . print_r($result, true) . ' for cache key: ' . $cacheKey, __METHOD__); |
|
| 434 | + Craft::debug('Sitemap cache result: '.print_r($result, true).' for cache key: '.$cacheKey, __METHOD__); |
|
| 435 | 435 | // Output some info if this is a console app |
| 436 | 436 | if (Craft::$app instanceof ConsoleApplication) { |
| 437 | - echo 'Sitemap cache result: ' . print_r($result, true) . ' for cache key: ' . $cacheKey . PHP_EOL; |
|
| 437 | + echo 'Sitemap cache result: '.print_r($result, true).' for cache key: '.$cacheKey.PHP_EOL; |
|
| 438 | 438 | } |
| 439 | 439 | // If the FastCGI Cache Bust plugin is installed, clear its caches too |
| 440 | 440 | /** @var ?FastcgiCacheBust $plugin */ |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | |
| 519 | 519 | $attributes = array_intersect_key( |
| 520 | 520 | $attributes, |
| 521 | - array_flip((array)$seoSettingsField->sitemapEnabledFields) |
|
| 521 | + array_flip((array) $seoSettingsField->sitemapEnabledFields) |
|
| 522 | 522 | ); |
| 523 | 523 | $attributes = array_filter( |
| 524 | 524 | $attributes, |
@@ -550,7 +550,7 @@ discard block |
||
| 550 | 550 | */ |
| 551 | 551 | protected static function assetSitemapItem(Asset $asset, MetaBundle $metaBundle, array &$lines) |
| 552 | 552 | { |
| 553 | - if ((bool)$asset->enabledForSite && $asset->getUrl() !== null) { |
|
| 553 | + if ((bool) $asset->enabledForSite && $asset->getUrl() !== null) { |
|
| 554 | 554 | switch ($asset->kind) { |
| 555 | 555 | case 'image': |
| 556 | 556 | $lines[] = '<image:image>'; |
@@ -562,9 +562,9 @@ discard block |
||
| 562 | 562 | $fieldName = $row['field'] ?? ''; |
| 563 | 563 | $propName = $row['property'] ?? ''; |
| 564 | 564 | if (!empty($fieldName) && !empty($asset[$fieldName]) && !empty($propName)) { |
| 565 | - $lines[] = '<image:' . $propName . '>'; |
|
| 565 | + $lines[] = '<image:'.$propName.'>'; |
|
| 566 | 566 | $lines[] = Html::encode($asset[$fieldName]); |
| 567 | - $lines[] = '</image:' . $propName . '>'; |
|
| 567 | + $lines[] = '</image:'.$propName.'>'; |
|
| 568 | 568 | } |
| 569 | 569 | } |
| 570 | 570 | $lines[] = '</image:image>'; |
@@ -580,9 +580,9 @@ discard block |
||
| 580 | 580 | $fieldName = $row['field'] ?? ''; |
| 581 | 581 | $propName = $row['property'] ?? ''; |
| 582 | 582 | if (!empty($fieldName) && !empty($asset[$fieldName]) && !empty($propName)) { |
| 583 | - $lines[] = '<video:' . $propName . '>'; |
|
| 583 | + $lines[] = '<video:'.$propName.'>'; |
|
| 584 | 584 | $lines[] = Html::encode($asset[$fieldName]); |
| 585 | - $lines[] = '</video:' . $propName . '>'; |
|
| 585 | + $lines[] = '</video:'.$propName.'>'; |
|
| 586 | 586 | } |
| 587 | 587 | } |
| 588 | 588 | $lines[] = '</video:video>'; |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | */ |
| 599 | 599 | protected static function assetFilesSitemapLink(Asset $asset, MetaBundle $metaBundle, array &$lines) |
| 600 | 600 | { |
| 601 | - if ((bool)$asset->enabledForSite && $asset->getUrl() !== null) { |
|
| 601 | + if ((bool) $asset->enabledForSite && $asset->getUrl() !== null) { |
|
| 602 | 602 | if (in_array($asset->kind, SitemapTemplate::FILE_TYPES, false)) { |
| 603 | 603 | $dateUpdated = $asset->dateUpdated ?? $asset->dateCreated ?? new DateTime(); |
| 604 | 604 | $lines[] = '<url>'; |