diff --git a/CHANGELOG.md b/CHANGELOG.md index c8bd4657..6e5440b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Release Notes for Campaign +## 2.8.6 - Unreleased + +### Fixed + +- Fixed a bug in which Campaign, Contact and Mailing List element types were not being registered by the Feed Me plugin ([#412](https://github.com/putyourlightson/craft-campaign/issues/412)). + ## 2.8.5 - 2023-08-21 ### Added diff --git a/composer.json b/composer.json index 7b23167d..2546ddb6 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": "2.8.5", + "version": "2.8.6", "type": "craft-plugin", "homepage": "https://putyourlightson.com/plugins/campaign", "license": "proprietary", diff --git a/src/Campaign.php b/src/Campaign.php index 43179e1e..faadb56a 100644 --- a/src/Campaign.php +++ b/src/Campaign.php @@ -36,6 +36,7 @@ use craft\services\Sites; use craft\services\UserPermissions; use craft\services\Utilities; +use craft\web\Application; use craft\web\Response; use craft\web\twig\variables\CraftVariable; use craft\web\UrlManager; @@ -701,17 +702,20 @@ private function _registerTwigExtensions(): void */ private function _registerFeedMeElements(): void { - // Ensure that the plugin is enabled and exists + // Ensure that the plugin is enabled and exists after application initialisation. // https://github.com/putyourlightson/craft-campaign/issues/400 - if (Craft::$app->getPlugins()->getPlugin('feed-me') !== null) { - Event::on(FeedMeElements::class, FeedMeElements::EVENT_REGISTER_FEED_ME_ELEMENTS, - function(RegisterFeedMeElementsEvent $event) { - $event->elements[] = CampaignFeedMeElement::class; - $event->elements[] = ContactFeedMeElement::class; - $event->elements[] = MailingListFeedMeElement::class; - } - ); - } + // https://github.com/putyourlightson/craft-campaign/issues/412 + Event::on(Application::class, Application::EVENT_INIT, function() { + if (Craft::$app->getPlugins()->getPlugin('feed-me') !== null) { + Event::on(FeedMeElements::class, FeedMeElements::EVENT_REGISTER_FEED_ME_ELEMENTS, + function(RegisterFeedMeElementsEvent $event) { + $event->elements[] = CampaignFeedMeElement::class; + $event->elements[] = ContactFeedMeElement::class; + $event->elements[] = MailingListFeedMeElement::class; + } + ); + } + }); } /**