From d44fa8a24c8039264a8a650edbc95e0ee75ae7a4 Mon Sep 17 00:00:00 2001 From: Brandon Kelly Date: Fri, 20 Jul 2018 06:14:51 -0700 Subject: [PATCH] Use registerTwigExtension() Fixes a bug where the plugin may cause Twig to be loaded before it should be, and another bug where the extension might not be available if the Template Mode ever changes from CP to Site, or vise-versa. --- src/TimeAgo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TimeAgo.php b/src/TimeAgo.php index 1388bd8..a7d4758 100644 --- a/src/TimeAgo.php +++ b/src/TimeAgo.php @@ -30,7 +30,7 @@ public function init() self::$plugin = $this; // Add in our Twig extensions - Craft::$app->view->twig->addExtension(new twigextensions\TimeAgoTwigExtension()); + Craft::$app->view->registerTwigExtension(new twigextensions\TimeAgoTwigExtension()); Craft::info( Craft::t(