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

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

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

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

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

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

$wp_customize->add_control( 'enlightme_theme_options[about_sub_title]', array(
	'label'           	=> esc_html__( 'Sub Title', 'enlightme' ),
	'section'        	=> 'enlightme_about_section',
	'active_callback' 	=> 'enlightme_is_about_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[about_sub_title]', array(
		'selector'            => '#about-us p.section-subtitle',
		'settings'            => 'enlightme_theme_options[about_sub_title]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'enlightme_about_sub_title_partial',
    ) );
}

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

$wp_customize->add_control( 'enlightme_theme_options[about_btn_text]', array(
	'label'           	=> esc_html__( 'Button Label', 'enlightme' ),
	'section'        	=> 'enlightme_about_section',
	'active_callback' 	=> 'enlightme_is_about_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[about_btn_text]', array(
		'selector'            => '#about-us div.read-more a',
		'settings'            => 'enlightme_theme_options[about_btn_text]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'enlightme_about_btn_text_partial',
    ) );
}

// about posts drop down chooser control and setting
$wp_customize->add_setting( 'enlightme_theme_options[about_content_post]', array(
	'sanitize_callback' => 'enlightme_sanitize_page',
) );

$wp_customize->add_control( new Enlightme_Dropdown_Chooser( $wp_customize, 'enlightme_theme_options[about_content_post]', array(
	'label'             => esc_html__( 'Select Post', 'enlightme' ),
	'section'           => 'enlightme_about_section',
	'choices'			=> enlightme_post_choices(),
	'active_callback'	=> 'enlightme_is_about_section_enable',
) ) );

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

$wp_customize->add_control( 'enlightme_theme_options[about_video_intro_text]', array(
	'label'           	=> esc_html__( 'Video Intro Text', 'enlightme' ),
	'section'        	=> 'enlightme_about_section',
	'active_callback' 	=> 'enlightme_is_about_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[about_video_intro_text]', array(
		'selector'            => '#about-us h2.entry-title',
		'settings'            => 'enlightme_theme_options[about_video_intro_text]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'enlightme_about_video_intro_text_partial',
    ) );
}

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

$wp_customize->add_control( 'enlightme_theme_options[about_video_sub_intro_text]', array(
	'label'           	=> esc_html__( 'Video Intro Sub Text', 'enlightme' ),
	'section'        	=> 'enlightme_about_section',
	'active_callback' 	=> 'enlightme_is_about_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[about_video_sub_intro_text]', array(
		'selector'            => '#about-us .entry-header p',
		'settings'            => 'enlightme_theme_options[about_video_sub_intro_text]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'enlightme_about_video_sub_intro_text_partial',
    ) );
}

// about image setting and control.
$wp_customize->add_setting( 'enlightme_theme_options[about_featured_image]', array(
	'sanitize_callback' => 'enlightme_sanitize_image'
) );

$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'enlightme_theme_options[about_featured_image]',
		array(
		'label'       		=> esc_html__( 'Featured Image', 'enlightme' ),
		'section'     		=> 'enlightme_about_section',
		'active_callback'	=> 'enlightme_is_about_section_enable',
) ) );

// about image setting and control.
$wp_customize->add_setting( 'enlightme_theme_options[about_video_image]', array(
	'sanitize_callback' => 'enlightme_sanitize_image'
) );

$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'enlightme_theme_options[about_video_image]',
		array(
		'label'       		=> esc_html__( 'Video Featured Image', 'enlightme' ),
		'section'     		=> 'enlightme_about_section',
		'active_callback'	=> 'enlightme_is_about_section_enable',
) ) );

// about btn link setting and control
$wp_customize->add_setting( 'enlightme_theme_options[about_video_link]', array(
	'sanitize_callback' => 'esc_url_raw',
) );

$wp_customize->add_control( 'enlightme_theme_options[about_video_link]', array(
	'label'           	=> esc_html__( 'Youtube Video Link', 'enlightme' ),
	'section'        	=> 'enlightme_about_section',
	'active_callback' 	=> 'enlightme_is_about_section_enable',
	'type'				=> 'url',
) );