<?php
/**
 * Download Section options
 *
 * @package Theme Palace
 * @subpackage enlightme Pro
 * @since enlightme Pro 1.0.0
 */

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

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

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

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

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

$wp_customize->add_control( 'enlightme_pro_theme_options[download_sub_title]', array(
	'label'           	=> esc_html__( 'Sub Title', 'enlightme-pro' ),
	'section'        	=> 'enlightme_pro_download_section',
	'active_callback' 	=> 'enlightme_pro_is_download_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[download_sub_title]', array(
		'selector'            => '#download p.section-subtitle',
		'settings'            => 'enlightme_pro_theme_options[download_sub_title]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'enlightme_pro_download_sub_title_partial',
    ) );
}

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

$wp_customize->add_control( 'enlightme_pro_theme_options[download_title]', array(
	'label'           	=> esc_html__( 'Title', 'enlightme-pro' ),
	'section'        	=> 'enlightme_pro_download_section',
	'active_callback' 	=> 'enlightme_pro_is_download_section_enable',
	'type'				=> 'textarea',
) );

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

// about image setting and control.
$wp_customize->add_setting( 'enlightme_pro_theme_options[download_playstore_image]', array(
	'sanitize_callback' => 'enlightme_pro_sanitize_image'
) );

$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'enlightme_pro_theme_options[download_playstore_image]',
		array(
		'label'       		=> esc_html__( 'Playstore Btn Image', 'enlightme-pro' ),
		'section'     		=> 'enlightme_pro_download_section',
		'active_callback'	=> 'enlightme_pro_is_download_section_enable',
) ) );

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

$wp_customize->add_control( 'enlightme_pro_theme_options[download_playstore_link]', array(
	'label'           	=> esc_html__( 'Play Store Link', 'enlightme-pro' ),
	'section'        	=> 'enlightme_pro_download_section',
	'active_callback' 	=> 'enlightme_pro_is_download_section_enable',
	'type'				=> 'url',
) );

// about image setting and control.
$wp_customize->add_setting( 'enlightme_pro_theme_options[download_appstore_image]', array(
	'sanitize_callback' => 'enlightme_pro_sanitize_image'
) );

$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'enlightme_pro_theme_options[download_appstore_image]',
		array(
		'label'       		=> esc_html__( 'Appstore Btn Image', 'enlightme-pro' ),
		'section'     		=> 'enlightme_pro_download_section',
		'active_callback'	=> 'enlightme_pro_is_download_section_enable',
) ) );

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

$wp_customize->add_control( 'enlightme_pro_theme_options[download_appstore_link]', array(
	'label'           	=> esc_html__( 'App Store Link', 'enlightme-pro' ),
	'section'        	=> 'enlightme_pro_download_section',
	'active_callback' 	=> 'enlightme_pro_is_download_section_enable',
	'type'				=> 'url',
) );