-
Notifications
You must be signed in to change notification settings - Fork 1
/
wondercms-markdown.php
59 lines (54 loc) · 1.41 KB
/
wondercms-markdown.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
<?php
/**
* SimpleMDE content plugin with Marked.js for page visits.
*
* @author Marcel Portma
* @version 3.0.7
*/
global $Wcms;
if (defined('VERSION')) {
define('version', VERSION);
defined('version') OR die('Direct access is not allowed.');
}
$Wcms->addListener('js', 'mdeJS');
$Wcms->addListener('css', 'mdeCSS');
function mdeJS($args) {
global $Wcms;
if ($Wcms) {
$script = <<<EOT
<script src="https://cdn.jsdelivr.net/npm/marked"></script>
EOT;
$args[0] .= $script;
}
if (!$Wcms->loggedIn) {
$script = <<<EOT
<script src="{$Wcms->url('plugins/wondercms-markdown/js/visitor.js')}"></script>
EOT;
$args[0] .= $script;
}
if ($Wcms->loggedIn) {
$script = <<<EOT
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/simplemde.min.js"></script>
<script src="{$Wcms->url('plugins/wondercms-markdown/js/loadEditor.js')}"></script>
EOT;
$args[0] .= $script;
}
return $args;
}
function mdeCSS($args) {
global $Wcms;
if ($Wcms) {
$script = <<<EOT
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css">
<link rel="stylesheet" href="{$Wcms->url('plugins/wondercms-markdown/css/custom.css')}">
EOT;
$args[0] .= $script;
}
if ($Wcms->loggedIn) {
$script = <<<EOT
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/simplemde.min.css">
EOT;
$args[0] .= $script;
}
return $args;
}