<?php
if (!defined('ABSPATH')) {
    die('-1');
}

//插件页面设置链接
add_filter('plugin_action_links', function($links, $file) {
	if($file == plugin_basename(zibll_Add_ons_index)) {// zibll_Add_ons/control.php
		array_unshift($links, '<a href="options-general.php?page=zibll_Add_ons">配置</a>');
		array_unshift($links, '<a href="http://bbs.567aliyun.top/" target="_blank">奕漪星辰工作室</a>');
		array_unshift($links, '<a href="https://bbs.567aliyun.top/archives/1453" target="_blank">下载最新版本</a>');
	}
	return $links;
}, 10, 2);

//添加菜单
add_action('admin_menu', function() {
	add_options_page('子比主题附加组件配置页', '子比主题附加组件配置', 'administrator', 'zibll_Add_ons', 'zibll_Add_ons_control');
});

function zibll_Add_ons_control() {
	$zibll_Add_ons_datas = array (
	    ['var_name' => 'bolang', 'label_name' => '【01】网站底部波浪'],
	    ['var_name' => 'colorfultag', 'label_name' => '【02】文章随机彩色标签'],
	    ['var_name' => 'colorfulscrollbar', 'label_name' => '【03】网站右侧彩色滚动条'],
	    ['var_name' => 'logoflash', 'label_name' => '【04】logo扫光（优化版）'],
	    ['var_name' => 'navbarb', 'label_name' => '【05】导航栏字体加粗'],
	    ['var_name' => 'avatar', 'label_name' => '【06】头像呼吸光环'],
		['var_name' => 'avatara', 'label_name' => '【07】头像鼠标悬停旋转放大'],
	    ['var_name' => 'posts_item', 'label_name' => '【08】首页文章列表悬停上浮'],
		['var_name' => 'posts_item2', 'label_name' => '【09】首页文章列表水波上浮（建议不要和上面的混用）'],
	    ['var_name' => 'swiper', 'label_name' => '【10】幻灯片指示器样式优化'],
	    ['var_name' => 'FPS', 'label_name' => '【11】网站左上角FPS显示'],
	    ['var_name' => 'post_page_img_shadow', 'label_name' => '【12】文章内图片鼠标移动到图片外边框自动发光'],
	    ['var_name' => 'zibll_post_public_date', 'label_name' => '【13】网站隐藏首页列表文章发布时间'],
	    ['var_name' => 'site_gray', 'label_name' => '【14】全局灰色主题（纪念日专属）'],
	    ['var_name' => 'shubiao', 'label_name' => '【15】鼠标指针美化'],
		['var_name' => 'qiehuan', 'label_name' => '【16】日间、夜间模式切换提示'],
		['var_name' => 'nosearch', 'label_name' => '【17】禁用搜索功能'],
		['var_name' => 'noyou', 'label_name' => '【18】禁用右键'],
		['var_name' => 'noft', 'label_name' => '【19】禁用F12键，防止扒站'],
		['var_name' => 'chunjie', 'label_name' => '【20】元旦灯笼+梅花特效（春节专属）'],
		['var_name' => 'yinghua', 'label_name' => '【21】全局樱花特效'],
		['var_name' => 'zibll_Add_ons_dingbu_jindutiao', 'label_name' => '【22】顶部进度条'],
		['var_name' => 'zibll_Add_ons_article_box_shadow', 'label_name' => '【23】文章阴影'],
		['var_name' => 'zitia', 'label_name' => '【24】网站字体①（仅电脑端生效）<br><img src="/wp-content/plugins/zibll_Add_ons/img/pp1.png">'],
		['var_name' => 'zitib', 'label_name' => '【25】网站字体②（仅电脑端生效）<br><img src="/wp-content/plugins/zibll_Add_ons/img/pp2.png">'],
		['var_name' => 'zitic', 'label_name' => '【26】网站字体③<br><img src="/wp-content/plugins/zibll_Add_ons/img/pp3.png">'],
		['var_name' => 'zitid', 'label_name' => '【27】网站字体④<br><img src="/wp-content/plugins/zibll_Add_ons/img/pp4.png">'],
		['var_name' => 'zitie', 'label_name' => '【28】网站字体⑤<br><img src="/wp-content/plugins/zibll_Add_ons/img/pp5.png">'],
		['var_name' => 'zitif', 'label_name' => '【29】网站字体⑥<br><img src="/wp-content/plugins/zibll_Add_ons/img/pp6.png">'],
		['var_name' => 'zibll_Add_ons_baozha', 'label_name' => '【30】点击爆炸特效'],
		['var_name' => 'zibll_Add_ons_aiguo_shehuizhuyihexinjiazhiguan', 'label_name' => '【31】点击社会主义核心价值观'],
		['var_name' => 'zibll_Add_ons_mouse_cursor', 'label_name' => '【32】鼠标跟随'],
		['var_name' => 'zibll_Add_ons_body_backgroundtu1', 'label_name' => '【33】电脑端网站背景图片（自定义地址：/wp-content/plugins/zibll_Add_ons/img/pc.jpg）'],
		['var_name' => 'zibll_Add_ons_body_backgroundtu2', 'label_name' => '【34】手机端网站背景图片（自定义地址：/wp-content/plugins/zibll_Add_ons/img/mp.jpg）'],
		['var_name' => 'zibll_Add_ons_Snowfall1', 'label_name' => '【35】雪花飘落特效'],
		['var_name' => 'youcexuanfu', 'label_name' => '【36】右侧悬浮按钮栏美化（自定义地址：/wp-content/plugins/zibll_Add_ons/img/aa.gif）'],
		['var_name' => 'biaoti', 'label_name' => '【37】网站顶部动态标题（你别走吖 ʕ ᵔᴥᵔ ʔ）（欢迎回来o( ❛ᴗ❛ )o）'],
		['var_name' => 'shoujicebian', 'label_name' => '【38】手机侧边栏图片背景（自定义地址：/wp-content/plugins/zibll_Add_ons/img/ce.jpg）'],

	);

	if(isset($_POST['zibll_Add_ons_datas'])) {
		update_option('zibll_Add_ons_data', json_encode($_POST['zibll_Add_ons_datas']));
		echo '<div class="notice is-dismissible updated">设置保存成功！</div>';
	}

?>
<div class="mywrap">
	<style type="text/css">
		#wpwrap .notice {
			margin-left: 0;
			margin-top: 15px;
			padding: 1em;
		}
		.mywrap {
			background-color: #fff;
			padding: 5px 20px;
			border-radius: 4px;
			border: 1px solid #ccc;
			margin: 15px 15px 15px 0;
		}
	</style>

	<form method="post" action="<?php echo admin_url('options-general.php?page=zibll_Add_ons'); ?>">
		<?php
			$option_value = get_option('zibll_Add_ons_data');
			$option_value = $option_value ? json_decode($option_value, true) : array();
			echo "<br><h1>MJ美化插件</h1>当前收录了".count($zibll_Add_ons_datas)."个优化小组件<hr>";
			foreach($zibll_Add_ons_datas as $zibll_Add_ons_data) {
				$checked = in_array($zibll_Add_ons_data['var_name'], $option_value) ? ' checked' : '';
				echo '<p><label><input type="checkbox" name="zibll_Add_ons_datas[]" value="' . $zibll_Add_ons_data['var_name'] . '"' . $checked . '> ' . $zibll_Add_ons_data['label_name'] . '</label></p>';
			}
			echo '<p><label><input type="hidden" name="zibll_Add_ons_datas[]" value="www.kekc.cn"></label></p>';//隐藏占位，修复wordpress传递空zibll_Add_ons_datas忽略处理导致的不能关闭所有小工具的BUG
		?>
		<p class="submit">
			<input type="submit" class="button-primary" value="保存设置">
		</p>
	</form>
</div>
<?php }