<?php
/**
 * Donation Section options
 *
 * @package Theme Palace
 * @subpackage Charity Give
 * @since Charity Give 1.0.0
 */

if ( ! class_exists( 'Give' ) ) {
	return;
}

// Add Donation section
$wp_customize->add_section( 'charity_give_donation_section', array(
	'title'             => esc_html__( 'Donation','charity-give' ),
	'description'       => esc_html__( 'Donation Section options.', 'charity-give' ),
	'panel'             => 'charity_give_front_page_panel',
) );

// Donation content enable control and setting
$wp_customize->add_setting( 'charity_give_theme_options[donation_section_enable]', array(
	'default'			=> 	$options['donation_section_enable'],
	'sanitize_callback' => 'charity_give_sanitize_switch_control',
) );

$wp_customize->add_control( new Charity_Give_Switch_Control( $wp_customize, 'charity_give_theme_options[donation_section_enable]', array(
	'label'             => esc_html__( 'Donation Section Enable', 'charity-give' ),
	'section'           => 'charity_give_donation_section',
	'on_off_label' 		=> charity_give_switch_options(),
) ) );

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

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

$wp_customize->add_control( 'charity_give_theme_options[donation_title]', array(
	'label'           	=> esc_html__( 'Title', 'charity-give' ),
	'section'        	=> 'charity_give_donation_section',
	'active_callback' 	=> 'charity_give_is_donation_section_enable',
	'type'				=> 'text',
) );

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

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

$wp_customize->add_control( 'charity_give_theme_options[donation_sub_title]', array(
	'label'           	=> esc_html__( 'Sub Title', 'charity-give' ),
	'section'        	=> 'charity_give_donation_section',
	'active_callback' 	=> 'charity_give_is_donation_section_enable',
	'type'				=> 'text',
) );

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

for ( $i = 1; $i <= 3; $i++ ) :

// About pages drop down chooser control and setting
$wp_customize->add_setting( 'charity_give_theme_options[dontation_form_' . $i . ']', array(
	'sanitize_callback' => 'charity_give_sanitize_page',
	) );

$wp_customize->add_control( new Charity_Give_Dropdown_Chooser( $wp_customize, 'charity_give_theme_options[dontation_form_' . $i . ']', array(
	'label'             => sprintf( esc_html__( 'Select Form %d', 'charity-give' ), $i ),
	'section'           => 'charity_give_donation_section',
	'choices'			=> charity_give_donation_form_choices(),
	'active_callback'	=> 'charity_give_is_donation_section_enable',
	) ) );

endfor;

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

$wp_customize->add_control( 'charity_give_theme_options[donation_btn_title]', array(
	'label'           	=> esc_html__( 'Button Label', 'charity-give' ),
	'section'        	=> 'charity_give_donation_section',
	'active_callback' 	=> 'charity_give_is_donation_section_enable',
	'type'				=> 'text',
	) );

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