|
10 | 10 | * @license MIT
|
11 | 11 | */
|
12 | 12 |
|
13 |
| -if(!c::get('plugin.kirby-sri')) return; |
| 13 | +if (c::get('plugin.kirby-sri', false)) { |
| 14 | + // Loading SRI helper function |
| 15 | + require_once __DIR__ . DS . 'utility' . DS . 'helper.php'; |
14 | 16 |
|
15 |
| -// Helper function generating base64-encoded SRI hashes |
16 |
| -function sri_checksum($input) { |
17 |
| - $algorithm = c::get('plugin.kirby-sri.algorithm', 'sha512'); |
18 |
| - $hash = hash($algorithm, $input, true); |
19 |
| - $hash_base64 = base64_encode($hash); |
| 17 | + // Loading core |
| 18 | + load([ |
| 19 | + 'kirby\\plugins\\sri\\css' => __DIR__ . DS . 'core' . DS . 'css.php', |
| 20 | + 'kirby\\plugins\\sri\\js' => __DIR__ . DS . 'core' . DS . 'js.php' |
| 21 | + ]); |
20 | 22 |
|
21 |
| - return "$algorithm-$hash_base64"; |
| 23 | + // Registering with Kirby's extension registry |
| 24 | + kirby()->set('component', 'css', 'Kirby\Plugins\\SRI\\CSS'); |
| 25 | + kirby()->set('component', 'js', 'Kirby\Plugins\\SRI\\JS'); |
22 | 26 | }
|
23 |
| - |
24 |
| -// Loading core |
25 |
| -load([ |
26 |
| - 'kirby\\plugins\\sri\\css' => __DIR__ . DS . 'core' . DS . 'css.php', |
27 |
| - 'kirby\\plugins\\sri\\js' => __DIR__ . DS . 'core' . DS . 'js.php' |
28 |
| -]); |
29 |
| - |
30 |
| -// Registering with Kirby's extension registry |
31 |
| -kirby()->set('component', 'css', 'Kirby\Plugins\\SRI\\CSS'); |
32 |
| -kirby()->set('component', 'js', 'Kirby\Plugins\\SRI\\JS'); |
0 commit comments