-
Notifications
You must be signed in to change notification settings - Fork 14
/
MarkupAddInlineScript.module
40 lines (36 loc) · 1.23 KB
/
MarkupAddInlineScript.module
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
<?php namespace ProcessWire;
class MarkupAddInlineScript extends WireData implements Module {
/**
* getModuleInfo is a module required by all modules to tell ProcessWire about them
*
* @return array
*
*/
public static function getModuleInfo() {
return array(
'title' => 'Inline Scripts',
'version' => '3.0.2',
'summary' => 'adds inline script before </body>',
'singular' => true,
'autoload' => true,
'requires' => 'ProcessWire>=3.0.0, MarkupLeafletMap',
'Author' => 'gebeer',
);
}
/**
* Initialize the module
*
* ProcessWire calls this when the module is loaded. For 'autoload' modules, this will be called
* when ProcessWire's API is ready. As a result, this is a good place to attach hooks.
*
*/
public function init() {
$this->addHookAfter('Page::render', $this, 'addInlineScript');
}
public function addInlineScript($event) {
$page = $event->object;
if ($page->template->name !== "admin" && $page->inlineScript) {
$event->return = str_replace("</body>", $page->inlineScript . "</body>", $event->return);
}
}
}