<?php
/**
 * Team options.
 *
 * @package Party Planner Bell
 */

$default = party_planner_bell_get_default_theme_options();

// Team Section
$wp_customize->add_section( 'section_home_team',
	array(
		'title'      => __( 'Team Section', 'party-planner-bell' ),
		'capability' => 'edit_theme_options',
		'panel'      => 'home_page_panel',
		'active_callback' => 'party_planner_bell_team_design_enable',
		)
);

$wp_customize->add_setting( 'theme_options[disable_team_section]',
	array(
		'default'           => $default['disable_team_section'],
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',
		'sanitize_callback' => 'party_planner_bell_sanitize_switch_control',
	)
);
$wp_customize->add_control( new Party_Planner_Bell_Switch_Control( $wp_customize, 'theme_options[disable_team_section]',
    array(
		'label' 			=> __('Enable/Disable Team Section', 'party-planner-bell'),
		'section'    		=> 'section_home_team',
		 'settings'  		=> 'theme_options[disable_team_section]',
		'on_off_label' 		=> party_planner_bell_switch_options(),
    )
) );

$wp_customize->add_setting( 'theme_options[team_background_color]', array(
    'sanitize_callback' => 'sanitize_hex_color', // The hue is stored as a positive integer.
    'default' 			=> $default['team_background_color'],
    
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'theme_options[team_background_color]', array(
    'label'    => esc_html__( 'Background Color', 'party-planner-bell' ),
    'section'  => 'section_home_team',
    'active_callback' => 'party_planner_bell_team_active',
) ) );

//Team Section title
$wp_customize->add_setting('theme_options[team_title]', 
	array(
	'default'           => $default['team_title'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',	
	'sanitize_callback' => 'sanitize_text_field'
	)
);

$wp_customize->add_control('theme_options[team_title]', 
	array(
	'label'       => __('Section Title', 'party-planner-bell'),
	'section'     => 'section_home_team',   
	'settings'    => 'theme_options[team_title]',
	'active_callback' => 'party_planner_bell_team_active',		
	'type'        => 'text'
	)
);


//Project Section Subtitle
$wp_customize->add_setting('theme_options[team_subtitle]', 
	array(
	'default'           => $default['team_subtitle'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',	
	'sanitize_callback' => 'sanitize_textarea_field'
	)
);

$wp_customize->add_control('theme_options[team_subtitle]', 
	array(
	'label'       => __('Section Sub Title', 'party-planner-bell'),
	'section'     => 'section_home_team',   
	'settings'    => 'theme_options[team_subtitle]',
	'active_callback' => 'party_planner_bell_team_active',		
	'type'        => 'textarea'
	)
);


// Add autoplay enable setting and control.
$wp_customize->add_setting( 'theme_options[team_content_enable]', array(
	'default'           => $default['team_content_enable'],
	'sanitize_callback' => 'party_planner_bell_sanitize_checkbox',
) );

$wp_customize->add_control( 'theme_options[team_content_enable]', array(
	'label'             => esc_html__( 'Enable Team Content', 'party-planner-bell' ),
	'section'           => 'section_home_team',
	'type'              => 'checkbox',
	'active_callback' => 'party_planner_bell_team_active',
) );

$number_of_team_items = party_planner_bell_get_option( 'number_of_team_items' );

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

	// Additional Information First Post
	$wp_customize->add_setting('theme_options[team_post_'.$i.']', 
		array(
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',	
		'sanitize_callback' => 'party_planner_bell_dropdown_posts'
		)
	);
	$wp_customize->add_control( new Party_Planner_Bell_Dropdown_Chooser( $wp_customize,'theme_options[team_post_'.$i.']', 
		array(
		'label'       => sprintf( __('Select Post #%1$s', 'party-planner-bell'), $i),
		'section'     => 'section_home_team',  
		'settings'    => 'theme_options[team_post_'.$i.']',	
		'choices'			=> party_planner_bell_post_choices(),	
		'type'        => 'dropdown-posts',
		'active_callback' => 'party_planner_bell_team_active',
		)
	));

	// team title setting and control
	$wp_customize->add_setting( 'theme_options[team_custom_position_' . $i . ']', array(
		'type'              => 'theme_mod',
		'sanitize_callback' => 'sanitize_text_field',
	) );

	$wp_customize->add_control( 'theme_options[team_custom_position_' . $i . ']', array(
		'label'           	=> sprintf( __( 'Position %d', 'party-planner-bell' ), $i ),
		'section'        	=> 'section_home_team',
		'settings'    		=> 'theme_options[team_custom_position_'.$i.']',	
		'active_callback' 	=> 'party_planner_bell_team_active',
		'type'				=> 'text',
	) );
}
