<?php 

/**
 * Initialize the options before anything else. 
 */
add_action( 'admin_init', 'custom_theme_options', 1 );

/**
 * Build the custom settings & update OptionTree.
 */
function custom_theme_options() {
  /**
   * Get a copy of the saved settings array. 
   */
  $saved_settings = get_option( 'option_tree_settings', array() );
  
  /**
   * Custom settings array that will eventually be 
   * passes to the OptionTree Settings API Class.
   */
  $custom_settings = array(
    'contextual_help' => array(
      'content'       => array( 
        array(
          'id'        => 'general_help',
          'title'     => 'General',
          'content'   => '<p>Help content goes here!</p>'
        )
      ),
      'sidebar'       => '<p>Sidebar content goes here!</p>',
    ),
    
	'sections'        => array(
      
	  array(
        'id'          => 'general',
        'title'       => 'General'
      ),

	  array(
        'id'          => 'header',
        'title'       => 'Header'
      ),
	  
	  array(
        'id'          => 'footer',
        'title'       => 'Footer'
      ),
	  
	   array(
        'id'          => 'styling',
        'title'       => 'Styling'
      ),
	  
	  array(
		'id'		=> 'social_links',
		'title'		=> 'Social Links'
	  ),



  ),
	
	
    'settings'        => array(
     	
		// General: Favicon
		array(
			'id'		=> 'favicon',
			'label'		=> 'Favicon',
			'desc'		=> 'Upload a 16x16px Png/Gif image that will be your favicon',
			'type'		=> 'upload',
			'section'	=> 'general'
		),
		
	  		// Header: Custom Logo

	  array(
        'id'          => 'custom_logo',
        'label'       => 'Custom logo',
        'desc'        => 'Upload custom logo image.',
        'std'         => '',
        'type'        => 'upload',
        'section'     => 'header',
        'class'       => '',
      ),
	  		// Header: Site Description
		array(
			'id'		=> 'site_description',
			'label'		=> 'Site Description',
			'desc'		=> 'The description that appears next to your logo',
			'type'		=> 'checkbox',
			'section'	=> 'header',
			'choices'	=> array(
				array( 
					'value' => '1',
					'label' => 'Disable'
				 )
				)
			   ),
			
			// Styling: Enable
		array(
			'id'		=> 'dynamic-styles',
			'label'		=> 'Dynamic Styles',
			'desc'		=> 'Turn styling options on / off',
			'type'		=> 'checkbox',
			'section'	=> 'styling',
			'choices'	=> array(
				array( 
					'value' => '1',
					'label' => 'Enable to use the options below'
				)
			)
		),
		   
		
			// Styling: Body Background
		array(
			'id'		=> 'body_background',
			'label'		=> 'Body Background',
			'desc'		=> 'Body background<br /><i>Default: #FFFFFF</i>',
			'std'		=> '#FFFFFF',
			'type'		=> 'colorpicker',
			'section'	=> 'styling',
		),

	   
			// Styling: Header Color
		array(
			'id'		=> 'header_color',
			'label'		=> 'Header Color',
			'desc'		=> 'Header background<br /><i>Default: #FFFFFF</i>',
			'std'		=> '#FFFFFF',
			'type'		=> 'colorpicker',
			'section'	=> 'styling',
		),
		
		 // Styling: Footer Color
		array(
			'id'		=> 'footer_widget_color',
			'label'		=> 'Footer Widget Color',
			'desc'		=> 'Footer Widget background<br /><i>Default: #3b3b3b</i>',
			'std'		=> '#3b3b3b',
			'type'		=> 'colorpicker',
			'section'	=> 'styling',
		),

	   
		  // Styling: Footer Color
		array(
			'id'		=> 'footer_color',
			'label'		=> 'Footer Color',
			'desc'		=> 'Footer background<br /><i>Default: #2d2d2d</i>',
			'std'		=> '#2d2d2d',
			'type'		=> 'colorpicker',
			'section'	=> 'styling',
		),
	  
	  	// Footer: Copyright
		array(
			'id'		=> 'copyright',
			'label'		=> 'Footer Copyright',
			'desc'		=> 'Replace the footer copyright text',
			'type'		=> 'text',
			'section'	=> 'footer'
		),
		
		// Social Links : List
		array(
			'id'		=> 'social_links',
			'label'		=> 'Social Links',
			'desc'		=> 'Create and organize your social links',
			'type'		=> 'list-item',
			'section'	=> 'social_links',
			'choices'	=> array(),
			'settings'	=> array(
				array(
					'id'		=> 'social-icon',
					'label'		=> 'Icon Name',
					'desc'		=> 'Font Awesome icon names [<a href="http://fortawesome.github.io/Font-Awesome/icons/" target="_blank"><strong>View all</strong>]</a>  ',
					'std'		=> 'fa-',
					'type'		=> 'text',
					'choices'	=> array()
				),
				array(
					'id'		=> 'social-link',
					'label'		=> 'Link',
					'desc'		=> 'Enter the full url for your icon button',
					'std'		=> 'http://',
					'type'		=> 'text',
					'choices'	=> array()
				),
				array(
					'id'		=> 'social-color',
					'label'		=> 'Icon Color',
					'desc'		=> 'Set a unique color for your icon (optional)',
					'std'		=> '',
					'type'		=> 'colorpicker',
					'section'	=> 'styling'
				),
				array(
					'id'		=> 'social-target',
					'label'		=> 'Link Options',
					'desc'		=> '',
					'std'		=> '',
					'type'		=> 'checkbox',
					'choices'	=> array(
						array( 
							'value' => '_blank',
							'label' => 'Open in new window'
						)
					)
				)
			)
		),

	 )
  );
  
  
  
  
  /* settings are not the same update the DB */
  if ( $saved_settings !== $custom_settings ) {
    update_option( 'option_tree_settings', $custom_settings ); 
  }
  
}

?>