<?php

/*	##################################
	TS ADMIN THEME SETTINGS
	################################## */

require_once( TEMPLATEPATH . '/lib/admin/theme-admin.php');

add_action( 'admin_init', 'register_ts_options' );

function register_ts_options() {
	register_setting( 'ts-options-group', 'ts_options' );
}

function ts_settings_page() {

	global $ts_options;
	
/*	##################################
	TS ADMIN THEME OPTIONS
	################################## */
	
?>
<div class="wrap">

	<div id="ts-wrap">
		
		<div id="ts-options-header">
		
			<a href="http://themeshift.com" target="_blank"><img src="<?php echo TS_ADMIN . 'img/logo-options.png'; ?>" alt="ThemeShift" width="300" height="30" /></a>
			
			<h2><?php echo TS_THEME; ?> <small><?php echo TS_VERSION; ?></small></h2>
		
		</div>
		
		<div id="ts-options-subheader" class="clearfix">
		
			<ul>
				<li><a class="ts-options-info" href="http://themeshift.com/<?php echo TS_DOMAIN; ?>" target="_blank"><?php _e('Theme Page', TS_DOMAIN); ?></a></li>
				<li><a class="ts-options-help" href="http://themeshift.com/<?php echo TS_DOMAIN; ?>/help" target="_blank"><?php _e('Help Center', TS_DOMAIN); ?></a></li>
				<li><a class="ts-options-forums" href="http://themeshift.com/support" target="_blank"><?php _e('Support Forum', TS_DOMAIN); ?></a></li>
			</ul>
			
			<?php if($_REQUEST['updated'] || $_REQUEST['reset']) echo '<div id="ts-message">'.TS_THEME.' '.__('Settings updated', TS_DOMAIN).'</div>'; ?>
		
		</div>
		
		<form id="ts-form" method="post" action="options.php">
		
		    <?php settings_fields( 'ts-options-group' ); ?>
		    <?php $ts_options = get_option('ts_options'); ?>
		    
		    <div id="ts-options-wrap">
		    
		    	<div id="ts-1" class="ts-section ts-toggle">
		    		<div class="ts-section-inner">	
		    		
		    		<div class="ts-submit"><input type="submit" class="button" value="<?php _e('Save Changes', TS_DOMAIN); ?>" /></div>
		    	
		    		<h3 class="ts-section-logo"><span><?php _e('General', TS_DOMAIN); ?></span></h3>
		    		
		    		<div class="ts-totoggle clear">
		    		
		    			<div class="ts-option clearfix">
		    			
		    				<div class="ts-option-left">
		    				
		    					<h4><?php _e('Logo', TS_DOMAIN); ?>:</h4>
		    				
		    				</div>
		    				
		    				<div class="ts-option-right">
		    				
		    					<?php $logo = $ts_options['ts_logo'] ? $ts_options['ts_logo'] : get_bloginfo('template_url').'/img/logo.png'; ?>
								<p class="ts-bg-logo-img"><img id="ts-logo-img" src="<?php echo $logo; ?>" /></p>
                
                    			<p><input name="ts_options[ts_logo]" id="ts-logo" class="ts-text ts-upload" type="text" value="<?php if ($ts_options['ts_logo']) { echo $ts_options['ts_logo']; } else { echo $logo; } ?>" /><input id="ts-upload-button" type="button" class="button" value="<?php _e('Upload Image', TS_DOMAIN); ?>" /></p>
		    			
		    					<p class="ts-description"><?php _e('Please enter an URL or upload your custom logo.', TS_DOMAIN); ?></p>
		    			
		    				</div>
		    			
		    			</div><!-- end ts-option -->
		    			
		    			<div class="ts-option ts-option-alt clearfix">
		    			
		    				<div class="ts-option-left">
		    				
		    					<h4><?php _e('Color Scheme', TS_DOMAIN); ?>:</h4>
		    				
		    				</div>
		    				
		    				<div class="ts-option-right">
		    		
		    					<p>
		    						<?php $ts_color = $ts_options['ts_color'] ? $ts_options['ts_color'] : 'red'; ?>
		    						<select name="ts_options[ts_color]" id="ts-color" class="ts-select">
										<option<?php if($ts_options['ts_color']=='red') echo ' selected="selected"'; ?> value="red">Red</option>
										<option<?php if($ts_options['ts_color']=='blue') echo ' selected="selected"'; ?> value="blue">Blue</option>
										<option<?php if($ts_options['ts_color']=='green') echo ' selected="selected"'; ?> value="green">Green</option>
										<option<?php if($ts_options['ts_color']=='pink') echo ' selected="selected"'; ?> value="pink">Pink</option>
										<option<?php if($ts_options['ts_color']=='grey') echo ' selected="selected"'; ?> value="grey">Grey</option>
									</select>
									
								</p>
		    			
		    					<p class="ts-description"><?php _e('Please select your preferred color scheme.', TS_DOMAIN); ?></p>
		    			
		    				</div>
		    			
		    			</div><!-- end ts-option -->
		    			
		    			<div class="ts-option clearfix">
		    			
		    				<div class="ts-option-left">
		    				
		    					<h4><?php _e('RSS URL', TS_DOMAIN); ?>:</h4>
		    				
		    				</div>
		    				
		    				<div class="ts-option-right">
                
                    			<p><input name="ts_options[ts_rss]" id="ts-rss" class="ts-text" type="text" value="<?php echo $ts_options['ts_rss']; ?>" /></p>
		    			
		    					<p class="ts-description"><?php _e('Please enter your custom RSS URL (e.g. Feedburner).', TS_DOMAIN); ?></p>
		    			
		    				</div>
		    			
		    			</div><!-- end ts-option -->
		    			
		    			<div class="ts-option ts-option-alt clearfix">
		    			
		    				<div class="ts-option-left">
		    				
		    					<h4><?php _e('Custom CSS', TS_DOMAIN); ?>:</h4>
		    				
		    				</div>
		    				
		    				<div class="ts-option-right">
		    		
		    					<p><textarea name="ts_options[ts_css]" class="ts-text ts-textarea"><?php echo $ts_options['ts_css']; ?></textarea></p>
		    			
		    					<p class="ts-description"><?php _e('Easily add some custom css to the head of your theme.', TS_DOMAIN); ?></p>
		    			
		    				</div>
		    			
		    			</div><!-- end ts-option -->
		    			
		    			<div class="ts-option ts-option-last clearfix">		    			
		    			
		    				<div class="ts-option-left">
		    				
		    					<h4><?php _e('Tracking Code', TS_DOMAIN); ?>:</h4>
		    				
		    				</div>
		    				
		    				<div class="ts-option-right">
		    		
		    					<p><textarea name="ts_options[ts_tracking]" class="ts-text ts-textarea"><?php echo $ts_options['ts_tracking']; ?></textarea></p>
		    			
		    					<p class="ts-description"><?php _e('Insert your tracking code here (e.g. Google Analytics). This code will be added to the footer of the theme.', TS_DOMAIN); ?></p>
		    			
		    				</div>		    				
		    			
		    			</div><!-- end ts-option -->
		    		
		    		</div>
		    	
		    		</div><!-- end ts-section-inner -->
		    	</div><!-- end ts-section -->
		    	
		    	<div id="ts-2" class="ts-section ts-toggle">
		    		<div class="ts-section-inner">   		
		    		
		    		<span class="ts-submit"><input type="submit" class="button" value="<?php _e('Save Changes', TS_DOMAIN); ?>" /></span>
		    	
		    		<h3 class="ts-section-logo"><span><?php _e('Menu', TS_DOMAIN); ?></span></h3>
		    		
		    		<div class="ts-totoggle">
		    			
		    			<div class="ts-option clearfix">
		    			
		    				<div class="ts-option-left">
		    				
		    					<h4><?php _e('Home', TS_DOMAIN); ?>:</h4>
		    				
		    				</div>
		    				
		    				<div class="ts-option-right">
		    					
		    					<p><input name="ts_options[ts_ex_home]" type="checkbox" value="1" <?php checked('1', $ts_options['ts_ex_home']); ?> /> <?php _e('Exclude home link from menu?', TS_DOMAIN); ?></p>
		    			
		    					<p class="ts-description"><?php _e('Exclude the home link from the menu. The logo will also be linked to the home page.', TS_DOMAIN); ?></p>
		    			
		    				</div>
		    			
		    			</div><!-- end ts-option -->
		    		
		    			<div class="ts-option ts-option-alt clearfix">
		    			
		    				<div class="ts-option-left">
		    				
		    					<h4><?php _e('Categories'); ?>:</h4>
		    				
		    				</div>
		    				
		    				<div class="ts-option-right">
		    				
		    					<p><input name="ts_options[ts_ex_cats]" id="ts-ex-cats" class="ts-text" type="text" value="<?php echo $ts_options['ts_ex_cats']; ?>" /></p>
		    			
		    					<p class="ts-description"><?php _e('Please enter the category IDs you want to exlcude from the menu (e.g. 2,5,9).', TS_DOMAIN); ?></p>
		    			
		    				</div>
		    			
		    			</div><!-- end ts-option -->
		    			
		    			<div class="ts-option clearfix">
		    			
		    				<div class="ts-option-left">
		    				
		    					<h4><?php _e('Pages'); ?>:</h4>
		    				
		    				</div>
		    				
		    				<div class="ts-option-right">
		    					
		    					<p><input name="ts_options[ts_ex_pages]" id="ts-ex-pages" class="ts-text" type="text" value="<?php echo $ts_options['ts_ex_pages']; ?>" /></p>
		    			
		    					<p class="ts-description"><?php _e('Please enter the page IDs you want to exlcude from the menu (e.g. 3,65,71).', TS_DOMAIN); ?></p>
		    			
		    				</div>
		    			
		    			</div><!-- end ts-option -->
		    			
		    			<div class="ts-option ts-option-alt ts-option-last clearfix">
		    			
		    				<p class="ts-description"><?php _e('Please notice that the above options will only work if you do not use WordPress custom menus.', TS_DOMAIN); ?></p>
		    			
		    			</div><!-- end ts-option -->
		    		
		    		</div>
		    	
		    		</div><!-- end ts-section-inner -->
		    	</div><!-- end ts-section -->
		    	
		    	<div id="ts-3" class="ts-section ts-toggle">
		    		<div class="ts-section-inner">   		
		    		
		    		<span class="ts-submit"><input type="submit" class="button" value="<?php _e('Save Changes', TS_DOMAIN); ?>" /></span>
		    	
		    		<h3 class="ts-section-logo"><span><?php _e('Home - Subheader', TS_DOMAIN); ?></span></h3>
		    		
		    		<div class="ts-totoggle">
		    		
		    			<div class="ts-option clearfix">
		    			
		    				<div class="ts-option-left">
		    				
		    					<h4><?php _e('Display', TS_DOMAIN); ?>:</h4>
		    				
		    				</div>
		    				
		    				<div class="ts-option-right">
		    		
		    					<p>
		    					
		    						<p><input name="ts_options[ts_display_dsp]" type="checkbox" value="1" <?php checked('1',$ts_options['ts_display_dsp']); ?> /> <?php _e('Hide subheader display?', TS_DOMAIN); ?></p>
		    						
		    						<p class="ts-description"><?php _e('Please tick the box to completely hide the subheader.', TS_DOMAIN); ?></p>
		    						
		    						<p><input name="ts_options[ts_display_tmb]" type="checkbox" value="1" <?php checked('1',$ts_options['ts_display_tmb']); ?> /> <?php _e('Remove image resize?', TS_DOMAIN); ?></p>
		    						
		    						<p class="ts-description"><?php _e('Please tick the box to remove the image resizer script <small>(images are displayed in 300x220px)</small>.', TS_DOMAIN); ?></p>
									
								</p>
		    			
		    				</div>
		    			
		    			</div><!-- end ts-option -->
		    			
		    			<div class="ts-option ts-option-alt clearfix">
		    			
		    				<div class="ts-option-left">
		    				
		    					<h4><?php _e('Item', TS_DOMAIN); ?> #1:</h4>
		    				
		    				</div>
		    				
		    				<div class="ts-option-right">
		    				
		    					<p><input name="ts_options[ts_display_1_img]" class="ts-text" type="text" value="<?php echo $ts_options['ts_display_1_img']; ?>" /></p>
		    			
		    					<p class="ts-description"><?php _e('Please enter display image URL. Image will be resized to 300x220px.', TS_DOMAIN); ?></p>
		    					
		    					<p>
		    					
		    						<select name="ts_options[ts_display_1_url]" class="ts-select">
		    							<option value=""><?php _e('Please select a page', TS_DOMAIN); ?>...</option>
										<?php $pages = get_pages(); foreach ($pages as $page) : ?>
		                        		 	<option value="<?php echo $page->ID; ?>" <?php selected($page->ID, $ts_options['ts_display_1_url']); ?>><?php echo $page->post_title; ?></option>
		                        		 <?php endforeach; ?>
									</select>
									
								</p>
								
								<p class="ts-description"><?php _e('Please select display link destination.', TS_DOMAIN); ?></p>
								
								<p><input name="ts_options[ts_display_1_text]" class="ts-text" type="text" value="<?php echo $ts_options['ts_display_1_text']; ?>" /></p>
		    			
		    					<p class="ts-description"><?php _e('Please enter a custom title <small>(overwrites the title of the page selected above)</small>.', TS_DOMAIN); ?></p>
								
								<p><input name="ts_options[ts_display_1_link]" class="ts-text" type="text" value="<?php echo $ts_options['ts_display_1_link']; ?>" /></p>
		    			
		    					<p class="ts-description"><?php _e('Please enter a custom link URL <small>(overwrites the page selected above)</small>.', TS_DOMAIN); ?></p>
		    			
		    				</div>
		    			
		    			</div><!-- end ts-option -->
		    			
		    			<div class="ts-option clearfix">
		    			
		    				<div class="ts-option-left">
		    				
		    					<h4><?php _e('Item', TS_DOMAIN); ?> #2:</h4>
		    				
		    				</div>
		    				
		    				<div class="ts-option-right">

		    					<p><input name="ts_options[ts_display_2_img]" class="ts-text" type="text" value="<?php echo $ts_options['ts_display_2_img']; ?>" /></p>
		    			
		    					<p class="ts-description"><?php _e('Please enter display image URL. Image will be resized to 300x220px.', TS_DOMAIN); ?></p>
		    					
		    					<p>
		    					
		    						<select name="ts_options[ts_display_2_url]" class="ts-select">
		    							<option value=""><?php _e('Please select a page', TS_DOMAIN); ?>...</option>
										<?php $pages = get_pages(); foreach ($pages as $page) : ?>
		                        		 	<option value="<?php echo $page->ID; ?>" <?php selected($page->ID, $ts_options['ts_display_2_url']); ?>><?php echo $page->post_title; ?></option>
		                        		 <?php endforeach; ?>
									</select>
									
								</p>
								
								<p class="ts-description"><?php _e('Please select display link destination.', TS_DOMAIN); ?></p>
								
								<p><input name="ts_options[ts_display_2_text]" class="ts-text" type="text" value="<?php echo $ts_options['ts_display_2_text']; ?>" /></p>
		    			
		    					<p class="ts-description"><?php _e('Please enter a custom title <small>(overwrites the title of the page selected above)</small>.', TS_DOMAIN); ?></p>
								
								<p><input name="ts_options[ts_display_2_link]" class="ts-text" type="text" value="<?php echo $ts_options['ts_display_2_link']; ?>" /></p>
		    			
		    					<p class="ts-description"><?php _e('Please enter a custom link URL <small>(overwrites the page selected above)</small>.', TS_DOMAIN); ?></p>
		    			
		    				</div>
		    			
		    			</div><!-- end ts-option -->
		    			
		    			<div class="ts-option ts-option-alt ts-option-last clearfix">
		    			
		    				<div class="ts-option-left">
		    				
		    					<h4><?php _e('Item', TS_DOMAIN); ?> #3:</h4>
		    				
		    				</div>
		    				
		    				<div class="ts-option-right">

		    					<p><input name="ts_options[ts_display_3_img]" class="ts-text" type="text" value="<?php echo $ts_options['ts_display_3_img']; ?>" /></p>
		    			
		    					<p class="ts-description"><?php _e('Please enter display image URL. Image will be resized to 300x220px.', TS_DOMAIN); ?></p>
		    					
		    					<p>
		    					
		    						<select name="ts_options[ts_display_3_url]" class="ts-select">
		    							<option value=""><?php _e('Please select a page', TS_DOMAIN); ?>...</option>
										<?php $pages = get_pages(); foreach ($pages as $page) : ?>
		                        		 	<option value="<?php echo $page->ID; ?>" <?php selected($page->ID, $ts_options['ts_display_3_url']); ?>><?php echo $page->post_title; ?></option>
		                        		 <?php endforeach; ?>
									</select>
									
								</p>
								
								<p class="ts-description"><?php _e('Please select display link destination.', TS_DOMAIN); ?></p>
								
								<p><input name="ts_options[ts_display_3_text]" class="ts-text" type="text" value="<?php echo $ts_options['ts_display_3_text']; ?>" /></p>
		    			
		    					<p class="ts-description"><?php _e('Please enter a custom title <small>(overwrites the title of the page selected above)</small>.', TS_DOMAIN); ?></p>
								
								<p><input name="ts_options[ts_display_3_link]" class="ts-text" type="text" value="<?php echo $ts_options['ts_display_3_link']; ?>" /></p>
		    			
		    					<p class="ts-description"><?php _e('Please enter a custom link URL <small>(overwrites the page selected above)</small>.', TS_DOMAIN); ?></p>
		    			
		    				</div>
		    			
		    			</div><!-- end ts-option -->
		    		
		    		</div>
		    	
		    		</div><!-- end ts-section-inner -->
		    	</div><!-- end ts-section -->
		    	
		    	<div id="ts-4" class="ts-section ts-toggle">
		    		<div class="ts-section-inner">
		    		
		    		<span class="ts-submit"><input type="submit" class="button" value="<?php _e('Save Changes', TS_DOMAIN); ?>" /></span>
		    	
		    		<h3 class="ts-section-logo"><span><?php _e('Home - Content', TS_DOMAIN); ?></span></h3>
		    		
		    		<div class="ts-totoggle">
		    		
		    			<div class="ts-option clearfix">
		    			
		    				<div class="ts-option-left">
		    				
		    					<h4><?php _e('Welcome', TS_DOMAIN); ?>:</h4>
		    				
		    				</div>
		    				
		    				<div class="ts-option-right">
		    				
		    					<p><input name="ts_options[ts_welcome_title]" id="ts-about-title" class="ts-text" type="text" value="<?php echo $ts_options['ts_welcome_title']; ?>" /></p>
		    			
		    					<p class="ts-description"><?php _e('Please enter a title for the welcome text on the home page.', TS_DOMAIN); ?></p>

		    					<p><textarea name="ts_options[ts_welcome_text]" class="ts-text ts-textarea"><?php echo $ts_options['ts_welcome_text']; ?></textarea></p>
		    			
		    					<p class="ts-description"><?php _e('Please enter the welcome text for the home page.', TS_DOMAIN); ?></p>
		    					
		    					<p>
		    					
		    						<select name="ts_options[ts_welcome_url]" class="ts-select">
		    							<option value=""><?php _e('Please select a page', TS_DOMAIN); ?>...</option>
										<?php $pages = get_pages(); foreach ($pages as $page) : ?>
		                        		 	<option value="<?php echo $page->ID; ?>" <?php selected($page->ID, $ts_options['ts_welcome_url']); ?>><?php echo $page->post_title; ?></option>
		                        		 <?php endforeach; ?>
									</select>
									
								</p>
								
								<p class="ts-description"><?php _e('Please select a page (e.g. <em>About Us</em>) the button below the text links to (optional).', TS_DOMAIN); ?></p>
		    			
		    				</div>
		    			
		    			</div><!-- end ts-option -->
		    			
		    			<div class="ts-option ts-option-alt ts-option-last clearfix">
		    			
		    				<div class="ts-option-left">
		    				
		    					<h4><?php _e('Posts or Pages', TS_DOMAIN); ?>:</h4>
		    				
		    				</div>
		    				
		    				<div class="ts-option-right">
		    				
		    					<p>
		    					
		    						<select name="ts_options[ts_home_con]" class="ts-select">
		    							<option<?php if($ts_options['ts_home_con']=='Posts') echo ' selected="selected"'; ?> value="Posts"><?php _e('Posts', TS_DOMAIN); ?></option>
										<option<?php if($ts_options['ts_home_con']=='Pages') echo ' selected="selected"'; ?> value="Pages"><?php _e('Pages', TS_DOMAIN); ?></option>
									</select>
									
								</p>
		    			
		    					<p class="ts-description"><?php _e('Please select wheter you want to display posts or pages on the home page. Create custom field named <em>page</em> with value <code>home</code> to add pages to home page.', TS_DOMAIN); ?></p>
		    					
		    					<p>
		    					
		    						<select name="ts_options[ts_featured_cat]" class="ts-select">
		    							<option value=""><?php _e('Please select a category', TS_DOMAIN); ?>...</option>
										<?php $categories = get_categories('hide_empty=0'); foreach ($categories as $category) : ?>
		                        		 	<option value="<?php echo $category->name; ?>" <?php selected($category->name, $ts_options['ts_featured_cat']); ?>><?php echo $category->name; ?></option>
		                        		 <?php endforeach; ?>
									</select>
									
								</p>
		    			
		    					<p class="ts-description"><?php _e('<strong>If Posts:</strong> Please select a featured category for the home page (if empty -> most recent).', TS_DOMAIN); ?></p>
		    					
		    					<p>
		    					
		    						<select name="ts_options[ts_featured_items]" id="ts-buttons" class="ts-select">
										<option<?php if($ts_options['ts_featured_items']=='2') echo ' selected="selected"'; ?>>2</option>
										<option<?php if($ts_options['ts_featured_items']=='4') echo ' selected="selected"'; ?>>4</option>
										<option<?php if($ts_options['ts_featured_items']=='6') echo ' selected="selected"'; ?>>6</option>
										<option<?php if($ts_options['ts_featured_items']=='8') echo ' selected="selected"'; ?>>8</option>
										<option<?php if($ts_options['ts_featured_items']=='10') echo ' selected="selected"'; ?>>10</option>
									</select>
									
								</p>
		    			
		    					<p class="ts-description"><?php _e('Please choose how many items you want to feature on the home page (if no featured category -> <code>Settings > Reading</code>).', TS_DOMAIN); ?></p>
		    			
		    				</div>
		    			
		    			</div><!-- end ts-option -->
		    		
		    		</div>
		    	
		    		</div><!-- end ts-section-inner -->
		    	</div><!-- end ts-section -->
		    	
		    	<div id="ts-5" class="ts-section ts-toggle">
		    		<div class="ts-section-inner">
		    		
		    		<span class="ts-submit"><input type="submit" class="button" value="<?php _e('Save Changes', TS_DOMAIN); ?>" /></span>
		    	
		    		<h3 class="ts-section-logo"><span><?php _e('Single', TS_DOMAIN); ?></span></h3>
		    		
		    		<div class="ts-totoggle">
		    		
		    			<div class="ts-option clearfix">
		    			
		    				<div class="ts-option-left">
		    				
		    					<h4><?php _e('Post Comments', TS_DOMAIN); ?>:</h4>
		    				
		    				</div>
		    				
		    				<div class="ts-option-right">
		    				
		    					<p><input name="ts_options[ts_comments_posts]" type="checkbox" value="1" <?php checked('1', $ts_options['ts_comments_posts']); ?> /> <?php _e('Hide comments template in posts?', TS_DOMAIN); ?></p>
		    			
		    				</div>
		    			
		    			</div><!-- end ts-option -->
		    			
		    			<div class="ts-option ts-option-alt ts-option-last clearfix">
		    			
		    				<div class="ts-option-left">
		    				
		    					<h4><?php _e('Page Comments', TS_DOMAIN); ?>:</h4>
		    				
		    				</div>
		    				
		    				<div class="ts-option-right">
		    				
		    					<p><input name="ts_options[ts_comments_pages]" type="checkbox" value="1" <?php checked('1', $ts_options['ts_comments_pages']); ?> /> <?php _e('Hide comments template on pages?', TS_DOMAIN); ?></p>
		    			
		    				</div>
		    			
		    			</div><!-- end ts-option -->
		    		
		    		</div>
		    	
		    		</div><!-- end ts-section-inner -->
		    	</div><!-- end ts-section -->
		    
		    </div>
		
		</form>
	
	</div><!-- end ts-wrap -->
	
</div>
<?php } 

require_once( TEMPLATEPATH . '/lib/admin/theme-pages.php');

?>