<?php
/**
 * A unique identifier is defined to store the options in the database and reference them from the theme.
 * By default it uses the theme name, in lowercase and without spaces, but this can be changed if needed.
 * If the identifier changes, it'll appear as if the options have been reset.
 * 
 */

function grain_option_name() {

	// This gets the theme name from the stylesheet (lowercase and without spaces)
	$grain_themename = get_theme_data(STYLESHEETPATH . '/style.css');
	$grain_themename = $grain_themename['Name'];
	$grain_themename = preg_replace("/\W/", "", strtolower($grain_themename) );
	
	$grain_settings = get_option('grain');
	$grain_settings['id'] = $grain_themename;
	update_option('grain', $grain_settings);
	
	// echo $grain_themename;
}

/**
 * Defines an array of options that will be used to generate the settings page and be saved in the database.
 * When creating the "id" fields, make sure to use all lowercase and no spaces.
 *  
 */

function grain_options() {
	
	$grain_layout_array = array("narrow-sidebar" => "Narrow Sidebar","wide-sidebar" => "Wide Sidebar");

	$grain_color_scheme_array = array("blue" => "Blue", "bright-blue" => "Bright Blue", "green" => "Green", "red" => "Red", "red-yellow" => "Red-Yellow");
		
	$grain_options = array();
		
	$grain_options[] = array( "name" => "Customise",
						"type" => "heading");
							
								
	$grain_options[] = array( "name" => "Feedburner URL",
						"desc" => "Enter custom Feedburner URL",
						"id" => "feed_url",
						"std" => get_bloginfo('rss2_url'),
						"type" => "text");
						
	$grain_options[] = array( "name" => "Grain Layout",
						"desc" => "Select a layout of your choice",
						"id" => "layout",
						"std" => "narrow-sidebar",
						"type" => "radio",
						"options" => $grain_layout_array);
						
	$grain_options[] = array( "name" => "Colour scheme",
						"desc" => "Choose your favourite colour scheme",
						"id" => "color_scheme",
						"std" => "blue",
						"type" => "radio",
						"options" => $grain_color_scheme_array);
							
	$grain_options[] = array( "name" => "Favicon",
						"desc" => "Upload the image that is to displayed in the URL bar of the viewer. 24x24 is the optimum size",
						"id" => "favicon",
						"type" => "upload");
						
		
	return $grain_options;
}