-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilter-strings.php
More file actions
44 lines (44 loc) · 1.08 KB
/
filter-strings.php
File metadata and controls
44 lines (44 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace Grav\Plugin;
use Grav\Common\Data;
use Grav\Common\Plugin;
use Grav\Common\Grav;
use Grav\Common\Page\Page;
use RocketTheme\Toolbox\Event\Event;
class FilterStringsPlugin extends Plugin
{
/**
* @var FilterStringsPlugin
*/
/**
* @return array
*/
public static function getSubscribedEvents()
{
return [
'onPluginsInitialized' => ['onPluginsInitialized', 0],
];
}
/**
* Initialize configuration
*/
public function onPluginsInitialized()
{
if ($this->isAdmin() && !$this->config->get('plugins.filter-strings.enabled', false)) {
$this->active = false;
return;
}
require_once(__DIR__.'/vendor/autoload.php');
$this->enable([
'onTwigExtensions' => ['onTwigExtensions', 0]
]);
}
/**
* Add Twig Extensions
*/
public function onTwigExtensions()
{
require_once(__DIR__.'/twig/FilterStringsTwigExtension.php');
$this->grav['twig']->twig->addExtension(new FilterStringsTwigExtension());
}
}