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

// Add Career section
$wp_customize->add_section( 'enlightme_pro_career_section', array(
	'title'             => esc_html__( 'Career','enlightme-pro' ),
	'description'       => esc_html__( 'Career Section options.', 'enlightme-pro' ),
	'panel'             => 'enlightme_pro_front_page_panel',
	'active_callback'   => function( $control ) {
        return (
            enlightme_pro_is_default_layout( $control )
        );
    },

) );

// Career content enable control and setting
$wp_customize->add_setting( 'enlightme_pro_theme_options[career_section_enable]', array(
	'default'			=> 	$options['career_section_enable'],
	'sanitize_callback' => 'enlightme_pro_sanitize_switch_control',
) );

$wp_customize->add_control( new Enlightme_Pro_Switch_Control( $wp_customize, 'enlightme_pro_theme_options[career_section_enable]', array(
	'label'             => esc_html__( 'Career Section Enable', 'enlightme-pro' ),
	'section'           => 'enlightme_pro_career_section',
	'on_off_label' 		=> enlightme_pro_switch_options(),
) ) );

if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'enlightme_pro_theme_options[career_section_enable]', array(
		'selector'            => '#career .tooltiptext',
		'settings'            => 'enlightme_pro_theme_options[career_section_enable]',
    ) );
}

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

$wp_customize->add_control( 'enlightme_pro_theme_options[career_sub_title]', array(
	'label'           	=> esc_html__( 'Sub Title', 'enlightme-pro' ),
	'section'        	=> 'enlightme_pro_career_section',
	'active_callback' 	=> 'enlightme_pro_is_career_section_enable',
	'type'				=> 'text',
) );

// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'enlightme_pro_theme_options[career_sub_title]', array(
		'selector'            => '#career p.section-subtitle',
		'settings'            => 'enlightme_pro_theme_options[career_sub_title]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'enlightme_pro_career_sub_title_partial',
    ) );
}

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

$wp_customize->add_control( 'enlightme_pro_theme_options[career_title]', array(
	'label'           	=> esc_html__( 'Title', 'enlightme-pro' ),
	'section'        	=> 'enlightme_pro_career_section',
	'active_callback' 	=> 'enlightme_pro_is_career_section_enable',
	'type'				=> 'text',
) );

// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'enlightme_pro_theme_options[career_title]', array(
		'selector'            => '#career h2.section-title',
		'settings'            => 'enlightme_pro_theme_options[career_title]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'enlightme_pro_career_title_partial',
    ) );
}

// career btn title setting and control
$wp_customize->add_setting( 'enlightme_pro_theme_options[career_post_btn]', array(
	'sanitize_callback' => 'sanitize_text_field',
	'default'			=> $options['career_post_btn'],
	) );

$wp_customize->add_control( 'enlightme_pro_theme_options[career_post_btn]', array(
	'label'           	=> esc_html__( 'Post Button Label', 'enlightme-pro' ),
	'section'        	=> 'enlightme_pro_career_section',
	'active_callback' 	=> 'enlightme_pro_is_career_section_enable',
	'type'				=> 'text',
	) );

// career btn title setting and control
$wp_customize->add_setting( 'enlightme_pro_theme_options[career_btn_title]', array(
	'sanitize_callback' => 'sanitize_text_field',
	'default'			=> $options['career_btn_title'],
	'transport'			=> 'postMessage',
	) );

$wp_customize->add_control( 'enlightme_pro_theme_options[career_btn_title]', array(
	'label'           	=> esc_html__( 'View All Button Label', 'enlightme-pro' ),
	'section'        	=> 'enlightme_pro_career_section',
	'active_callback' 	=> 'enlightme_pro_is_career_section_enable',
	'type'				=> 'text',
	) );

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

// career btn title setting and control
$wp_customize->add_setting( 'enlightme_pro_theme_options[career_btn_url]', array(
	'sanitize_callback' => 'esc_url_raw',
	) );

$wp_customize->add_control( 'enlightme_pro_theme_options[career_btn_url]', array(
	'label'           	=> esc_html__( 'Button Url', 'enlightme-pro' ),
	'section'        	=> 'enlightme_pro_career_section',
	'active_callback' 	=> 'enlightme_pro_is_career_section_enable',
	'type'				=> 'url',
	) );

// career content enable control and setting
$wp_customize->add_setting( 'enlightme_pro_theme_options[career_autoplay]', array(
	'default'			=> 	$options['career_autoplay'],
	'sanitize_callback' => 'enlightme_pro_sanitize_switch_control',
	) );

$wp_customize->add_control( new Enlightme_Pro_Switch_Control( $wp_customize, 'enlightme_pro_theme_options[career_autoplay]', array(
	'label'             => esc_html__( 'Auto Play Enable', 'enlightme-pro' ),
	'section'           => 'enlightme_pro_career_section',
	'on_off_label' 		=> enlightme_pro_switch_options(),
	'active_callback' 	=> 'enlightme_pro_is_career_section_enable',
	) ) );

// Event social icons number control and setting
$wp_customize->add_setting( 'enlightme_pro_theme_options[career_count]', array(
	'default'          	=> $options['career_count'],
	'sanitize_callback' => 'enlightme_pro_sanitize_number_range',
	'validate_callback' => 'enlightme_pro_validate_career_count',
) );

$wp_customize->add_control( 'enlightme_pro_theme_options[career_count]', array(
	'label'             => esc_html__( 'Number of Posts', 'enlightme-pro' ),
	'description'       => esc_html__( 'Note: Min 1 & Max 50. Please input the valid number and save. Then refresh the page to see the change.', 'enlightme-pro' ),
	'section'           => 'enlightme_pro_career_section',
	'active_callback'   => 'enlightme_pro_is_career_section_enable',
	'type'				=> 'number',
	'input_attrs'		=> array(
		'min'	=> 1,
		'max'	=> 50,
		'style' => 'width: 100px;'
		),
) );

// Career Content type setting and control
$wp_customize->add_setting( 'enlightme_pro_theme_options[career_content_type]', array(
	'default'          	=> $options['career_content_type'],
	'sanitize_callback' => 'enlightme_pro_sanitize_select',
) );

$wp_customize->add_control( 'enlightme_pro_theme_options[career_content_type]', array(
	'label'             => esc_html__( 'Content Type', 'enlightme-pro' ),
	'section'           => 'enlightme_pro_career_section',
	'type'				=> 'select',
	'active_callback' 	=> 'enlightme_pro_is_career_section_enable',
	'choices'			=> enlightme_pro_career_content_type(),
) );

// Add dropdown category setting and control.
$wp_customize->add_setting(  'enlightme_pro_theme_options[career_content_category]', array(
	'sanitize_callback' => 'enlightme_pro_sanitize_integers',
) ) ;

$wp_customize->add_control( new Enlightme_Pro_Dropdown_Category_Control( $wp_customize,'enlightme_pro_theme_options[career_content_category]', array(
	'label'             => esc_html__( 'Select Multiple Category', 'enlightme-pro' ),
	'section'           => 'enlightme_pro_career_section',
	'type'              => 'dropdown-categories',
	'active_callback'	=> 'enlightme_pro_is_career_section_content_category_enable'
) ) );

// Add dropdown category setting and control.
$wp_customize->add_setting(  'enlightme_pro_theme_options[career_content_course_category]', array(
	'sanitize_callback' => 'enlightme_pro_sanitize_integers',
) ) ;

$wp_customize->add_control( new Enlightme_Pro_Dropdown_Category_Control( $wp_customize,'enlightme_pro_theme_options[career_content_course_category]', array(
	'label'             => esc_html__( 'Select Multiple Course Category', 'enlightme-pro' ),
	'section'           => 'enlightme_pro_career_section',
	'taxonomy'			=> 'tp-course-category',
	'type'              => 'dropdown-categories',
	'active_callback'	=> 'enlightme_pro_is_career_section_content_course_category_enable'
) ) );