<?php
if ( function_exists('register_sidebar') )
	register_sidebar(array(
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => '</li>',
        'before_title' => '',
        'after_title' => '',
    ));

function getOptions() {
  // 在数据库中获取选项组
  $options = get_option('classic_options');
  // 如果数据库中不存在该选项组, 设定这些选项的默认值, 并将它们插入数据库
  if (!is_array($options)) {
    $options['notice'] = false;
    $options['notice_content'] = '';
    update_option('classic_options', $options);
  }
  return $options;
}
function init() {
  if(isset($_POST['classic_save'])) {
    $options = getOptions();
    if ($_POST['notice']) {
      $options['notice'] = (bool)true;
    } else {
      $options['notice'] = (bool)false;
    }
    $options['notice_content'] = stripslashes($_POST['notice_content']);
    update_option('classic_options', $options);
  }
   else 
    getOptions();
add_theme_page("标签页", __('Theme Options'), 'edit_themes', basename(__FILE__), 'display');
}
function display() {
  $options = getOptions();
?>
<form action="#" method="post" enctype="multipart/form-data" name="classic_form" id="classic_form">
在页脚显示代码？ <input name="notice" type="checkbox" value="checkbox" <?php if($options['notice']) echo "checked='checked'"; ?> /><br />
代码内容：<textarea name="notice_content" cols="50" rows="10" id="notice_content"  class="code"><?php echo($options['notice_content']); ?></textarea><br />
<input type="submit" name="classic_save" />
</form>
<?php
	}
add_action('admin_menu', 'init');
?>
