<?php
/**
 * About Section options
 *
 * @package Theme Palace
 * @subpackage Top Event
 * @since Top Event 1.0.0
 */

// Add About section
$wp_customize->add_section( 'top_event_about_section',
	array(
		'title'             => esc_html__( 'About us','top-event' ),
		'description'       => esc_html__( 'About us  Section options.', 'top-event' ),
        'panel'             => 'top_event_front_page_panel',

	)
);

// About content enable control and setting
$wp_customize->add_setting( 'top_event_theme_options[about_section_enable]',
	array(
		'default'			=> 	$options['about_section_enable'],
		'sanitize_callback' => 'top_event_sanitize_switch_control',
	)
);

$wp_customize->add_control( new Top_Event_Switch_Control( $wp_customize,
	'top_event_theme_options[about_section_enable]',
		array(
			'label'             => esc_html__( 'About Section Enable', 'top-event' ),
			'section'           => 'top_event_about_section',
			'on_off_label' 		=> top_event_switch_options(),
		)
	)
);

// about section title control and setting
$wp_customize->add_setting( 'top_event_theme_options[about_section_subtitle]',
	array(
		'sanitize_callback' => 'sanitize_text_field',
		'default'			=> 	$options['about_section_subtitle'],
		'transport'			=>'postMessage'
	)
);

$wp_customize->add_control('top_event_theme_options[about_section_subtitle]',
	array(
		'label'             => esc_html__( 'Section Sub Title', 'top-event' ),
		'section'           => 'top_event_about_section',
		'type'              =>'text',
		'active_callback'	=> 'top_event_is_about_section_enable',
	)
);

$wp_customize->selective_refresh->add_partial( 'top_event_theme_options[about_section_subtitle]',
    array(
        'selector'            => '#about-section .section-subtitle',
        'render_callback'     => 'top_event_about_section_subtitle_partial',
    )
);

// about section title control and setting
$wp_customize->add_setting( 'top_event_theme_options[about_section_title]',
	array(
		'sanitize_callback' => 'sanitize_text_field',
		'default'			=> 	$options['about_section_title'],
		'transport'			=>'postMessage'
	)
);

$wp_customize->add_control('top_event_theme_options[about_section_title]',
	array(
		'label'             => esc_html__( 'Section Sub Title', 'top-event' ),
		'section'           => 'top_event_about_section',
		'type'              =>'text',
		'active_callback'	=> 'top_event_is_about_section_enable',
	)
);

$wp_customize->selective_refresh->add_partial( 'top_event_theme_options[about_section_title]',
    array(
        'selector'            => '#about-section .section-title',
        'render_callback'     => 'top_event_about_section_title_partial',
    )
);

// about pages drop down chooser control and setting
$wp_customize->add_setting( 'top_event_theme_options[about_content_page]',
	array(
		'sanitize_callback' => 'top_event_sanitize_page',
	)
);

$wp_customize->add_control( new Top_Event_Dropdown_Chooser( $wp_customize,
	'top_event_theme_options[about_content_page]',
		array(
			'label'             => esc_html__( 'Select Page', 'top-event' ),
			'section'           => 'top_event_about_section',
			'choices'			=> top_event_page_choices(),
			'active_callback'	=> 'top_event_is_about_section_enable',
		)
	)
);

//about_btn_txt
$wp_customize->add_setting('top_event_theme_options[about_btn_txt]',
    array(
        'sanitize_callback' => 'sanitize_text_field',
        'transport'			=> 'postMessage',
        'default'           => $options['about_btn_txt'],
    )
);

$wp_customize->add_control('top_event_theme_options[about_btn_txt]',
    array(
        'section'			=> 'top_event_about_section',
        'label'				=> esc_html__( 'Button Text:', 'top-event' ),
        'type'          	=>'text',
        'active_callback' 	=> 'top_event_is_about_section_enable'
    )
);

// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'top_event_theme_options[about_btn_txt]',
		array(
			'selector'            => '#about-section div.read-more a',
			'settings'            => 'top_event_theme_options[about_btn_txt]',
			'fallback_refresh'    => true,
			'container_inclusive' => false,
			'render_callback'     => 'top_event_about_btn_txt_partial',
		)
	);
}

// about Excerpt length setting and control.
$wp_customize->add_setting( 'top_event_theme_options[about_excerpt_length]',
	array(
		'sanitize_callback' => 'top_event_sanitize_number_range',
		'default'			=> $options['about_excerpt_length'],
	)
);

$wp_customize->add_control( 'top_event_theme_options[about_excerpt_length]',
	array(
		'label'       		=> esc_html__( 'Excerpt Length', 'top-event' ),
		'description' 		=> esc_html__( 'Total words to be displayed in about section', 'top-event' ),
		'section'     		=> 'top_event_about_section',
		'type'        		=> 'number',
		'active_callback' 	=> 'top_event_is_about_section_enable',
	)
);