This repository has been archived by the owner on Sep 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shortcode.php
80 lines (70 loc) · 2.52 KB
/
shortcode.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
73
74
75
76
77
78
<?php
//MDUI短代码
function tm_shortcode($content)
{
//代码
$content = str_replace(
array('[c]','[/c]'),
array(
'<code>',
'</code>',
),
$content);
//可扩展面板
$content = str_replace(
array('[br]', '[panel]', '[/panel]', '[panel-title]', '[panel-title-open]', '[/panel-title]', '[panel-content]', '[/panel-content]'),
array(
'<br>',
'<div class="mdui-panel mdui-panel-gapless" mdui-panel="{accordion: true}">',
'</div><br>',
'<div class="mdui-panel-item"><div class="mdui-panel-item-header">',
'<div class="mdui-panel-item mdui-panel-item-open"><div class="mdui-panel-item-header">',
'</div>',
'<div class="mdui-panel-item-body"><p>',
'</p></div></div>',
),
$content);
//按钮
$content = str_replace(
array('[btn]', '[btn-flat]','[btn-white]','[btn-white-flat]', '[/btn]', '[btn-url]', '[/btn-url]', '[btn-url-new]','[/btn-url-new]'),
array(
'<button class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-grey-700" ',
'<button class="mdui-btn mdui-ripple mdui-color-grey-700" ',
'<button class="mdui-btn mdui-btn-raised mdui-ripple" ',
'<button class="mdui-btn mdui-ripple" ',
'</button>',
"onclick='window.location.href=\"",
"\"'>",
"onclick='window.open(\"",
"\")'>",
),
$content);
//复选
$content = str_replace(
array('[check]','[uncheck]','[/check]'),
array(
'<label class="mdui-checkbox"><input type="checkbox" disabled checked/><i class="mdui-checkbox-icon"></i>',
'<label class="mdui-checkbox"><input type="checkbox" disabled/><i class="mdui-checkbox-icon"></i>',
'</label>',
),
$content);
//Font Awesome
$content = str_replace(
array('[fontawesome]'),
array(
'<link rel="stylesheet" href="'.get_bloginfo("template_url").'/fontawesome/css/all.min.css">',
),
$content);
return $content;
}
function panel_function()
{
return '<div class="mdui-panel mdui-panel-gapless" mdui-panel="{accordion: true}">';
}
function panel_close_function()
{
return '<div class="mdui-panel mdui-panel-gapless" mdui-panel="{accordion: true}">';
}
add_shortcode('panel', 'panel_function');
add_shortcode('panel-s', 'panel_function');
add_shortcode('/panel', 'panel_close_function');