<?php
/**
 * Call To Action Section options
 *
 * @package Theme Palace
 * @subpackage Pushpa
 * @since Pushpa 1.0.0
 */

// Add Call To Action section
$wp_customize->add_section( 'pushpa_cta_section',
    array(
        'title'             => esc_html__( 'Call To Action','pushpa' ),
        'description'       => esc_html__( 'Call To Action Section options.', 'pushpa' ),
        'panel'             => 'pushpa_front_page_panel',
    )
);

// Call To Action content enable control and setting
$wp_customize->add_setting( 'pushpa_theme_options[cta_section_enable]',
    array(
        'default'			=> 	$options['cta_section_enable'],
        'sanitize_callback' => 'pushpa_sanitize_switch_control',
    )
);

$wp_customize->add_control( new Pushpa_Switch_Control( $wp_customize,
    'pushpa_theme_options[cta_section_enable]',
        array(
            'label'             => esc_html__( 'Call To Action Section Enable', 'pushpa' ),
            'section'           => 'pushpa_cta_section',
            'on_off_label' 		=> pushpa_switch_options(),
        )
    )
);

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

$wp_customize->add_setting( 'pushpa_theme_options[cta_content_page]',
    array(
        'sanitize_callback' => 'pushpa_sanitize_page',
    )
);

$wp_customize->add_control( new Pushpa_Dropdown_Chooser( $wp_customize,
    'pushpa_theme_options[cta_content_page]',
        array(
            'label'             => esc_html__( 'Select Page', 'pushpa' ),
            'section'           => 'pushpa_cta_section',
            'choices'			=> pushpa_page_choices(),
            'active_callback'	=> 'pushpa_is_cta_section_enable',
        )
    )
);

// Call To Action read more setting and control
$wp_customize->add_setting( 'pushpa_theme_options[cta_read_more]',
    array(
        'default'			=> $options['cta_read_more'],
        'sanitize_callback' => 'sanitize_text_field',
        'transport'         =>'postMessage',
    )
);

$wp_customize->add_control( 'pushpa_theme_options[cta_read_more]',
    array(
        'label'           	=> esc_html__( 'Read More Text', 'pushpa' ),
        'section'        	=> 'pushpa_cta_section',
        'active_callback' 	=> 'pushpa_is_cta_section_enable',
        'type'				=> 'text',
    )
);

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