<?php
/**
 * Team Section options
 *
 * @package Theme Palace
 * @subpackage Kompany
 * @since Kompany 1.0.0
 */

// Add Team section
$wp_customize->add_section( 'kompany_team_section', array(
	'title'             => esc_html__( 'Teams','kompany' ),
	'description'       => esc_html__( 'Teams Section options.', 'kompany' ),
	'panel'             => 'kompany_front_page_panel',
) );

// Team content enable control and setting
$wp_customize->add_setting( 'kompany_theme_options[team_section_enable]', array(
	'default'			=> 	$options['team_section_enable'],
	'sanitize_callback' => 'kompany_sanitize_switch_control',
) );

$wp_customize->add_control( new Kompany_Switch_Control( $wp_customize, 'kompany_theme_options[team_section_enable]', array(
	'label'             => esc_html__( 'Team Section Enable', 'kompany' ),
	'section'           => 'kompany_team_section',
	'on_off_label' 		=> kompany_switch_options(),
) ) );

// team title setting and control
$wp_customize->add_setting( 'kompany_theme_options[team_title]', array(
	'sanitize_callback' => 'sanitize_text_field',
	'default'			=> $options['team_title'],
	'transport'			=> 'postMessage',
) );

$wp_customize->add_control( 'kompany_theme_options[team_title]', array(
	'label'           	=> esc_html__( 'Title', 'kompany' ),
	'section'        	=> 'kompany_team_section',
	'active_callback' 	=> 'kompany_is_team_section_enable',
	'type'				=> 'text',
) );

// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'kompany_theme_options[team_title]', array(
		'selector'            => '#kompany_team_section h2.section-title',
		'settings'            => 'kompany_theme_options[team_title]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'kompany_team_title_partial',
    ) );
}
// team sub_title setting and control
$wp_customize->add_setting( 'kompany_theme_options[team_sub_title]', array(
	'sanitize_callback' => 'wp_kses_post',
	'default'			=> $options['team_sub_title'],
	'transport'			=> 'postMessage',
) );

$wp_customize->add_control( 'kompany_theme_options[team_sub_title]', array(
	'label'           	=> esc_html__( 'Title', 'kompany' ),
	'section'        	=> 'kompany_team_section',
	'active_callback' 	=> 'kompany_is_team_section_enable',
	'type'				=> 'textarea',
) );

// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'kompany_theme_options[team_sub_title]', array(
		'selector'            => '#kompany_team_section div.section-content p',
		'settings'            => 'kompany_theme_options[team_sub_title]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'kompany_team_sub_title_partial',
    ) );
}

// team title setting and control
	$wp_customize->add_setting( 'kompany_theme_options[team_btn]', array(
		'sanitize_callback' => 'sanitize_text_field',
		'default'			=> $options['team_btn'],
		'transport'			=> 'postMessage',
		) );

	$wp_customize->add_control( 'kompany_theme_options[team_btn]', array(
		'label'             => esc_html__( 'Button Label', 'kompany' ),
		'section'        	=> 'kompany_team_section',
		'active_callback' 	=> 'kompany_is_team_section_enable',
		'type'				=> 'text',
		) );

	// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'kompany_theme_options[team_btn]', array(
		'selector'            => '#kompany_team_section .read-more a.btn',
		'settings'            => 'kompany_theme_options[team_btn]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'kompany_team_btn_partial',
    ) );
}

	// team title setting and control
	$wp_customize->add_setting( 'kompany_theme_options[team_btn_url]', array(
		'sanitize_callback' => 'esc_url_raw',
		) );

	$wp_customize->add_control( 'kompany_theme_options[team_btn_url]', array(
		'label'             => esc_html__( 'Button Link', 'kompany' ),
		'section'        	=> 'kompany_team_section',
		'active_callback' 	=> 'kompany_is_team_section_enable',
		'type'				=> 'url',
		) );

for ( $i = 1; $i <= 3; $i++ ) :

	// team pages drop down chooser control and setting
	$wp_customize->add_setting( 'kompany_theme_options[team_content_page_' . $i . ']', array(
		'sanitize_callback' => 'kompany_sanitize_page',
	) );

	$wp_customize->add_control( new Kompany_Dropdown_Chooser( $wp_customize, 'kompany_theme_options[team_content_page_' . $i . ']', array(
		'label'             => sprintf( esc_html__( 'Select Page %d', 'kompany' ), $i ),
		'section'           => 'kompany_team_section',
		'choices'			=> kompany_page_choices(),
		'active_callback'	=> 'kompany_is_team_section_enable',
	) ) );

	// team custom content
	$wp_customize->add_setting( 'kompany_theme_options[team_position_' . $i . ']', array(
		'sanitize_callback' => 'wp_kses_post',
	) );

	$wp_customize->add_control( 'kompany_theme_options[team_position_' . $i . ']', array(
		'label'             => sprintf( esc_html__( 'Position %d', 'kompany' ), $i ),
		'section'           => 'kompany_team_section',
		'active_callback'	=> 'kompany_is_team_section_enable',
	) );

endfor;