-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoption.php
More file actions
206 lines (186 loc) · 6.88 KB
/
Copy pathoption.php
File metadata and controls
206 lines (186 loc) · 6.88 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<?php
defined( 'ABSPATH' ) or exit;
if ( $_POST['update_plugin_options'] == 'true' ) {
if ( live2d_options_update() ) {
echo '<div id="message" class="updated"><h4>设置已成功保存</a></h4></div>';
} else {
echo '<div id="message" class="updated"><h4>设置更新失败</a></h4></div>';
}
}
?>
<style>
input[type='color'] {
width: 25px;
height: 25px;
padding: .1px 2px;
}
textarea {
width: 60%;
height: 230px;
}
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}
.switch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: #2196F3;
}
input:focus + .slider {
box-shadow: 0 0 1px #2196F3;
}
input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
/* Rounded sliders */
.slider.round {
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;
}
</style>
<div class="wrap">
<h2>PoiLive2D魔改 插件控制面板</h2>
<form method="POST" action="">
<input type="hidden" name="update_plugin_options" value="true"/>
<h3>基本设置</h3>
<div style="margin-left: 50px">
<input type="color" name="main-color" id="main-color"
value="<?php echo get_option( 'live2d_maincolor' ); ?>"/> 对话框主体颜色
<p>
<label class="switch">
<input type="checkbox" name="hitokoto"
id="hitokoto" <?php echo get_option( 'live2d_hitokoto' ); ?> >
<span class="slider round"></span>
</label>
<span style="margin-left: 16px">一言显示</span>
</p>
<p>
<label class="switch">
<input type="checkbox" name="special-tip"
id="special-tip" <?php echo get_option( 'live2d_special_tip' ); ?> >
<span class="slider round"></span>
</label>
<span style="margin-left: 16px">特殊显示</span>
</p>
<p>
<label class="switch">
<input type="checkbox" name="catalog"
id="catalog" <?php echo get_option( 'live2d_catalog' ); ?> >
<span class="slider round"></span>
</label>
<span style="margin-left: 16px">文章目录</span>
</p>
<p>
<label class="switch">
<input type="checkbox" name="position"
id="position" <?php echo get_option( 'live2d_position' ); ?> >
<span class="slider round"></span>
</label>
<span style="margin-left: 16px">Live2d位置(当前:
<?php if ( get_option( 'live2d_position' ) == "checked" ) {
echo "左下";
} else {
echo "右下";
} ?>)</span>
</p>
<p>
<input type="number" name="nav-offset"
id="nav-offset" value="<?php echo get_option( 'live2d_nav-offset' ); ?>">
<span style="margin-left: 16px">目录滚动偏移高度(px)</span>
</p>
</div>
<h3>高级设置</h3>
<div style="margin-left: 50px">
<p>
<label class="switch">
<input type="checkbox" name="localkoto"
id="localkoto" <?php echo get_option( 'live2d_localkoto' ); ?> >
<span class="slider round"></span>
</label>
<span style="margin-left: 16px">本地一言(需开启一言显示)</span>
</p>
<p>自定义本地一言</p> <textarea name="custom-koto"
id="custom-koto"><?php echo get_option( 'live2d_customkoto' ); ?></textarea>
<p>自定义提示</p> <textarea name="custom-msg"
id="custom-msg"><?php echo get_option( 'live2d_custommsg' ); ?></textarea>
<p>请自行校验json有效性,不需要的话请填写{}</p>
</div>
<input type="submit" class="button-primary" value="保存设置" style="margin: 20px 0;"/>
<br><br> PoiLive2D Enhanced 版本 <?php echo LIVE2D_VERSION; ?>
<br><br>原版插件作者 <a href="https://daidr.me" target="_blank">戴兜</a> <a
href="https://daidr.me/archives/code-176.html" target="_blank">点击获取最新版本 & 说明</a>
</form>
<?php
function live2d_options_update() {
//judge nav offset is numeric first
//this can block other settings update when get error input
if ( is_numeric( $_POST['nav-offset'] ) ) {
update_option( 'live2d_nav-offset', $_POST['nav-offset'] );
} else {
update_option( 'live2d_nav_offset', 0 );
return false;
}
update_option( 'live2d_maincolor', $_POST['main-color'] );
if ( $_POST['hitokoto'] == 'on' ) {
update_option( 'live2d_hitokoto', 'checked' );
if ( $_POST['localkoto'] == 'on' ) {
update_option( 'live2d_localkoto', 'checked' );
} else {
update_option( 'live2d_localkoto', '' );
}
} else {
update_option( 'live2d_hitokoto', '' );
update_option( 'live2d_localkoto', '' );
}
if ( $_POST['special-tip'] == 'on' ) {
update_option( 'live2d_special_tip', 'checked' );
} else {
update_option( 'live2d_special_tip', '' );
}
if ( $_POST['catalog'] == 'on' ) {
update_option( 'live2d_catalog', 'checked' );
} else {
update_option( 'live2d_catalog', '' );
}
if ( $_POST['position'] == 'on' ) {
update_option( 'live2d_position', 'checked' );
} else {
update_option( 'live2d_position', '' );
}
update_option( 'live2d_customkoto', stripslashes( $_POST['custom-koto'] ) );
update_option( 'live2d_custommsg', stripslashes( $_POST['custom-msg'] ) );
return true;
}
?>