<?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 optionsframework_option_name() {

	// This gets the theme name from the stylesheet
	$themename = get_option( 'stylesheet' );
	$themename = preg_replace("/\W/", "_", strtolower($themename) );

	$optionsframework_settings = get_option( 'optionsframework' );
	$optionsframework_settings['id'] = $themename;
	update_option( 'optionsframework', $optionsframework_settings );
}

/**
 * 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.
 *
 * If you are making your theme translatable, you should replace 'awesome'
 * with the actual text domain for your theme.  Read more:
 * http://codex.wordpress.org/Function_Reference/load_theme_textdomain
 */

function optionsframework_options() {

	// Test data
	$test_array = array(
		'one' => __('One', 'awesome'),
		'two' => __('Two', 'awesome'),
		'three' => __('Three', 'awesome'),
		'four' => __('Four', 'awesome'),
		'five' => __('Five', 'awesome')
	);

	// Multicheck Array
	$multicheck_array = array(
		'one' => __('French Toast', 'awesome'),
		'two' => __('Pancake', 'awesome'),
		'three' => __('Omelette', 'awesome'),
		'four' => __('Crepe', 'awesome'),
		'five' => __('Waffle', 'awesome')
	);

	// Multicheck Defaults
	$multicheck_defaults = array(
		'one' => '1',
		'five' => '1'
	);

	// Background Defaults
	$background_defaults = array(
		'color' => '',
		'image' => '',
		'repeat' => 'repeat',
		'position' => 'top center',
		'attachment'=>'scroll' );

	// Typography Defaults
	$typography_defaults = array(
		'size' => '15px',
		'face' => 'georgia',
		'style' => 'bold',
		'color' => '#bada55' );
		
	// Typography Options
	$typography_options = array(
		'sizes' => array( '6','12','14','16','20' ),
		'faces' => array( 'Helvetica Neue' => 'Helvetica Neue','Arial' => 'Arial' ),
		'styles' => array( 'normal' => 'Normal','bold' => 'Bold' ),
		'color' => false
	);

	// Pull all the categories into an array
	$options_categories = array();
	$options_categories_obj = get_categories();
	foreach ($options_categories_obj as $category) {
		$options_categories[$category->cat_ID] = $category->cat_name;
	}
	
	// Pull all tags into an array
	$options_tags = array();
	$options_tags_obj = get_tags();
	foreach ( $options_tags_obj as $tag ) {
		$options_tags[$tag->term_id] = $tag->name;
	}


	// Pull all the pages into an array
	$options_pages = array();
	$options_pages_obj = get_pages('sort_column=post_parent,menu_order');
	$options_pages[''] = 'Select a page:';
	foreach ($options_pages_obj as $page) {
		$options_pages[$page->ID] = $page->post_title;
	}

	// If using image radio buttons, define a directory path
	$imagepath =  get_template_directory_uri() . '/images/';
	
	$options = array();

	$options[] = array(
		'name' => __('General', 'awesome'),
		'type' => 'heading');
		
	$options[] = array(
		'name' => __('Favicon', 'awesome'),
		'desc' => __('Upload your website favicon image.', 'awesome'),
		'id' => 'aw_favicon',
		'type' => 'upload');	
		
	$options[] = array(
		'name' => __('Logo', 'awesome'),
		'desc' => __('Upload your website logo image.', 'awesome'),
		'id' => 'aw_logo',
		'type' => 'upload');		
		
	$options[] = array(
		'name' => __('Footer Credit', 'awesome'),
		'desc' => __('Custom footer credit.', 'awesome'),
		'id' => 'aw_fcredit',
		'std' => '',
		'type' => 'text');		
		
	$options[] = array(
		'name' => __('About Your Company', 'awesome'),
		'type' => 'info');			
		
	$options[] = array(
		'name' => __('Tagline', 'awesome'),
		'id' => 'aw_ctagline',
		'std' => '',
		'type' => 'text');	
		
	$options[] = array(
		'name' => __('Description', 'awesome'),
		'id' => 'aw_cdesc',
		'std' => '',
		'type' => 'textarea');	
		
	$options[] = array(
		'name' => __('Image', 'awesome'),
		'id' => 'aw_cimg',
		'type' => 'upload');			
		
	$options[] = array(
		'name' => __('Social Media', 'awesome'),
		'type' => 'info');				
		
	$options[] = array(
		'name' => __('Twitter', 'awesome'),
		'desc' => __('Input your Twitter profile URL.', 'awesome'),
		'id' => 'aw_twitter',
		'class' => 'mini',
		'type' => 'text');

	$options[] = array(
		'name' => __('Facebook', 'awesome'),
		'desc' => __('Input your Facebook profile URL.', 'awesome'),
		'id' => 'aw_fb',
		'std' => '',
		'class' => 'mini',
		'type' => 'text');

	$options[] = array(
		'name' => __('Flickr', 'awesome'),
		'desc' => __('Input your Flickr profile URL', 'awesome'),
		'id' => 'aw_flickr',
		'std' => '',
		'class' => 'mini',
		'type' => 'text');

	$options[] = array(
		'name' => __('RSS', 'awesome'),
		'desc' => __('Input your RSS feed link.', 'awesome'),
		'id' => 'aw_rss',
		'std' => '',
		'class' => 'mini',
		'type' => 'text');
		

	$options[] = array(
		'name' => __('Contact', 'awesome'),
		'type' => 'heading');

	$options[] = array(
		'name' => __('Quick Contact', 'awesome'),
		'desc' => __('Displayed in header, in right side of main menu.', 'awesome'),
		'type' => 'info');		

	$options[] = array(
		'name' => __('Email', 'awesome'),
		'id' => 'aw_mailtop',
		'std' => '',
		'class' => 'mini',
		'type' => 'text');		
		
	$options[] = array(
		'name' => __('Phone', 'awesome'),
		'id' => 'aw_phonetop',
		'std' => '',
		'class' => 'mini',
		'type' => 'text');			
		
	$options[] = array(
		'name' => __('More Contact Details', 'awesome'),
		'type' => 'info');				
		
	$options[] = array(
		'name' => __('Phone number 1', 'awesome'),
		'desc' => __('Input your phone number.', 'awesome'),
		'id' => 'aw_pnumber',
		'std' => '',
		'class' => 'mini',
		'type' => 'text');

	$options[] = array(
		'name' => __('Phone number 2', 'awesome'),
		'desc' => __('Input your phone number.', 'awesome'),
		'id' => 'aw_pnumber2',
		'std' => '',
		'class' => 'mini',
		'type' => 'text');

	$options[] = array(
		'name' => __('Email address 1', 'awesome'),
		'desc' => __('Input your email address.', 'awesome'),
		'id' => 'aw_mail',
		'std' => '',
		'class' => 'mini',
		'type' => 'text');

	$options[] = array(
		'name' => __('Email address 2', 'awesome'),
		'desc' => __('Input your email address', 'awesome'),
		'id' => 'aw_mail2',
		'std' => '',
		'class' => 'mini',
		'type' => 'text');

	$options[] = array(
		'name' => __('Email address 2', 'awesome'),
		'desc' => __('Input your email address', 'awesome'),
		'id' => 'aw_mail2',
		'std' => '',
		'class' => 'mini',
		'type' => 'text');

	$options[] = array(
		'name' => __('Google map address', 'awesome'),
		'desc' => __('Input your Google map address.', 'awesome'),
		'id' => 'aw_gmap',
		'std' => '',
		'class' => 'mini',
		'type' => 'text');
		
	$options[] = array(
		'name' => __('Contact Form', 'awesome'),
		'type' => 'info');				
		
	$options[] = array(
		'name' => __('Email Admin', 'awesome'),
		'desc' => __('Input your email address admin for contact form', 'awesome'),
		'id' => 'aw_mailadmin',
		'std' => '',
		'class' => 'mini',
		'type' => 'text');		
		
	$options[] = array(
		'name' => __('Team Members', 'awesome'),
		'type' => 'heading');		
		
	$options[] = array(
		'name' => __('Team 1', 'awesome'),
		'desc' => __('Team 1 information details.', 'awesome'),
		'type' => 'info');	

	$options[] = array(
		'name' => __('Name', 'awesome'),
		'id' => 'aw_t_name1',
		'std' => '',
		'class' => 'mini',
		'type' => 'text');	

	$options[] = array(
		'name' => __('Position', 'awesome'),
		'id' => 'aw_t_position1',
		'std' => '',
		'class' => 'mini',
		'type' => 'text');		

	$options[] = array(
		'name' => __('Phone', 'awesome'),
		'id' => 'aw_t_phone1',
		'std' => '',
		'class' => 'mini',
		'type' => 'text');				

	$options[] = array(
		'name' => __('Short Biography', 'awesome'),
		'id' => 'aw_t_bio1',
		'std' => '',
		'type' => 'textarea');				

	$options[] = array(
		'name' => __('Profile picture', 'awesome'),
		'id' => 'aw_t_pp1',
		'std' => '',
		'type' => 'upload');	

	$options[] = array(
		'name' => __('Twitter profile URL', 'awesome'),
		'id' => 'aw_t_twitter1',
		'std' => 'http://',
		'class' => 'mini',
		'type' => 'text');		

	$options[] = array(
		'name' => __('Facebook profile URL', 'awesome'),
		'id' => 'aw_t_fb1',
		'std' => 'http://',
		'class' => 'mini',
		'type' => 'text');		

	$options[] = array(
		'name' => __('Flickr profile URL', 'awesome'),
		'id' => 'aw_t_fr1',
		'std' => 'http://',
		'class' => 'mini',
		'type' => 'text');		

	$options[] = array(
		'name' => __('Team 2', 'awesome'),
		'desc' => __('Team 2 information details.', 'awesome'),
		'type' => 'info');		

	$options[] = array(
		'name' => __('Name', 'awesome'),
		'id' => 'aw_t_name2',
		'std' => '',
		'class' => 'mini',
		'type' => 'text');	

	$options[] = array(
		'name' => __('Position', 'awesome'),
		'id' => 'aw_t_position2',
		'std' => '',
		'class' => 'mini',
		'type' => 'text');		

	$options[] = array(
		'name' => __('Phone', 'awesome'),
		'id' => 'aw_t_phone2',
		'std' => '',
		'class' => 'mini',
		'type' => 'text');				

	$options[] = array(
		'name' => __('Biography', 'awesome'),
		'id' => 'aw_t_bio2',
		'std' => '',
		'type' => 'textarea');				

	$options[] = array(
		'name' => __('Profile picture', 'awesome'),
		'id' => 'aw_t_pp2',
		'std' => '',
		'type' => 'upload');	

	$options[] = array(
		'name' => __('Twitter profile URL', 'awesome'),
		'id' => 'aw_t_twitter2',
		'std' => 'http://',
		'class' => 'mini',
		'type' => 'text');		

	$options[] = array(
		'name' => __('Facebook profile URL', 'awesome'),
		'id' => 'aw_t_fb2',
		'std' => 'http://',
		'class' => 'mini',
		'type' => 'text');		

	$options[] = array(
		'name' => __('Flickr profile URL', 'awesome'),
		'id' => 'aw_t_fr2',
		'std' => 'http://',
		'class' => 'mini',
		'type' => 'text');

	$options[] = array(
		'name' => __('Team 3', 'awesome'),
		'desc' => __('Team 3 information details.', 'awesome'),
		'type' => 'info');	

	$options[] = array(
		'name' => __('Name', 'awesome'),
		'id' => 'aw_t_name3',
		'std' => '',
		'class' => 'mini',
		'type' => 'text');	

	$options[] = array(
		'name' => __('Position', 'awesome'),
		'id' => 'aw_t_position3',
		'std' => '',
		'class' => 'mini',
		'type' => 'text');		

	$options[] = array(
		'name' => __('Phone', 'awesome'),
		'id' => 'aw_t_phone3',
		'std' => '',
		'class' => 'mini',
		'type' => 'text');				

	$options[] = array(
		'name' => __('Biography', 'awesome'),
		'id' => 'aw_t_bio3',
		'std' => '',
		'type' => 'textarea');				

	$options[] = array(
		'name' => __('Profile picture', 'awesome'),
		'id' => 'aw_t_pp3',
		'std' => '',
		'type' => 'upload');	

	$options[] = array(
		'name' => __('Twitter profile URL', 'awesome'),
		'id' => 'aw_t_twitter3',
		'std' => 'http://',
		'class' => 'mini',
		'type' => 'text');		

	$options[] = array(
		'name' => __('Facebook profile URL', 'awesome'),
		'id' => 'aw_t_fb3',
		'std' => 'http://',
		'class' => 'mini',
		'type' => 'text');		

	$options[] = array(
		'name' => __('Flickr profile URL', 'awesome'),
		'id' => 'aw_t_fr3',
		'std' => 'http://',
		'class' => 'mini',
		'type' => 'text');		

	$options[] = array(
		'name' => __('Miscellaneous', 'awesome'),
		'type' => 'heading');		

	$options[] = array(
		'name' => __('Motto', 'awesome'),
		'id' => 'aw_motto',
		'std' => '',
		'type' => 'text');			

	$options[] = array(
		'name' => __('Purchase Teaser Head', 'awesome'),
		'id' => 'aw_purchase_hteaser',
		'std' => '',
		'type' => 'textarea');			

	$options[] = array(
		'name' => __('Purchase Teaser Content', 'awesome'),
		'id' => 'aw_purchase_cteaser',
		'std' => '',
		'type' => 'textarea');	

	$options[] = array(
		'name' => __('Purchase Button Name', 'awesome'),
		'id' => 'aw_purchase_btn',
		'std' => '',
		'class' => 'mini',
		'type' => 'text');			

	$options[] = array(
		'name' => __('Purchase Button URL', 'awesome'),
		'id' => 'aw_purchase_url',
		'std' => 'http://',
		'class' => 'mini',
		'type' => 'text');				

	return $options;
}

/*
 * This is an example of how to add custom scripts to the options panel.
 * This example shows/hides an option when a checkbox is clicked.
 */

add_action('optionsframework_custom_scripts', 'optionsframework_custom_scripts');

function optionsframework_custom_scripts() { ?>

<script type="text/javascript">
jQuery(document).ready(function($) {

	$('#example_showhidden').click(function() {
  		$('#section-example_text_hidden').fadeToggle(400);
	});

	if ($('#example_showhidden:checked').val() !== undefined) {
		$('#section-example_text_hidden').show();
	}

});
</script>

<?php
}