Skip to content

Commit 567dd39

Browse files
committed
Merge branch 'release/5.1.18' into v5
2 parents 1726313 + 9024a2b commit 567dd39

38 files changed

+1148
-937
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# SEOmatic Changelog
22

3+
## 5.1.18 - 2025.10.06
4+
### Added
5+
* Added a `twigExtensionClasses` config setting to allow additional TwigExtension classes to be loaded in the Twig `SandboxView` that SEOmatic uses to render ([#1632](https://github.com/nystudio107/craft-seomatic/issues/1632))
6+
* Only allow users to pick SEO/Facebook/Twitter images from asset volumes that they had permission to access ([#1650](https://github.com/nystudio107/craft-seomatic/issues/1650))
7+
8+
### Changed
9+
* No longer block various AI bots via `robots.txt` by default ([#1635](https://github.com/nystudio107/craft-seomatic/issues/1635))
10+
* Handle setting the focal point for social images that are transformed ([#1626](https://github.com/nystudio107/craft-seomatic/issues/1626))
11+
12+
### Fixed
13+
* Fixed an issue with page footer text being untranslatable on 3 pages due to filter ordering ([#1651](https://github.com/nystudio107/craft-seomatic/issues/1651))
14+
* Fixed an issue where sitemap generation could fail with the new Content Block fields under certain conditions ([#1645](https://github.com/nystudio107/craft-seomatic/issues/1645))
15+
* Don't overwrite the `dataLayer` if it already exists in the Google Tag Manager default script ([#1642](https://github.com/nystudio107/craft-seomatic/issues/1642))
16+
317
## 5.1.17 - 2025.08.17
418
### Added
519
* Added the ability to choose from nested fields in Content Block fields from the SEOmatic GUI in the various Content SEO settings

buildchain/package-lock.json

Lines changed: 612 additions & 558 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "nystudio107/craft-seomatic",
33
"description": "SEOmatic facilitates modern SEO best practices & implementation for Craft CMS 5. It is a turnkey SEO system that is comprehensive, powerful, and flexible.",
44
"type": "craft-plugin",
5-
"version": "5.1.17",
5+
"version": "5.1.18",
66
"minimum-stability": "dev",
77
"prefer-stable": true,
88
"keywords": [
@@ -38,7 +38,7 @@
3838
"craftcms/cms": "^5.0.0",
3939
"nystudio107/craft-plugin-vite": "^5.0.0",
4040
"nystudio107/craft-code-editor": "^1.0.14",
41-
"nystudio107/craft-twig-sandbox": "^5.0.3",
41+
"nystudio107/craft-twig-sandbox": "^5.0.5",
4242
"php-science/textrank": "^1.0.3",
4343
"davechild/textstatistics": "^1.0.3",
4444
"sunra/php-simple-html-dom-parser": "^1.5.2"

docs/package-lock.json

Lines changed: 353 additions & 306 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Seomatic.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,12 @@ protected function installEventListeners(): void
428428
$seomaticTwigExtension = new SeomaticTwigExtension();
429429
self::$view->registerTwigExtension($seomaticTwigExtension);
430430
self::$sandboxView->registerTwigExtension($seomaticTwigExtension);
431+
// Register the additional TwigExtension classes
432+
foreach (Seomatic::$settings->twigExtensionClasses as $className) {
433+
if (class_exists($className)) {
434+
self::$sandboxView->registerTwigExtension(new $className());
435+
}
436+
}
431437
$request = Craft::$app->getRequest();
432438
// Add in our event listeners that are needed for every request
433439
$this->installGlobalEventListeners();

src/config.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,7 @@
174174
// string[] URL params that are allowed to be considered part of the unique URL used for the metadata cache
175175
'allowedUrlParams' => [
176176
],
177+
// class-string[] Array of TwigExtension classes to instantiate and add to the SandboxView
178+
'twigExtensionClasses' => [
179+
],
177180
];

src/controllers/SettingsController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use nystudio107\seomatic\autocompletes\TrackingVarsAutocomplete;
2626
use nystudio107\seomatic\base\SeoElementInterface;
2727
use nystudio107\seomatic\helpers\ArrayHelper;
28+
use nystudio107\seomatic\helpers\AssetHelper;
2829
use nystudio107\seomatic\helpers\DynamicMeta as DynamicMetaHelper;
2930
use nystudio107\seomatic\helpers\Field as FieldHelper;
3031
use nystudio107\seomatic\helpers\ImageTransform as ImageTransformHelper;
@@ -326,6 +327,7 @@ public function actionGlobal(string $subSection = 'general', string $siteHandle
326327
// Image selectors
327328
$bundleSettings = $metaBundle->metaBundleSettings;
328329
$variables['elementType'] = Asset::class;
330+
$variables['assetVolumeSources'] = AssetHelper::getAssetInputSources();
329331
$variables['seoImageElements'] = ImageTransformHelper::assetElementsFromIds(
330332
$bundleSettings->seoImageIds,
331333
$siteId
@@ -629,6 +631,7 @@ public function actionEditContent(
629631
$variables['currentSubSection'] = $subSection;
630632
$bundleSettings = $metaBundle->metaBundleSettings;
631633
$variables['elementType'] = Asset::class;
634+
$variables['assetVolumeSources'] = AssetHelper::getAssetInputSources();
632635
$variables['seoImageElements'] = ImageTransformHelper::assetElementsFromIds(
633636
$bundleSettings->seoImageIds,
634637
$siteId
@@ -809,6 +812,7 @@ public function actionSite(string $subSection = 'identity', string $siteHandle =
809812
);
810813
}
811814
$variables['elementType'] = Asset::class;
815+
$variables['assetVolumeSources'] = AssetHelper::getAssetInputSources();
812816
$this->setCrumbVariables($variables);
813817

814818
// Render the template

src/fields/SeoSettings.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use craft\helpers\StringHelper;
2020
use nystudio107\seomatic\assetbundles\seomatic\SeomaticAsset;
2121
use nystudio107\seomatic\helpers\ArrayHelper;
22+
use nystudio107\seomatic\helpers\AssetHelper;
2223
use nystudio107\seomatic\helpers\Config as ConfigHelper;
2324
use nystudio107\seomatic\helpers\Field as FieldHelper;
2425
use nystudio107\seomatic\helpers\Migration as MigrationHelper;
@@ -364,7 +365,7 @@ public function getInputHtml(mixed $value, ?ElementInterface $element = null): s
364365

365366
/** @var MetaBundle $value */
366367
$variables['elementType'] = Asset::class;
367-
368+
$variables['assetVolumeSources'] = AssetHelper::getAssetInputSources();
368369
$variables['parentBundles'] = [];
369370
// Preview the containers so the preview is correct in the field
370371
if ($element !== null && $element->uri !== null) {

src/helpers/AssetHelper.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
/**
3+
* SEOmatic plugin for Craft CMS
4+
*
5+
* A turnkey SEO implementation for Craft CMS that is comprehensive, powerful,
6+
* and flexible
7+
*
8+
* @link https://nystudio107.com
9+
* @copyright Copyright (c) nystudio107
10+
*/
11+
12+
namespace nystudio107\seomatic\helpers;
13+
14+
use Craft;
15+
use craft\elements\Asset;
16+
use craft\fs\Temp;
17+
use craft\helpers\ArrayHelper;
18+
use craft\services\ElementSources;
19+
20+
/**
21+
* @author nystudio107
22+
* @package Seomatic
23+
* @since 5.1.18
24+
*/
25+
class AssetHelper
26+
{
27+
/**
28+
* Return asset volume sources that can be accessed by the current user
29+
*
30+
* @return array
31+
*/
32+
public static function getAssetInputSources(): array
33+
{
34+
$sources = [];
35+
foreach (Craft::$app->getElementSources()->getSources(Asset::class) as $source) {
36+
if ($source['type'] !== ElementSources::TYPE_HEADING) {
37+
$sources[] = $source['key'];
38+
}
39+
}
40+
41+
$userService = Craft::$app->getUser();
42+
$volumesService = Craft::$app->getVolumes();
43+
return ArrayHelper::where($sources, function(string $source) use ($volumesService, $userService) {
44+
// If it’s not a volume folder, let it through
45+
if (!str_starts_with($source, 'volume:')) {
46+
return true;
47+
}
48+
// Only show it if they have permission to view it, or if it's the temp volume
49+
$volumeUid = explode(':', $source)[1];
50+
if ($userService->checkPermission("viewAssets:$volumeUid")) {
51+
return true;
52+
}
53+
$volume = $volumesService->getVolumeByUid($volumeUid);
54+
return $volume?->getFs() instanceof Temp;
55+
}, true, true, false);
56+
}
57+
}

src/helpers/EagerLoad.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static function sitemapEagerLoadMap($metaBundle): array
6969
public static function assetFieldEagerLoadMap($layout, $transform): array
7070
{
7171
$fieldMap = [];
72-
$assetFields = FieldHelper::fieldsOfTypeFromLayout(FieldHelper::ASSET_FIELD_CLASS_KEY, $layout);
72+
$assetFields = FieldHelper::fieldsOfTypeFromLayout(FieldHelper::ASSET_FIELD_CLASS_KEY, $layout, true, null, null, false);
7373
foreach ($assetFields as $assetFieldHandle) {
7474
$fieldMap[] = empty($transform) ? $assetFieldHandle : [$assetFieldHandle, ['withTransforms' => $transform]];
7575
}
@@ -87,7 +87,7 @@ public static function assetFieldEagerLoadMap($layout, $transform): array
8787
public static function matrixFieldEagerLoadMap($layout, $transform): array
8888
{
8989
$fieldMap = [];
90-
$matrixFields = FieldHelper::fieldsOfTypeFromLayout(FieldHelper::BLOCK_FIELD_CLASS_KEY, $layout);
90+
$matrixFields = FieldHelper::fieldsOfTypeFromLayout(FieldHelper::BLOCK_FIELD_CLASS_KEY, $layout, true, null, null, false);
9191
foreach ($matrixFields as $matrixFieldHandle) {
9292
/** @var Matrix $matrixField */
9393
$matrixField = $layout->getFieldByHandle($matrixFieldHandle);
@@ -103,7 +103,7 @@ public static function matrixFieldEagerLoadMap($layout, $transform): array
103103
if ($entryTypes) {
104104
foreach ($entryTypes as $entryType) {
105105
$matrixLayout = $entryType->getFieldLayout();
106-
$assetFields = FieldHelper::fieldsOfTypeFromLayout(FieldHelper::ASSET_FIELD_CLASS_KEY, $matrixLayout);
106+
$assetFields = FieldHelper::fieldsOfTypeFromLayout(FieldHelper::ASSET_FIELD_CLASS_KEY, $matrixLayout, true, null, null, false);
107107
foreach ($assetFields as $assetFieldHandle) {
108108
$fieldMap[] = empty($transform) ? "$matrixFieldHandle.$assetFieldHandle" : ["$matrixFieldHandle.$assetFieldHandle", ['withTransforms' => $transform]];
109109
}

0 commit comments

Comments
 (0)