@@ -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>'; |
@@ -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, '/'); |
@@ -73,8 +73,8 @@ discard block |
||
| 73 | 73 | public static function mergeUrlWithPath(string $url, string $path): string |
| 74 | 74 | { |
| 75 | 75 | $overlap = 0; |
| 76 | - $url = rtrim($url, '/') . '/'; |
|
| 77 | - $path = '/' . ltrim($path, '/'); |
|
| 76 | + $url = rtrim($url, '/').'/'; |
|
| 77 | + $path = '/'.ltrim($path, '/'); |
|
| 78 | 78 | $urlOffset = strlen($url); |
| 79 | 79 | $pathLength = strlen($path); |
| 80 | 80 | $pathOffset = 0; |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - return rtrim($url, '/') . '/' . ltrim(substr($path, $overlap), '/'); |
|
| 89 | + return rtrim($url, '/').'/'.ltrim(substr($path, $overlap), '/'); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | // Handle trailing slashes properly for generated URLs |
| 159 | 159 | $generalConfig = Craft::$app->getConfig()->getGeneral(); |
| 160 | 160 | if ($generalConfig->addTrailingSlashesToUrls && !preg_match('/(.+\?.*)|(\.[^\/]+$)/', $url)) { |
| 161 | - $url = rtrim($url, '/') . '/'; |
|
| 161 | + $url = rtrim($url, '/').'/'; |
|
| 162 | 162 | } |
| 163 | 163 | if (!$generalConfig->addTrailingSlashesToUrls && (!$preserveTrailingSlash || self::urlIsSiteIndex($url))) { |
| 164 | 164 | $url = rtrim($url, '/'); |
@@ -178,13 +178,13 @@ discard block |
||
| 178 | 178 | $urlParts = parse_url($url); |
| 179 | 179 | $encodedUrl = ""; |
| 180 | 180 | if (isset($urlParts['scheme'])) { |
| 181 | - $encodedUrl .= $urlParts['scheme'] . '://'; |
|
| 181 | + $encodedUrl .= $urlParts['scheme'].'://'; |
|
| 182 | 182 | } |
| 183 | 183 | if (isset($urlParts['host'])) { |
| 184 | 184 | $encodedUrl .= $urlParts['host']; |
| 185 | 185 | } |
| 186 | 186 | if (isset($urlParts['port'])) { |
| 187 | - $encodedUrl .= ':' . $urlParts['port']; |
|
| 187 | + $encodedUrl .= ':'.$urlParts['port']; |
|
| 188 | 188 | } |
| 189 | 189 | if (isset($urlParts['path'])) { |
| 190 | 190 | $encodedUrl .= $urlParts['path']; |
@@ -194,15 +194,15 @@ discard block |
||
| 194 | 194 | foreach ($query as $j => $value) { |
| 195 | 195 | $value = explode('=', $value, 2); |
| 196 | 196 | if (count($value) === 2) { |
| 197 | - $query[$j] = urlencode($value[0]) . '=' . urlencode($value[1]); |
|
| 197 | + $query[$j] = urlencode($value[0]).'='.urlencode($value[1]); |
|
| 198 | 198 | } else { |
| 199 | 199 | $query[$j] = urlencode($value[0]); |
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | - $encodedUrl .= '?' . implode('&', $query); |
|
| 202 | + $encodedUrl .= '?'.implode('&', $query); |
|
| 203 | 203 | } |
| 204 | 204 | if (isset($urlParts['fragment'])) { |
| 205 | - $encodedUrl .= '#' . $urlParts['fragment']; |
|
| 205 | + $encodedUrl .= '#'.$urlParts['fragment']; |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | return $encodedUrl; |
@@ -234,10 +234,10 @@ discard block |
||
| 234 | 234 | $sitePath = parse_url(self::siteUrl('/', null, null, $site->id), PHP_URL_PATH); |
| 235 | 235 | if (!empty($sitePath)) { |
| 236 | 236 | // Normalizes a URI path by trimming leading/ trailing slashes and removing double slashes |
| 237 | - $sitePath = '/' . preg_replace('/\/\/+/', '/', trim($sitePath, '/')); |
|
| 237 | + $sitePath = '/'.preg_replace('/\/\/+/', '/', trim($sitePath, '/')); |
|
| 238 | 238 | } |
| 239 | 239 | // Normalizes a URI path by trimming leading/ trailing slashes and removing double slashes |
| 240 | - $url = '/' . preg_replace('/\/\/+/', '/', trim($url, '/')); |
|
| 240 | + $url = '/'.preg_replace('/\/\/+/', '/', trim($url, '/')); |
|
| 241 | 241 | // See if this url ends with a site prefix, and thus is a site index |
| 242 | 242 | if (str_ends_with($url, $sitePath)) { |
| 243 | 243 | $result = true; |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | if ($siteId !== null) { |
| 271 | 271 | $site = $sites->getSiteById($siteId, true); |
| 272 | 272 | if (!$site) { |
| 273 | - throw new Exception('Invalid site ID: ' . $siteId); |
|
| 273 | + throw new Exception('Invalid site ID: '.$siteId); |
|
| 274 | 274 | } |
| 275 | 275 | } |
| 276 | 276 | |
@@ -315,11 +315,11 @@ discard block |
||
| 315 | 315 | |
| 316 | 316 | if (filter_var($pathOrUrl, FILTER_VALIDATE_URL)) { |
| 317 | 317 | $url_parts = parse_url($pathOrUrl); |
| 318 | - $result['prefix'] = $url_parts['scheme'] . '://' . $url_parts['host']; |
|
| 318 | + $result['prefix'] = $url_parts['scheme'].'://'.$url_parts['host']; |
|
| 319 | 319 | $result['path'] = $url_parts['path'] ?? ''; |
| 320 | 320 | $result['suffix'] = ''; |
| 321 | - $result['suffix'] .= empty($url_parts['query']) ? '' : '?' . $url_parts['query']; |
|
| 322 | - $result['suffix'] .= empty($url_parts['fragment']) ? '' : '#' . $url_parts['fragment']; |
|
| 321 | + $result['suffix'] .= empty($url_parts['query']) ? '' : '?'.$url_parts['query']; |
|
| 322 | + $result['suffix'] .= empty($url_parts['fragment']) ? '' : '#'.$url_parts['fragment']; |
|
| 323 | 323 | } else { |
| 324 | 324 | $result['prefix'] = ''; |
| 325 | 325 | $result['path'] = $pathOrUrl; |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | { |
| 88 | 88 | if ($pageInfo !== null && $pageInfo->currentPage !== null) { |
| 89 | 89 | // Let the meta containers know that this page is paginated |
| 90 | - Seomatic::$plugin->metaContainers->paginationPage = (string)$pageInfo->currentPage; |
|
| 90 | + Seomatic::$plugin->metaContainers->paginationPage = (string) $pageInfo->currentPage; |
|
| 91 | 91 | // See if we should strip the query params |
| 92 | 92 | $stripQueryParams = true; |
| 93 | 93 | $pageTrigger = Craft::$app->getConfig()->getGeneral()->pageTrigger; |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | if (is_array($content)) { |
| 171 | 171 | $headerValue = ''; |
| 172 | 172 | foreach ($content as $contentVal) { |
| 173 | - $headerValue .= ($contentVal . ','); |
|
| 173 | + $headerValue .= ($contentVal.','); |
|
| 174 | 174 | } |
| 175 | 175 | $headerValue = rtrim($headerValue, ','); |
| 176 | 176 | } else { |
@@ -190,12 +190,12 @@ discard block |
||
| 190 | 190 | $headerValue = ''; |
| 191 | 191 | foreach ($href as $hrefVal) { |
| 192 | 192 | $hrefVal = UrlHelper::encodeUrl($hrefVal); |
| 193 | - $headerValue .= ('<' . $hrefVal . '>' . ','); |
|
| 193 | + $headerValue .= ('<'.$hrefVal.'>'.','); |
|
| 194 | 194 | } |
| 195 | 195 | $headerValue = rtrim($headerValue, ','); |
| 196 | 196 | } else { |
| 197 | 197 | $href = UrlHelper::encodeUrl($href); |
| 198 | - $headerValue = '<' . $href . '>'; |
|
| 198 | + $headerValue = '<'.$href.'>'; |
|
| 199 | 199 | } |
| 200 | 200 | $headerValue .= "; rel='canonical'"; |
| 201 | 201 | $response->headers->add('Link', $headerValue); |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | if (is_array($content)) { |
| 212 | 212 | $headerValue = ''; |
| 213 | 213 | foreach ($content as $contentVal) { |
| 214 | - $headerValue .= ($contentVal . ','); |
|
| 214 | + $headerValue .= ($contentVal.','); |
|
| 215 | 215 | } |
| 216 | 216 | $headerValue = rtrim($headerValue, ','); |
| 217 | 217 | } else { |
@@ -625,7 +625,7 @@ discard block |
||
| 625 | 625 | } |
| 626 | 626 | } |
| 627 | 627 | // Never include the URL if the element isn't enabled for the site |
| 628 | - if (isset($element->enabledForSite) && !(bool)$element->enabledForSite) { |
|
| 628 | + if (isset($element->enabledForSite) && !(bool) $element->enabledForSite) { |
|
| 629 | 629 | $includeUrl = false; |
| 630 | 630 | } |
| 631 | 631 | } else { |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | if (isset($value[$day][$time]) |
| 834 | 834 | && ($date = DateTimeHelper::toDateTime($value[$day][$time])) !== false |
| 835 | 835 | ) { |
| 836 | - $normalized[$day][$time] = (array)($date); |
|
| 836 | + $normalized[$day][$time] = (array) ($date); |
|
| 837 | 837 | } else { |
| 838 | 838 | $normalized[$day][$time] = null; |
| 839 | 839 | } |