Skip to content

Commit

Permalink
Merge branch 'release/4.0.34' into v4
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Nov 15, 2023
2 parents a3daa47 + 1e1791c commit 679c9ad
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 13 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# SEOmatic Changelog

## 4.0.34 - 2023.11.15
### Changed
* Try to use Craft's matched element from `UrlManager` in `MetaContainers` if looking for an enabled element, the current `siteId` is being used and the current `uri` matches what was in the request ([#1381](https://github.com/nystudio107/craft-seomatic/pull/1381))

### Fixed
* Fixed an issue where the `CanonicalLink` would render if the `Robots` tag contained multiple values ([#1378](https://github.com/nystudio107/craft-seomatic/issues/1378))
* Fixed incorrect references to `SeoEntry` in the Campaign `SeoElement` ([#1382](https://github.com/nystudio107/craft-seomatic/pull/1382))

## 4.0.33 - 2023.10.22
### Added
* Added an SEOmatic debug panel to the Yii2 Debug Toolbar to aid in debugging SEO metadata
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "nystudio107/craft-seomatic",
"description": "SEOmatic facilitates modern SEO best practices & implementation for Craft CMS 4. It is a turnkey SEO system that is comprehensive, powerful, and flexible.",
"type": "craft-plugin",
"version": "4.0.33",
"version": "4.0.34",
"keywords": [
"craft",
"cms",
Expand Down
12 changes: 3 additions & 9 deletions src/models/metalink/CanonicalLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,9 @@ public function prepForRender(&$data): bool
$robots = Seomatic::$seomaticVariable->tag->get('robots');
if ($robots !== null && $robots->include && !Seomatic::$previewingMetaContainers && !Seomatic::$settings->alwaysIncludeCanonicalUrls) {
$robotsArray = $robots->renderAttributes();
$content = $robotsArray['content'] ?? '';
if (!empty($content)) {
if (\is_array($content)) {
if (\in_array('noindex', $content, true) || \in_array('none', $content, true)) {
return false;
}
} else if ($content === 'noindex' || $content === 'none') {
return false;
}
$contentArray = explode(',', $robotsArray['content'] ?? '');
if (in_array('noindex', $contentArray, true) || in_array('none', $contentArray, true)) {
return false;
}
}
// Ensure the href is a full url
Expand Down
4 changes: 2 additions & 2 deletions src/seoelements/SeoCampaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function (CampaignTypeEvent $event) {
);
// Create the meta bundles for this campaign type if it's new
if ($event->isNew) {
SeoEntry::createContentMetaBundle($event->campaignType);
SeoCampaign::createContentMetaBundle($event->campaignType);
Seomatic::$plugin->sitemaps->submitSitemapIndex();
}
}
Expand All @@ -167,7 +167,7 @@ function (CampaignTypeEvent $event) {
);
// Delete the meta bundles for this campaign type
Seomatic::$plugin->metaBundles->deleteMetaBundleBySourceId(
SeoEntry::getMetaBundleType(),
SeoCampaign::getMetaBundleType(),
$event->campaignType->id
);
}
Expand Down
13 changes: 12 additions & 1 deletion src/services/MetaContainers.php
Original file line number Diff line number Diff line change
Expand Up @@ -893,10 +893,21 @@ protected function setMatchedElement(string $uri, int $siteId = null)
?? Craft::$app->getSites()->primarySite->id
?? 1;
}
$element = null;
$uri = trim($uri, '/');
/** @var Element $element */
$enabledOnly = !Seomatic::$previewingMetaContainers;
$element = Craft::$app->getElements()->getElementByUri($uri, $siteId, $enabledOnly);
// Try to use Craft's matched element if looking for an enabled element, the current `siteId` is being used and
// the current `uri` matches what was in the request
if ($enabledOnly
&& $siteId === Craft::$app->getSites()->currentSite->id
&& Craft::$app->getRequest()->getPathInfo() === $uri)
{
$element = Craft::$app->getUrlManager()->getMatchedElement();
}
if (!$element) {
$element = Craft::$app->getElements()->getElementByUri($uri, $siteId, $enabledOnly);
}
if ($element && ($element->uri !== null)) {
Seomatic::setMatchedElement($element);
}
Expand Down

0 comments on commit 679c9ad

Please sign in to comment.