From 5aa55e907bc1a1d77b8599d97ccc0e6d6a0ebb1d Mon Sep 17 00:00:00 2001 From: Frederic Koeberl Date: Tue, 2 Feb 2021 12:25:05 +0100 Subject: [PATCH] Only register Asset Bundle when necessary. #12 --- CHANGELOG.md | 4 ++++ composer.json | 2 +- src/SlugEqualsTitle.php | 5 +---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10b4a4f..a5585bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Slug Equals Title Changelog All notable changes to this project will be documented in this file. +## 1.3.1 - 2021-02-02 +### Fixed +- Only register Asset Bundle when necessary. #12 + ## 1.3.0 - 2021-01-04 ### Added - Added support for Commerce Products and Categories. diff --git a/composer.json b/composer.json index 146b508..da59c64 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "internetztube/craft-slug-equals-title", "description": "This plugin makes sure that the slug is always the same as the title.", "type": "craft-plugin", - "version": "1.3.0", + "version": "1.3.1", "keywords": [ "craft", "cms", diff --git a/src/SlugEqualsTitle.php b/src/SlugEqualsTitle.php index e9a1755..cef3efb 100644 --- a/src/SlugEqualsTitle.php +++ b/src/SlugEqualsTitle.php @@ -27,10 +27,6 @@ public function init() $this->hasCpSettings = true; self::$plugin = $this; - if (Craft::$app->request->isCpRequest) { - Craft::$app->view->registerAssetBundle(ExcludeFromRewriteAssetBundle::class); - } - $this->setComponents([ 'elementStatus' => ElementStatusService::class, ]); @@ -68,6 +64,7 @@ public function init() Event::on(View::class, View::EVENT_BEFORE_RENDER_PAGE_TEMPLATE, function ($event) { if (!$this->elementStatus->isTemplateEnabledForOverwrite($event->template)) return; + Craft::$app->view->registerAssetBundle(ExcludeFromRewriteAssetBundle::class); /** @var View $view */ $view = $event->sender; $element = $this->elementStatus->getElementFromEventVariables($event->variables);