-
Notifications
You must be signed in to change notification settings - Fork 0
/
hadron.php
72 lines (59 loc) · 2.33 KB
/
hadron.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
namespace Grav\Theme;
use Grav\Common\Grav;
use Grav\Common\Theme;
class Hadron extends Quark {
public static function getSubscribedEvents() {
return [
'onTwigLoader' => ['onTwigLoader', 0],
'onShortcodeHandlers' => ['onShortcodeHandlers', 0],
'onTwigSiteVariables' => ['onTwigSiteVariables', 0],
'onTwigInitialized' => ['onTwigInitialized', 0],
'registerNextGenEditorPlugin' => ['registerNextGenEditorPluginShortcodes', 0]
];
}
public function onTwigLoader() {
parent::onTwigLoader();
// add parent theme as namespace to twig
$parentThemeName = 'quark';
$parentThemePath = Grav::instance()['locator']->findResource('themes://' . $parentThemeName);
$this->grav['twig']->addPath($parentThemePath . DIRECTORY_SEPARATOR . 'templates', $parentThemeName);
}
public function onTwigInitialized() {
$twig = $this->grav['twig'];
$form_class_variables = [
//'form_outer_classes' => 'form-horizontal',
'form_button_outer_classes' => 'buttons button-wrapper',
'form_button_classes' => 'button',
'form_errors_classes' => '',
'form_field_outer_classes' => 'form-group',
'form_field_outer_label_classes' => 'form-label-wrapper',
'form_field_label_classes' => 'form-label',
//'form_field_outer_data_classes' => 'col-9',
'form_field_input_classes' => 'form-input',
'form_field_textarea_classes' => 'form-input',
'form_field_select_classes' => 'form-select',
'form_field_radio_classes' => 'form-radio',
'form_field_checkbox_classes' => 'form-checkbox',
];
$twig->twig_vars = array_merge($twig->twig_vars, $form_class_variables);
}
public static function getblogpageheroclasses() {
$config = Grav::instance()['config'];
return $config->get('themes.' . $config->get('system.pages.theme') . '.blog_page_hero_classes');
}
public function onShortcodeHandlers() {
$this->grav['shortcode']->registerAllShortcodes('user://themes/hadron/shortcodes');
}
public function onTwigSiteVariables() {
if ($this->isAdmin() && ($this->grav['config']->get('plugins.shortcode-core.enabled'))) {
$this->grav['assets']->add('theme://editor-buttons/admin/js/shortcode-h5p.js');
}
}
public function registerNextGenEditorPluginShortcodes($event) {
$plugins = $event['plugins'];
$plugins['js'][] = 'user://themes/hadron/nextgen-editor/shortcodes/h5p.js';
$event['plugins'] = $plugins;
return $event;
}
}