<?php
/**
 * Contact Section options
 *
 * @package Theme Palace
 * @subpackage Raise Charity Pro
 * @since Raise Charity Pro 1.0.0
 */

// Add Contact section
$wp_customize->add_section( 'raise_charity_pro_contact_section', array(
	'title'             => esc_html__( 'Contact Section','raise-charity-pro' ),
	'description'       => esc_html__( 'Contact Section options.', 'raise-charity-pro' ),
	'panel'             => 'raise_charity_pro_front_page_panel',
	) );

// Contact content enable control and setting
$wp_customize->add_setting( 'raise_charity_pro_theme_options[contact_section_enable]', array(
	'default'			=> 	$options['contact_section_enable'],
	'sanitize_callback' => 'raise_charity_pro_sanitize_switch_control',
	) );

$wp_customize->add_control( new Raise_Charity_Pro_Switch_Control( $wp_customize, 'raise_charity_pro_theme_options[contact_section_enable]', array(
	'label'             => esc_html__( 'Contact Section Enable', 'raise-charity-pro' ),
	'section'           => 'raise_charity_pro_contact_section',
	'on_off_label' 		=> raise_charity_pro_switch_options(),
	) ) );

if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'raise_charity_pro_theme_options[contact_section_enable]', array(
		'selector'            => '#contact-section .tooltiptext',
		'settings'            => 'raise_charity_pro_theme_options[contact_section_enable]',
    ) );
}

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

$wp_customize->add_control( 'raise_charity_pro_theme_options[contact_title]', array(
	'label'           	=> esc_html__( 'Section Title', 'raise-charity-pro' ),
	'section'        	=> 'raise_charity_pro_contact_section',
	'active_callback' 	=> 'raise_charity_pro_is_contact_section_enable',
	'type'				=> 'text',
) );

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

// top description setting and control
$wp_customize->add_setting( 'raise_charity_pro_theme_options[contact_sub_title]', array(
	'sanitize_callback' => 'wp_kses_post',
	'default'			=> $options['contact_sub_title'],
	'transport'			=> 'postMessage',
) );

$wp_customize->add_control( 'raise_charity_pro_theme_options[contact_sub_title]', array(
	'label'           	=> esc_html__( 'Section Title', 'raise-charity-pro' ),
	'section'        	=> 'raise_charity_pro_contact_section',
	'active_callback' 	=> 'raise_charity_pro_is_contact_section_enable',
	'type'				=> 'textarea',
) );

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

// contact image setting and control.
$wp_customize->add_setting( 'raise_charity_pro_theme_options[contact_image]', array(
	'sanitize_callback' => 'raise_charity_pro_sanitize_image'
) );

$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'raise_charity_pro_theme_options[contact_image]',
		array(
		'label'       		=> esc_html__( 'Counter BG Image', 'raise-charity-pro' ),
		'section'     		=> 'raise_charity_pro_contact_section',
		'active_callback'	=> 'raise_charity_pro_is_contact_section_enable',
) ) );

// top description setting and control
$wp_customize->add_setting( 'raise_charity_pro_theme_options[contact_form_shortcode]', array(
	'sanitize_callback' => 'sanitize_text_field',
	'default'			=> $options['contact_form_shortcode'],
) );

$wp_customize->add_control( 'raise_charity_pro_theme_options[contact_form_shortcode]', array(
	'label'           	=> esc_html__( 'Contact Form Short', 'raise-charity-pro' ),
	'description'		=> esc_html__( 'Get the form shortcode from contact form 7(CF7) plugin example [contact-form-7 id="3088" title="Untitled"] :', 'raise-charity-pro' ),
	'section'        	=> 'raise_charity_pro_contact_section',
	'active_callback' 	=> 'raise_charity_pro_is_contact_section_enable',
	'type'				=> 'text',
) );

// top description setting and control
$wp_customize->add_setting( 'raise_charity_pro_theme_options[contact_map_shortcode]', array(
	'sanitize_callback' => 'sanitize_text_field',
	'default'			=> $options['contact_map_shortcode'],
) );

$wp_customize->add_control( 'raise_charity_pro_theme_options[contact_map_shortcode]', array(
	'label'           	=> esc_html__( 'Contact Form Short', 'raise-charity-pro' ),
	'description'		=> esc_html__( 'Get the form shortcode from WP Google Maps plugin example [wpgmza id="1"]', 'raise-charity-pro' ),
	'section'        	=> 'raise_charity_pro_contact_section',
	'active_callback'   => function( $control ) {
		return ( 
			raise_charity_pro_is_contact_section_enable( $control )
			&&
			raise_charity_pro_is_seventh_layout( $control )
		);
	},
	'type'				=> 'text',
) );

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

$wp_customize->add_control('raise_charity_pro_theme_options[contact_section_phoneNumber]',
    array(
        'section'			=> 'raise_charity_pro_contact_section',
        'label'				=> esc_html__( 'Contact Number:', 'raise-charity-pro' ),
        'type'          	=>'text',
		'active_callback'   => function( $control ) {
			return ( 
				raise_charity_pro_is_contact_section_enable( $control )
				&&
				raise_charity_pro_is_seventh_layout( $control )
			);
		},
    )
);

// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'raise_charity_pro_theme_options[contact_section_phoneNumber]',
		array(
			'selector'            => '#contact-section .contact-information ul li:nth-child(2) span',
			'settings'            => 'raise_charity_pro_theme_options[contact_section_phoneNumber]',
			'fallback_refresh'    => true,
			'container_inclusive' => false,
			'render_callback'     => 'raise_charity_pro_contact_section_phoneNumber_partial',
		) 
	);
}

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

$wp_customize->add_control('raise_charity_pro_theme_options[contact_section_address]',
    array(
        'section'			=> 'raise_charity_pro_contact_section',
        'label'				=> esc_html__( 'Address:', 'raise-charity-pro' ),
        'type'          	=>'text',
		'active_callback'   => function( $control ) {
			return ( 
				raise_charity_pro_is_contact_section_enable( $control )
				&&
				raise_charity_pro_is_seventh_layout( $control )
			);
		},
    )
);

// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'raise_charity_pro_theme_options[contact_section_address]',
		array(
            'selector'            => '#contact-section .contact-information ul li:nth-child(1) span',
			'settings'            => 'raise_charity_pro_theme_options[contact_section_address]',
			'fallback_refresh'    => true,
			'container_inclusive' => false,
			'render_callback'     => 'raise_charity_pro_contact_section_address_partial',
        ) 
    );
}

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

$wp_customize->add_control('raise_charity_pro_theme_options[contact_section_email]',
    array(
        'section'			=> 'raise_charity_pro_contact_section',
        'label'				=> esc_html__( 'E-mail:', 'raise-charity-pro' ),
        'type'          	=>'text',
		'active_callback'   => function( $control ) {
			return ( 
				raise_charity_pro_is_contact_section_enable( $control )
				&&
				raise_charity_pro_is_seventh_layout( $control )
			);
		},
    )
);

// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'raise_charity_pro_theme_options[contact_section_email]',
        array(
            'selector'            => '#contact-section .contact-information ul li:nth-child(3) span',
            'settings'            => 'raise_charity_pro_theme_options[contact_section_email]',
            'fallback_refresh'    => true,
            'container_inclusive' => false,
            'render_callback'     => 'raise_charity_pro_contact_section_email_partial',
        ) 
    );
}