"Background Color", "id" => "bs_bgcolor", "std" => "#4682B4", "desc" => "The background color for the outsides of the page.", "type" => "color" ), array( "name" => "Page Background Color", "id" => "bs_pagecolor", "std" => "#777", "desc" => "The background color for the middle of the page.", "type" => "color" ), array( "name" => "Header Text Color", "id" => "bs_headertextcolor", "std" => "#000", "desc" => "", "type" => "color" ), array( "name" => "Text Color", "id" => "bs_textcolor", "std" => "#fff", "desc" => "", "type" => "color" ), array( "name" => "Link Color", "id" => "bs_linkcolor", "std" => "#aaa", "desc" => "", "type" => "color" ), array( "name" => "Navigation Link Color", "id" => "bs_navcolor", "std" => "#fff", "desc" => "", "type" => "color" ), array( "name" => "Transparency Percent", "id" => "bs_transamount", "std" => ".8", "desc" => "Between 0 and 1, 0 = invisible, 1 = solid", "type" => "number" ) ); function mytheme_add_admin() { global $themename, $shortname, $options; if ( $_GET['page'] == basename(__FILE__) ) { if ( 'save' == $_REQUEST['action'] ) { foreach ($options as $value) { switch ($value['type']) { case "color": //get the color $v = $_POST[ $value['id'] ]; //if it starts with a pount sign, remove it if ($v[0] == '#') $v = substr($v, 1); //Ensure $v is a hex color of length 3 or 6; if ((strlen($v) == 3 || strlen($v) == 6) && isHex($v)) { update_option( $value['id'], "#".$v ); } break; case "number": $v = $_POST[ $value['id'] ]; //Ensure $v is a number if (is_numeric($v)) { //fix the bounds of the color if ($v < 0) $v = 0; else if ($v > 1) $v = 1; update_option( $value['id'], $v ); } break; } } header("Location: themes.php?page=theme-options.php&saved=true"); die; } else if( 'reset' == $_REQUEST['action'] ) { //seed the options with the options in the array if they aren't already. foreach ($options as $value) { if ( !isset($value['id']) ) { add_option($value['id'], $value['std']); } else { update_option($value['id'], $value['std']); } } header("Location: themes.php?page=theme-options.php&reset=true"); die; } } add_theme_page($themename." Options", $themename." Options", 'edit_themes', basename(__FILE__), 'mytheme_admin'); } function mytheme_admin() { global $themename, $shortname, $options; if ( $_REQUEST['saved'] ) echo '
'.$themename.' settings saved.
'.$themename.' settings reset.