forked from pmoreno-rodriguez/grav-theme-editorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheditorial.php
53 lines (43 loc) · 1.56 KB
/
editorial.php
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
45
46
47
48
49
50
51
52
53
<?php
namespace Grav\Theme;
use Grav\Common\Theme;
use RocketTheme\Toolbox\Event\Event;
use Grav\Common\Page\Interfaces\PageInterface;
/**
* Editorial Theme
*
* Class Editorial
*
* @category Extensions
* @package Grav\Theme
* @author Pedro Moreno <https://github.com/pmoreno-rodriguez>
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @link https://github.com/pmoreno-rodriguez/grav-theme-editorial
*/
class Editorial extends Theme
{
// Access plugin events in this class
public static function getSubscribedEvents()
{
return [
'onShortcodeHandlers' => ['onShortcodeHandlers', 0],
'onTwigSiteVariables' => ['onTwigSiteVariables', 0]
];
}
public function onShortcodeHandlers()
{
$this->grav['shortcode']->registerAllShortcodes(__DIR__ . '/shortcodes');
}
public function onTwigSiteVariables()
{
if ($this->isAdmin() && ($this->grav['config']->get('plugins.shortcode-core.enabled'))) {
}
$themeConfig = $this->config->get('themes.editorial');
if (isset($themeConfig['custom_css']) && $themeConfig['custom_css'] && file_exists(__DIR__ . '/assets/css/custom.css')) {
$this->grav['assets']->addCss('theme://assets/css/custom.css', ['priority' => 5]);
}
if (isset($themeConfig['custom_js']) && $themeConfig['custom_js'] && file_exists(__DIR__ . '/assets/js/custom.js')) {
$this->grav['assets']->addJs('theme://assets/js/custom.js', ['group' => 'bottom', 'priority' => 15]);
}
}
}