<?php

function envira_options(){
// VARIABLES
$themename = "enVirashop";
$manualurl = 'http://www.lifeofstrange.com/envirashop/ReadMe.pdf';
$shortname = "envira";

$GLOBALS['template_path'] = get_bloginfo('template_directory');

//Access the WordPress Categories via an Array
$envira_categories = array();  
$envira_categories_obj = get_categories('hide_empty=0');
foreach ($envira_categories_obj as $envira_cat) {
    $envira_categories[$envira_cat->cat_ID] = $envira_cat->cat_name;}
$categories_tmp = array_unshift($envira_categories, "Select a category:");    
       
//Access the WordPress Pages via an Array
$envira_pages = array();
$envira_pages_obj = get_pages('sort_column=post_parent,menu_order');    
foreach ($envira_pages_obj as $envira_page) {
    $envira_pages[$envira_page->ID] = $envira_page->post_name; }
$envira_pages_tmp = array_unshift($envira_pages, "Select a page:");

//More Options
$all_uploads_path = get_bloginfo('home') . '/wp-content/uploads/';
$all_uploads = get_option('envira_uploads');
$other_entries = array("Select a number:","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19");
$cart_icons = array("orange","blue","green","grey","purple");
$banner_icons = array("blue","green","grey","purple","red");
$checkout_option = array("","PayPal","GoogleCheckout");
$currency = array("","USD","GBP","AUD","CAD","CZK","DKK","EUR","HKD","HUF","ILS","JPY","MXN","NOK","NZD","PLN","SGD","SEK","CHF");
$carousel_animation = array("","slow","fast");
$relatedproducts = array("Yes","No");



// THIS IS THE DIFFERENT FIELDS
$options = array();   

$options[] = array(	"name" => "General Settings",
					"type" => "heading");

$options[] = array( "name" => "Shopping Cart Color",
					"desc" => "Select your color scheme for the Shopping Cart",
					"id" => $shortname."_cart_color",
					"type" => "select",
					"options" => $cart_icons);
					            
$options[] = array( "name" => "Custom Logo",
					"desc" => "Upload a logo for your theme, or specify the image address of your online logo. (http://yoursite.com/logo.png)",
					"id" => $shortname."_logo",
					"std" => "",
					"type" => "upload");    
                                                                                     
$options[] = array( "name" => "Custom Favicon",
					"desc" => "Upload a 16px x 16px Png/Gif image that will represent your website's favicon.",
					"id" => $shortname."_custom_favicon",
					"std" => "",
					"type" => "upload");                                                                                                                   		

$options[] = array( "name" => "Show Related Products",
					"desc" => "Choose to display related products on your products page.",
					"id" => $shortname."_related_posts",
					"type" => "select",
					"options" => $relatedproducts);
                                               
$options[] = array( "name" => "Tracking Code",
					"desc" => "Paste your Google Analytics (or other) tracking code here. This will be added into the footer template of your theme.",
					"id" => $shortname."_google_analytics",
					"std" => "",
					"type" => "textarea");        

$options[] = array( "name" => "RSS URL",
					"desc" => "Enter your preferred RSS URL. (Feedburner or other)",
					"id" => $shortname."_feedburner_url",
					"std" => "",
					"type" => "text");				

$options[] = array( "name" => "Banner Options",
					"type" => "heading");    

$options[] = array( "name" => "Banner Color",
					"desc" => "Select your color scheme for the Banner",
					"id" => $shortname."_banner_color",
					"type" => "select",
					"options" => $banner_icons);
					
$options[] = array( "name" => "Banner Text",
					"desc" => "The text displayed on the homepage within the banner.",
					"id" => $shortname."_banner_text",
					"std" => "",
					"type" => "text");
					
$options[] = array( "name" => "Navigation Options",
					"type" => "heading");    

$options[] = array( "name" => "Header - Exclude Pages from Navigation",
					"desc" => "Enter a comma-separated list of <a href='http://support.wordpress.com/pages/8/'>ID's</a> that you'd like to exclude from the top navigation. (e.g. 12,23,27,44)",
					"id" => $shortname."_nav_exclude",
					"std" => "",
					"type" => "text");				
					
$options[] = array( "name" => "Featured Category",
					"desc" => "Enter a comma-separated list of <a href='http://support.wordpress.com/pages/8/'>ID's</a> that you'd like to include for the featured post. (e.g. 12,23,27,44)",
					"id" => $shortname."_featured_cat",
					"std" => "",
					"type" => "text");          

$options[] = array(	"name" => "Carousel Options",
					"type" => "heading");

$options[] = array( "name" => "Animation Speed",
					"desc" => "The speed of the animation scroll",
					"id" => $shortname."_carousel_animation",
					"type" => "select",
					"options" => $carousel_animation);
					
$options[] = array(	"name" => "Number of Posts",
					"desc" => "Specify the number of posts to show",
					"id" => $shortname."_carousel_num",
					"std" => "",
					"type" => "text");

$options[] = array(	"name" => "Posts to Scroll",
					"desc" => "Specify the number of posts to scroll",
					"id" => $shortname."_carousel_scroll",
					"std" => "",
					"type" => "text");
					
$options[] = array(	"name" => "Auto Scroll",
					"desc" => "Specify how many seconds to periodically autoscroll the content. If left blank then autoscrolling is turned off",
					"id" => $shortname."_carousel_auto",
					"std" => "",
					"type" => "text");
					
$options[] = array(	"name" => "Shopping Cart Settings",
					"type" => "heading");

$options[] = array(	"name" => "Shopping Cart URL",
					"desc" => "Specify the URL address of your shopping cart. (http://yoursite.com/shopping-cart)",
					"id" => $shortname."_cart_url",
					"std" => "",
					"type" => "text");

$options[] = array( "name" => "Payment Method",
					"desc" => "Specify your prefered payment method.",
					"id" => $shortname."_checkout_option",
					"type" => "select",
					"options" => $checkout_option);
					
$options[] = array(	"name" => "PayPal Email Address",
					"desc" => "Enter the PayPal email you wish to receive payments to. (Only required if PayPal Payment Method is selected)",
					"id" => $shortname."_paypal_email",
					"std" => "",
					"type" => "text");

$options[] = array( "name" => "Google Checkout ID",
					"desc" => "Enter the Google ID you wish to receive payments to. (Only required if GoogleCheckout Payment Method is selected)",
					"id" => $shortname."_google_id",
					"std" => "",
					"type" => "text");
					
$options[] = array( "name" => "Currency",
					"desc" => "Specify your prefered Currency.",
					"id" => $shortname."_currency",
					"type" => "select",
					"options" => $currency);

$options[] = array(	"name" => "Tax Rate (Optional)",
					"desc" => "Specify the Tax Rate (0.05)",
					"id" => $shortname."_tax_rate",
					"std" => "",
					"type" => "text");

$options[] = array(	"name" => "Flat Rate Shipping (Optional)",
					"desc" => "Specify the Shipping Rate (3.00)",
					"id" => $shortname."_flat_rate",
					"std" => "",
					"type" => "text");

$options[] = array(	"name" => "Percentage Shipping (Optional)",
					"desc" => "Add a shipping cost as a percentage of the total cost (0.05)",
					"id" => $shortname."_shipping_rate",
					"std" => "",
					"type" => "text");				

$options[] = array(	"name" => "Shipping Increments (Optional)",
					"desc" => "Add a shipping cost for every item in the cart (3.00)",
					"id" => $shortname."_shipping_incred",
					"std" => "",
					"type" => "text");
				
update_option('envira_template',$options);      
update_option('envira_themename',$themename);   
update_option('envira_shortname',$shortname);
update_option('envira_manual',$manualurl);

                                     
// envira Metabox Options
                    

$envira_metaboxes = array(

		"image" => array (
			"name"		=> "image",
			"default" 	=> "",
			"label" 	=> "Image",
			"type" 		=> "upload",
			"desc"      => "Enter the URL for image to be used by the Dynamic Image resizer."
		)
        
    );
    
update_option('envira_custom_template',$envira_metaboxes);      

/*
function envira_update_options(){
        $options = get_option('envira_template',$options);  
        foreach ($options as $option){
            update_option($option['id'],$option['std']);
        }   
}

function envira_add_options(){
        $options = get_option('envira_template',$options);  
        foreach ($options as $option){
            update_option($option['id'],$option['std']);
        }   
}


//add_action('switch_theme', 'envira_update_options'); 
if(get_option('template') == 'enviraframework'){       
    envira_add_options();
} // end function 
*/


}

add_action('init','envira_options');  

?>