Skip to content

Commit

Permalink
v2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
rayfalling committed Feb 3, 2020
1 parent a29e2cf commit 9686ffa
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 32 deletions.
18 changes: 11 additions & 7 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: PoiLive2D Enhanced
Plugin URI: https://github.com/wanghaiwei/PoiLive2d-Enhanced
Description: 萌萌哒WordPress看板娘耶!
Version: 2.0.1
Version: 2.0.2
Author: 墨笙
Author URI: https://rayfalling.com
License: GPL2
Expand Down Expand Up @@ -53,27 +53,31 @@ function poilive2d_pluginoptions_page() {
'live2d_special_tip' => 'checked',
'live2d_localkoto' => '',
'live2d_catalog' => 'checked',
'live2d_position' => 'checked'
'live2d_position' => 'checked',
'live2d_nav-offset' => 0
);

//写入默认设置
if ( ! get_option( 'live2d_maincolor' ) ) {
update_option( 'live2d_maincolor', $live2d_setting_default['maincolor'] );
}
if ( ! get_option( 'live2d_hitokoto' ) ) {
update_option( 'live2d_hitokoto', $live2d_setting_default['live2d_hitokoto'] );
update_option( 'live2d_hitokoto', $live2d_setting_default['live2d_hitokoto'] );
}
if ( ! get_option( 'live2d_special_tip' ) ) {
update_option( 'live2d_special_tip', $live2d_setting_default['live2d_special_tip'] );
update_option( 'live2d_special_tip', $live2d_setting_default['live2d_special_tip'] );
}
if ( ! get_option( 'live2d_localkoto' ) ) {
update_option( 'live2d_localkoto',$live2d_setting_default['live2d_localkoto'] );
update_option( 'live2d_localkoto', $live2d_setting_default['live2d_localkoto'] );
}
if ( ! get_option( 'live2d_catalog' ) ) {
update_option( 'live2d_catalog', $live2d_setting_default['live2d_catalog'] );
update_option( 'live2d_catalog', $live2d_setting_default['live2d_catalog'] );
}
if ( ! get_option( 'live2d_position' ) ) {
update_option( 'live2d_position', $live2d_setting_default['live2d_position'] );
update_option( 'live2d_position', $live2d_setting_default['live2d_position'] );
}
if ( ! get_option( 'live2d_nav-offset' ) ) {
update_option( 'live2d_nav-offset', $live2d_setting_default['live2d_nav-offset'] );
}
if ( ! get_option( 'live2d_custommsg' ) ) {
$json = "{\"mouseover\":[{\"selector\":\".entry-content a\",\"text\":[\"要看看 <span style='color:#0099cc;'>「{text}」</span> 么?\"]},{\"selector\":\".post .post-title\",\"text\":[\"主人写的<s>爽文</s> <span style='color:#0099cc;'>「{text}」</span> ,要看看嘛?\"]},{\"selector\":\".feature-content a\",\"text\":[\"超级热门的 <span style='color:#0099cc;'>「{text}」</span> ,要看看么?\"]},{\"selector\":\".searchbox\",\"text\":[\"在找什么东西呢,需要帮忙吗?\"]},{\"selector\":\".top-social\",\"text\":[\"这里是主人的社交账号啦!不关注一波嘛?\"]},{\"selector\":\".zilla-likes\",\"text\":[\"听说点这个主人会很开心哦~\"]},{\"selector\":\".cd-top\",\"text\":[\"你想要返回顶部嘛?\"]},{\"selector\":\".site-title\",\"text\":[\"你要返回首页是吗?\"]},{\"selector\":\".comments\",\"text\":[\"看了这么久,是时候评论一下啦!\"]},{\"selector\":\".post-nepre.previous\",\"text\":[\"看看主人的上一篇文章怎么样?\"]},{\"selector\":\".post-nepre.next\",\"text\":[\"看看主人的下一篇文章怎么样?\"]},{\"selector\":\".reward-open\",\"text\":[\"你看主人把我扔在这么慢的服务器上,打赏了解一下?\"]},{\"selector\":\".poiplay.playing\",\"text\":[\"这是播放按钮啦~\"]},{\"selector\":\".poi-open-list\",\"text\":[\"戳一下就可以看到歌词哦!\"]},{\"selector\":\"#open-poi-player\",\"text\":[\"听说点这个按钮可以显示/隐藏播放器?\"]},{\"selector\":\".hide-button\",\"text\":[\"我有话唠属性,觉得我烦可以关掉我哦~\"]},{\"selector\":\"#pagination\",\"text\":[\"想看看更久远的内容?\"]}],\"click\":[{\"selector\":\"#landlord #live2d\",\"text\":[\"不要动手动脚的!快把手拿开~~\",\"真…真的是不知羞耻!\",\"Hentai!\",\"再摸的话我可要报警了!⌇●﹏●⌇\",\"110吗,这里有个变态一直在摸我(ó﹏ò。)\"]}]}";
Expand Down
44 changes: 27 additions & 17 deletions live2d/js/message.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,20 @@
echo 'const message_Path = "' . LIVE2D_URL . '/live2d/";';
echo 'const home_Path = "' . home_url() . '/";';

if ( get_option( 'live2d_nohitokoto' ) == "checked" ) {
$noHitoKoto = 'true';
// echo "let nohitokoto = true;";
} else {
if ( get_option( 'live2d_hitokoto' ) == "checked" ) {
$noHitoKoto = 'false';
// echo "let nohitokoto = false;";
}
if ( get_option( 'live2d_nospecialtip' ) == "checked" ) {
$noSpecialTip = 'true';
// echo "let nospecialtip = true;";
} else {
$noHitoKoto = 'true';
}
if ( get_option( 'live2d_special_tip' ) == "checked" ) {
$noSpecialTip = 'false';
// echo "let nospecialtip = false;";
} else {
$noSpecialTip = 'true';
}
if ( get_option( 'live2d_localkoto' ) == "checked" ) {
$localKoto = 'true';
// echo "let localkoto = true;";
} else {
$localKoto = 'false';
// echo "let localkoto = false;";
}

?>
Expand Down Expand Up @@ -207,17 +201,33 @@ function hideMessage(timeout) {
}

function positionWrap() {
$('.h2wrap, .h3wrap').click(function () {
$('.h2wrap, .h3wrap .h4wrap').click(function () {
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
let $target = $(this.hash);
$target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']');
if ($target.length) {
const targetOffset = $target.offset().top;
<?php if ( current_user_can( 'level_10' ) ): ?>
<?php if ( get_option( 'live2d_nav-offset' ) ) : ?>
$('html,body').animate({
scrollTop: targetOffset - 32 - <?php echo get_option( 'live2d_nav-offset' ); ?>
}, 800);
<?php else: ?>
$('html,body').animate({
scrollTop: targetOffset - 32 - $('nav').height() == undefined ? 0 : $('nav').height()
}, 800);
<?php endif; ?>
<?php else:?>
<?php if ( get_option( 'live2d_nav-offset' ) ) : ?>
$('html,body').animate({
scrollTop: targetOffset - <?php echo get_option( 'live2d_nav-offset' ); ?>
}, 800);
<?php else: ?>
$('html,body').animate({
scrollTop: targetOffset
},
800);
return false;
scrollTop: targetOffset - $('nav').height() == undefined ? 0 : $('nav').height()
}, 800);
<?php endif; ?>
<?php endif; ?>
}
}
});
Expand Down
36 changes: 28 additions & 8 deletions option.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?php
defined( 'ABSPATH' ) or exit;
if ( $_POST['update_plugin_options'] == 'true' ) {
live2d_options_update();
echo '<div id="message" class="updated"><h4>设置已成功保存</a></h4></div>';
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>
Expand Down Expand Up @@ -94,12 +97,12 @@
<span style="margin-left: 16px">一言显示</span>
</p>
<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>
<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>
<label class="switch">
Expand Down Expand Up @@ -130,6 +133,11 @@
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">
Expand All @@ -149,6 +157,16 @@

<?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' ) {
Expand Down Expand Up @@ -183,6 +201,8 @@ function live2d_options_update() {

update_option( 'live2d_customkoto', stripslashes( $_POST['custom-koto'] ) );
update_option( 'live2d_custommsg', stripslashes( $_POST['custom-msg'] ) );

return true;
}

?>
4 changes: 4 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html

== Changelog ==

= 2.0.2 =
* 修复了一些bug
* 添加了选择目录导航滚动偏移

= 2.0.1 =
* 优化了设置页
* 添加了选择live2d位置的设置
Expand Down

0 comments on commit 9686ffa

Please sign in to comment.