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

// Add team section
$wp_customize->add_section( 'enlightme_team_section', array(
	'title'             => esc_html__( 'Team','enlightme' ),
	'description'       => esc_html__( 'Team Section options.', 'enlightme' ),
	'panel'             => 'enlightme_front_page_panel',
) );

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

$wp_customize->add_control( new Enlightme_Switch_Control( $wp_customize, 'enlightme_theme_options[team_section_enable]', array(
	'label'             => esc_html__( 'Team Section Enable', 'enlightme' ),
	'section'           => 'enlightme_team_section',
	'on_off_label' 		=> enlightme_switch_options(),
) ) );

if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'enlightme_theme_options[team_section_enable]', array(
		'selector'            => '#team-section .tooltiptext',
		'settings'            => 'enlightme_theme_options[team_section_enable]',
    ) );
}

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

$wp_customize->add_control( 'enlightme_theme_options[team_title]', array(
	'label'           	=> esc_html__( 'Title', 'enlightme' ),
	'section'        	=> 'enlightme_team_section',
	'active_callback' 	=> 'enlightme_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( 'enlightme_theme_options[team_title]', array(
		'selector'            => '#team-section h2.section-title',
		'settings'            => 'enlightme_theme_options[team_title]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'enlightme_team_title_partial',
    ) );
}

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

$wp_customize->add_control( 'enlightme_theme_options[team_sub_title]', array(
	'label'           	=> esc_html__( 'Sub Title', 'enlightme' ),
	'section'        	=> 'enlightme_team_section',
	'active_callback' 	=> 'enlightme_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( 'enlightme_theme_options[team_sub_title]', array(
		'selector'            => '#team-section p.section-subtitle',
		'settings'            => 'enlightme_theme_options[team_sub_title]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'enlightme_team_sub_title_partial',
    ) );
}

// team sub title setting and control
$wp_customize->add_setting( 'enlightme_theme_options[team_button]', array(
	'sanitize_callback' => 'sanitize_text_field',
	'default'			=> $options['team_button'],
) );

$wp_customize->add_control( 'enlightme_theme_options[team_button]', array(
	'label'           	=> esc_html__( 'Button Label', 'enlightme' ),
	'section'        	=> 'enlightme_team_section',
	'active_callback' 	=> 'enlightme_is_team_section_enable',
	'type'				=> 'text',
) );

// team content type control and setting
$wp_customize->add_setting( 'enlightme_theme_options[team_content_type]', array(
	'default'          	=> $options['team_content_type'],
	'sanitize_callback' => 'enlightme_sanitize_select',
) );

$wp_customize->add_control( 'enlightme_theme_options[team_content_type]', array(
	'label'             => esc_html__( 'Content Type', 'enlightme' ),
	'section'           => 'enlightme_team_section',
	'type'				=> 'select',
	'active_callback' 	=> 'enlightme_is_team_section_enable',
	'choices'			=> enlightme_popular_team_content_type(),
) );

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

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

	$wp_customize->add_control( new Enlightme_Dropdown_Chooser( $wp_customize, 'enlightme_theme_options[team_content_page_' . $i . ']', array(
		'label'             => sprintf( esc_html__( 'Select Page %d', 'enlightme' ), $i ),
		'section'           => 'enlightme_team_section',
		'choices'			=> enlightme_page_choices(),
		'active_callback'	=> 'enlightme_is_team_section_content_page_enable',
	) ) );
	if ( class_exists( 'TP_Education' ) ) {
		// team pages drop down chooser control and setting
		$wp_customize->add_setting( 'enlightme_theme_options[team_content_team_' . $i . ']', array(
			'sanitize_callback' => 'enlightme_sanitize_page',
		) );

		$wp_customize->add_control( new Enlightme_Dropdown_Chooser( $wp_customize, 'enlightme_theme_options[team_content_team_' . $i . ']', array(
			'label'             => sprintf( esc_html__( 'Select Teacher %d', 'enlightme' ), $i ),
			'section'           => 'enlightme_team_section',
			'choices'			=> enlightme_team_choices(),
			'active_callback'	=> 'enlightme_is_team_section_content_team_enable',
		) ) );
	}

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

	$wp_customize->add_control( 'enlightme_theme_options[team_position_' . $i . ']', array(
		'label'             => sprintf( esc_html__( 'Position %d', 'enlightme' ), $i ),
		'section'           => 'enlightme_team_section',
		'active_callback'	=> 'enlightme_is_team_section_content_position_social_enable',
	) );

	// team social
	$wp_customize->add_setting( 'enlightme_theme_options[team_social_' . $i. ']', array(
		'sanitize_callback' => 'esc_url_raw',
	) );

	$wp_customize->add_control( new Enlightme_Multi_Input_Custom_Control( $wp_customize, 'enlightme_theme_options[team_social_' . $i. ']', array(
		'label'             => esc_html__( 'Social ', 'enlightme' ),
		'button_text'       => esc_html__( 'Add social.', 'enlightme' ),
		'section'           => 'enlightme_team_section',
		'active_callback' 	=> 'enlightme_is_team_section_content_position_social_enable',
	) ) );

// team hr setting and control
	$wp_customize->add_setting( 'enlightme_theme_options[team_hr_'. $i .']', array(
		'sanitize_callback' => 'sanitize_text_field'
	) );

	$wp_customize->add_control( new Enlightme_Customize_Horizontal_Line( $wp_customize, 'enlightme_theme_options[team_hr_'. $i .']',
		array(
			'section'         => 'enlightme_team_section',
			'active_callback' => 'enlightme_is_team_section_enable',
			'type'			  => 'hr'
	) ) );

endfor;