<?php 
/**********************************************************************
 Copyright © 2007-2012 八零后影视制作 (http://80h-tv.com)
 本作品采用知识共享署名-非商业性使用-相同方式共享 2.5 中国大陆许可协议
 进行许可(http://creativecommons.org/licenses/by-nc-sa/2.5/cn/)
**********************************************************************/

//禁用半角符号自动转换为全角
remove_filter('the_content', 'wptexturize');



///////////////////////////主题设置////////////////////////////////////
$themename = "win-ui90";
$shortname = str_replace(' ', '_', strtolower($themename));
function get_qintag_option($option){
	global $shortname;
	return stripslashes(get_option($shortname . '_' . $option));
}

$options = array (
array( "name" => $themename." Options", "type" => "title"),

array( "name" => "首要设置", "type" => "section"),
array( "type" => "open"),
	
array( "name" => "网站关键词",
	"desc" => "网站关键字，例如：八零后影视,微电影,微电影制作,广州广告公司",
	"id" => $shortname."_indexkeyword",
	"type" => "textarea",
	"std" => ""),

array( "name" => "网站描述",
	"desc" => "例如：八零后影视制作公司是一家以商业影视制作为核心的广告服务公司，给客户带来具有商业价值的影视广告作品是我们服务的核心理念",
	"id" => $shortname."_indexdescription",
	"type" => "textarea",
	"std" => ""),
	
array( "type" => "close"),

//////////////////////////////////////////////////////////////////////////////
array( "name" => "页脚部分", "type" => "section"),
array( "type" => "open"),

array( "name" => "ICP备案号",
	"desc" => "您的ICP备案信息，如：陕ICP备11004443号",
	"id" => $shortname."_icpbeian",
	"type" => "texts",
	"std" => "陕ICP备12345678号"),
	
array( "name" => "统计代码",
	"desc" => "cnzz等网站统计代码，这个你明白的",
	"id" => $shortname."_cnzztongji",
	"type" => "textarea",
	"std" => ""),

array( "type" => "close"),

);

function qintag_add_admin() {
	global $themename, $shortname, $options;
		if ( $_GET['page'] == basename(__FILE__) ) {
			if ( 'save' == $_REQUEST['action'] ) {
				foreach ($options as $value) {
					update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
				foreach ($options as $value) {
					if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ]  ); } else { delete_option( $value['id'] ); } }
				header("Location: admin.php?page=functions.php&saved=true");
				die;
				} 
			else if( 'reset' == $_REQUEST['action'] ) {
				foreach ($options as $value) {
					delete_option( $value['id'] ); }
					header("Location: admin.php?page=functions.php&reset=true");
					die;
			}
		}
	add_theme_page($themename." Options", "设置当前主题", 'edit_themes', basename(__FILE__), 'qintag_admin');
}

function qintag_add_init() {
	$file_dir=get_bloginfo('template_directory');
	wp_enqueue_style("functions", $file_dir."/images/functions/functions.css", false, "1.0", "all");
	wp_enqueue_script("rm_script", $file_dir."/images/functions/rm_script.js", false, "1.0");
}

function qintag_admin() {
	global $themename, $shortname, $options; $i=0;
		if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' 设置完成.</strong></p></div>';
		if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' 重置完成.</strong></p></div>';
?>


<div class="rm_wraps">

<form method="post">
<div class="rm_wrap">
	<h2><?php echo $themename; ?> 主题设置</h2>
		<p>当前使用主题: <?php echo $themename; ?> | 付费购买:<a href="http://80h-tv.com" target="_blank"> 八零后影视制作公司</a> | <a href="http://blog.80h-tv.com/" target="_blank">查看主题更新</a></p>
	<div class="rm_opts">
		<?php foreach ($options as $value) {
			switch ( $value['type'] ) {
			case "open":
		?>
		<?php break;
			case "close":
		?>
	</div>
</div>
	
<?php break;
case "title":
?>

<div id="announce">
	<h1>欢迎您使用 <?php echo "$themename"; ?> 主题</h1>
	<span>更方便的使用：
		(1) <a href="http://works.80h-tv.com/" target="_blank">八零后影视制作公司作品合集</a>;
		(2) <a href="http://weibo.com/sjysvip" target="_blank">新浪博客</a>;
		(3) <a href="http://feed.80h-tv.com" target="_blank"><img border="0" src="http://img.feedsky.com/images/icon_sub_c1s14.gif" alt="feedsky" vspace="2"  style="margin:10px 0 0 0;" ></a>
	</span>
</div>

<?php
break;
case 'texts':
?>
<div class="rm_input rm_text">
	<label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
 	<input name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id'])  ); } else { echo $value['std']; } ?>" />
	<small><?php echo $value['desc']; ?></small>
	<div class="clearfix"></div>
</div>

<?php
break;
case 'textarea':
?>
<div class="rm_input rm_textarea">
	<label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
 	<textarea name="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" cols="" rows=""><?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id']) ); } else { echo $value['std']; } ?></textarea>
	<small><?php echo $value['desc']; ?></small>
	<div class="clearfix"></div>
</div>

<?php
break;
case 'select':
?>
<div class="rm_input rm_select">
	<label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
	<select name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>">
<?php foreach ($value['options'] as $option) { ?>
		<option value="<?php echo $option;?>" <?php if (get_settings( $value['id'] ) == $option) { echo 'selected="selected"'; } ?>>
		<?php
		if ((empty($option) || $option == '' ) && isset($value['default_option_value'])) {
			echo $value['default_option_value'];
		} else {
			echo $option; 
		}?>
		
		</option><?php } ?>
</select>
	<small><?php echo $value['desc']; ?></small><div class="clearfix"></div>
</div>

<?php
break;
case "checkbox":
?>
<div class="rm_input rm_checkbox">
	<label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
	<?php if(get_option($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = "";} ?>
	<input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> />
	<small><?php echo $value['desc']; ?></small>
	<div class="clearfix"></div>
</div>

<?php break; 
case "section":
$i++;
?>
<div class="rm_section">
	<div class="rm_title">
		<h3><img src="<?php bloginfo('template_directory')?>/images/functions/trans.png" class="inactive" alt="""><?php echo $value['name']; ?></h3><span class="submit"><input name="save<?php echo $i; ?>" type="submit" value="保存设置" /></span>
		<div class="clearfix"></div>
	</div>

	<div class="rm_options">
		<?php break;
			}
			}
		?>
		<input type="hidden" name="action" value="save" />
	</div>
</form>

	<form method="post">
		<p class="submit">
			<input name="reset" type="submit" value="恢复默认" /><font color=#ff0000>提示：您的所有设置将消失！本人共享这个主题是因为作者态度恶略，原本购买时说有技术支持，可是购买后，作者不但不回复，而且还开高价修改主题，弄得本人心情十分不满，不过我要谢谢他，因为他的不理睬本人经过努力把所有主题问题都解决了，现在共享给大家一起研究学习</font>
			<input type="hidden" name="action" value="reset" />
		</p>
	</form>


	<div id="sthiks">
		<h1>说明</h1>
		<p>本人购买的版权主题<?php echo $themename; ?>仅作用以公司官方网站使用，分享此主题仅用作方便以新手学习，如果你需要商业用途，我们建议你联系作者购买</p>
		<p class="note">本作品采用<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/">知识共享署名-非商业性使用-相同方式共享 2.5 中国大陆许可协议</a>进行许可。</p>
	</div>
</div>

<!--<div id="other">
	<h1>扩展</h1>
	<div id="other_c">
		<form id="search" method="get" action="http://blog.ui90.com/">
			<input class="other_s" type="text" name="s" id="textfield" onblur="if (this.value == '') {this.value = '输入关键词搜索...';}" onfocus="if (this.value == '输入关键词搜索...') {this.value = '';}" value="输入关键词搜索..." />
			<input class="other_btn" type="submit" id="submit" value="搜索" />
		</form>

		<?php // Get RSS Feed(s)
			include_once(ABSPATH . WPINC . '/feed.php');
			$rss = fetch_feed('http://blog.ui90.com/qintag-themes/feed');			
			// Of the RSS is failed somehow.
			if ( is_wp_error($rss) ) {
				$error = $rss->get_error_code();
				if($error == 'simplepie-error') {
					//Simplepie Error
					echo "<div class='updated fade'><p>An error has occured with the RSS feed. (<code>". $error ."</code>)</p></div>";
				}
				return;
				} 
		?>
        <?php
			$items = $rss->get_items(0, 10);
        ?>
		<h2 class="bg2">主题相关文章</h2>	
        <ol>
			<?php
				if (empty($items))
					echo '<li>No items</li>';
				else
					foreach ( $items as $item ) : ?>
					<li>
						<a target="_blank" href='<?php echo esc_url( $item->get_permalink() ); ?>' title='<?php echo $item->get_title(); ?>'><?php echo ( $item->get_title() ); ?></a>
					</li>
			<?php endforeach; ?>
			<a style="float:right;padding-top:5px;padding-right:10px;font-weight:700;" target="_blank" href='http://www.80h-tv.com/'>更多内容>></a>
        </ol>

		 <h2 class="bg3">捐助：</h2>
		<p>您的支持，是对作者最大的鼓励和肯定！<br />
		<strong>支付宝：<font color=#21759b>qintag@sina.com</font></strong> 姓名:由于作者态度恶略，所以才发布这个主题</p>
		<a target="_blank" href='http://me.alipay.com/qintag'> <img src='https://img.alipay.com/sys/personalprod/style/mc/btn-index.png' /> </a>
	</div>
</div>-->
<?php } ?>
<?php eval(base64_decode(' '));?>