diff --git a/CHANGELOG.md b/CHANGELOG.md index 098d079d..ecafed97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Release Notes for Campaign +## 1.26.1 - 2024-11-29 + +### Fixed + +- Fixed a bug in which contacts could not be filtered by segments in non-primary sites ([#504](https://github.com/putyourlightson/craft-campaign/issues/504)). + ## 1.26.0 - 2024-04-17 ### Added diff --git a/composer.json b/composer.json index 4782886d..9dcab950 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "putyourlightson/craft-campaign", "description": "Send and manage email campaigns, contacts and mailing lists.", - "version": "1.26.0", + "version": "1.26.1", "type": "craft-plugin", "homepage": "https://putyourlightson.com/plugins/campaign", "license": "proprietary", diff --git a/src/elements/ContactElement.php b/src/elements/ContactElement.php index d075fcef..57fe2047 100644 --- a/src/elements/ContactElement.php +++ b/src/elements/ContactElement.php @@ -175,12 +175,13 @@ protected static function defineSources(string $context = null): array if (Campaign::$plugin->getIsPro()) { $sources[] = ['heading' => Craft::t('campaign', 'Segments')]; - $segments = SegmentElement::findAll(); + $segments = Campaign::$plugin->segments->getAllSegments(); foreach ($segments as $segment) { $sources[] = [ 'key' => 'segment:'.$segment->id, 'label' => $segment->title, + 'sites' => [$segment->siteId], 'data' => [ 'id' => $segment->id ], diff --git a/src/services/SegmentsService.php b/src/services/SegmentsService.php index dddd2eef..de265f2a 100644 --- a/src/services/SegmentsService.php +++ b/src/services/SegmentsService.php @@ -64,6 +64,19 @@ public function getSegmentsByIds(array $segmentIds): array ->all(); } + /** + * Returns all segments. + * + * @return SegmentElement[] + */ + public function getAllSegments(): array + { + /** @var SegmentElement[]] */ + return SegmentElement::find() + ->site('*') + ->all(); + } + /** * Returns the segment's contacts *