<?php
/**
 * Choose Us options.
 *
 * @package Super Business
 */

$default = super_business_get_default_theme_options();

// Choose Us Section
$wp_customize->add_section( 'section_choose_us',
	array(
	'title'      		=> __( 'Choose Us Section', 'super-business' ),
	'priority'   		=> 100,
	'capability' 		=> 'edit_theme_options',
	'panel'      		=> 'home_page_panel',
	)
);

// Enable Choose Us Section
$wp_customize->add_setting('theme_options[enable_choose_us_section]', 
	array(
	'default' 			=> $default['enable_choose_us_section'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',
	'sanitize_callback' => 'super_business_sanitize_checkbox'
	)
);

$wp_customize->add_control('theme_options[enable_choose_us_section]', 
	array(		
	'label' 			=> __('Enable Section', 'super-business'),
	'description' => __('Go to Customize - Homepage Settings. Select A static page. Set Homepage as Home and Posts page as Blog to show this section.', 'super-business'),
	'section' 			=> 'section_choose_us',
	'settings'  		=> 'theme_options[enable_choose_us_section]',
	'type' 				=> 'checkbox',	
	)
);

// Image
$wp_customize->add_setting('theme_options[choose_us_image]', 
	array(
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',	
	'sanitize_callback' => 'super_business_sanitize_image'
	)
);

$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize,
	'theme_options[choose_us_image]', 
	array(
	'label' 			=> __('Image', 'super-business'),
	'section'     		=> 'section_choose_us',   
	'settings'    		=> 'theme_options[choose_us_image]',		
	'active_callback' 	=> 'super_business_choose_us_active',
	'type'        		=> 'image',
	)
	)
);

// Subtitle
$wp_customize->add_setting('theme_options[choose_us_section_subtitle]', 
	array(
	'default'           => $default['choose_us_section_subtitle'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',	
	'sanitize_callback' => 'sanitize_text_field'
	)
);

$wp_customize->add_control('theme_options[choose_us_section_subtitle]', 
	array(
	'label' 	  		=> __('Subtitle', 'super-business'),
	'section'     		=> 'section_choose_us',   
	'settings'    		=> 'theme_options[choose_us_section_subtitle]',		
	'active_callback' 	=> 'super_business_choose_us_active',		
	'type'        		=> 'text'
	)
);

// Title
$wp_customize->add_setting('theme_options[choose_us_section_title]', 
	array(
	'default'           => $default['choose_us_section_title'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',	
	'sanitize_callback' => 'sanitize_text_field'
	)
);

$wp_customize->add_control('theme_options[choose_us_section_title]', 
	array(
	'label' 			=> __('Title', 'super-business'),
	'section'       	=> 'section_choose_us',   
	'settings'      	=> 'theme_options[choose_us_section_title]',		
	'active_callback' 	=> 'super_business_choose_us_active',		
	'type'        		=> 'text'
	)
);

// Number of items
$wp_customize->add_setting('theme_options[number_of_choose_us_items]', 
	array(
	'default' 			=> $default['number_of_choose_us_items'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',	
	'sanitize_callback' => 'super_business_sanitize_number_range'
	)
);

$wp_customize->add_control('theme_options[number_of_choose_us_items]', 
	array(
	'label'       => __('Number Of Items', 'super-business'),
	'description' => __('Save & Refresh the customizer to see its effect. Maximum is 2.', 'super-business'),
	'section'     => 'section_choose_us',   
	'settings'    => 'theme_options[number_of_choose_us_items]',		
	'type'        => 'number',
	'active_callback' => 'super_business_choose_us_active',
	'input_attrs' => array(
			'min'	=> 1,
			'max'	=> 2,
			'step'	=> 1,
		),
	)
);

$number_of_choose_us_items = super_business_get_option( 'number_of_choose_us_items' );

for( $i=1; $i<=$number_of_choose_us_items; $i++ ) {

	// Icon
	$wp_customize->add_setting('theme_options[choose_us_icon_'.$i.']', 
		array(
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',	
		'sanitize_callback' => 'sanitize_text_field'
		)
	);

	$wp_customize->add_control('theme_options[choose_us_icon_'.$i.']', 
		array(
		'label'       		=> sprintf( __('Icon #%1$s', 'super-business'), $i),
		'section'     		=> 'section_choose_us',   
		'settings'    		=> 'theme_options[choose_us_icon_'.$i.']',		
		'active_callback' 	=> 'super_business_choose_us_active',			
		'type'        		=> 'text',
		)
	);

	// Title
	$wp_customize->add_setting('theme_options[choose_us_title_'.$i.']', 
		array(
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',	
		'sanitize_callback' => 'sanitize_text_field'
		)
	);

	$wp_customize->add_control('theme_options[choose_us_title_'.$i.']', 
		array(
		'label'       		=> sprintf( __('Title #%1$s', 'super-business'), $i),
		'section'     		=> 'section_choose_us',   
		'settings'    		=> 'theme_options[choose_us_title_'.$i.']',		
		'active_callback' 	=> 'super_business_choose_us_active',		
		'type'        		=> 'text'
		)
	);

	// Content
	$wp_customize->add_setting('theme_options[choose_us_content_'.$i.']', 
		array(
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',	
		'sanitize_callback' => 'super_business_sanitize_textarea_content'
		)
	);

	$wp_customize->add_control('theme_options[choose_us_content_'.$i.']', 
		array(
		'label'       		=> sprintf( __('Content #%1$s', 'super-business'), $i),
		'section'     		=> 'section_choose_us',   
		'settings'    		=> 'theme_options[choose_us_content_'.$i.']',		
		'active_callback' 	=> 'super_business_choose_us_active',		
		'type'        		=> 'textarea'
		)
	);
}