<?php
/**
 * Call To Action Section
*/
$wp_customize->add_section(new constructionarc_Toggle_Section($wp_customize, 'constructionarc_calltoaction_section', array(
	'title'		=> 	esc_html__('Call To Action Section','construction-arc'),
	'panel'		=> 'constructionarc_frontpage_settings',
	'priority'  => constructionarc_themes_get_section_position('constructionarc_calltoaction_section'),
	'hiding_control' => 'constructionarc_cta_disable'
)));

//ENABLE/DISABLE CALL TO ACTION SECTION
$wp_customize->add_setting('constructionarc_cta_disable', array(
	'default' => 'enable',
	'transport' => 'postMessage',
	'sanitize_callback' => 'constructionarc_themes_sanitize_switch',    
));
$wp_customize->add_control(new constructionarc_Switch_Control($wp_customize, 'constructionarc_cta_disable', array(
	'label' => esc_html__('Section', 'construction-arc'),
	'section' => 'constructionarc_calltoaction_section',
	'switch_label' => array(
		'enable' => esc_html__('Enable', 'construction-arc'),
		'disable' => esc_html__('Disable', 'construction-arc'),
	),
	'class' => 'switch-section',
    'priority' => -1,
)));

	$wp_customize->add_setting('constructionarc_calltoaction_section_nav', array(
		'transport' => 'postMessage',
		'sanitize_callback' => 'wp_kses_post',
	));
	$wp_customize->add_control(new constructionarc_Custom_Control_Tab($wp_customize, 'constructionarc_calltoaction_section_nav', array(
		'type' => 'tab',
		'section' => 'constructionarc_calltoaction_section',
		'priority' => 1,
		'buttons' => array(
			array(
				'name' => esc_html__('Content', 'construction-arc'),
				'fields' => array(
					'constructionarc_cta_style',
					'constructionarc_cta_width',
					'constructionarc_cta_layout',
					'constructionarc_cta_alignment',
					'constructionarc_calltoaction_image',
					'constructionarc_calltoaction_icon',
					'constructionarc_call_to_action_title',
					'constructionarc_call_to_action_subtitle',
					'constructionarc_call_to_action_button',
					'constructionarc_call_to_action_link',
					'constructionarc_call_to_action_button_one',
					'constructionarc_call_to_action_link_one',
					'constructionarc_calltoaction_height',
				),
				'active' => true,
			),
			array(
				'name' => esc_html__('Style', 'construction-arc'),
				'fields' => array(
					'constructionarc_cta_title_font_size',
					'constructionarc_cta_desc_font_size',
					'constructionarc_calltoaction_cs_heading',
					'constructionarc_calltoaction_box_bg_color',
					'constructionarc_calltoaction_title_color',
					'constructionarc_calltoaction_text_color',
				)
			),
			array(
				'name' => esc_html__('Advanced', 'construction-arc'),
				'fields' => array(
					'constructionarc_calltoaction_bg_type',
					'constructionarc_calltoaction_bg_color',
					'constructionarc_calltoaction_bg_image',
					'constructionarc_calltoaction_overlay_color',
					'constructionarc_calltoaction_padding',
					'constructionarc_calltoaction_margin',
					'constructionarc_calltoaction_radius',
					'constructionarc_calltoaction_cs_seperator',
				),
			),
		),
	)));

	$wp_customize->add_setting('constructionarc_cta_style', array(
		'default' => 'cover',
		'transport' => 'postMessage',
		'sanitize_callback' => 'constructionarc_themes_sanitize_select'       
	));
	$wp_customize->add_control('constructionarc_cta_style', array(
		'label' => esc_html__('Layout', 'construction-arc'),
		'section' => 'constructionarc_calltoaction_section',
		'type' => 'select',
		'choices' => array(
			'classic' => esc_html__('Classic' , 'construction-arc'),
			'cover' => esc_html__('Cover' ,'construction-arc'),
		)
	));

	$wp_customize->add_setting('constructionarc_cta_width', array(
		'default' => 'container',
		'transport' => 'postMessage',
		'sanitize_callback' => 'constructionarc_themes_sanitize_select'       
	));
	$wp_customize->add_control('constructionarc_cta_width', array(
		'label' => esc_html__('Width', 'construction-arc'),
		'section' => 'constructionarc_calltoaction_section',
		'type' => 'select',
		'choices' => array(
			'container' => esc_html__('Container' ,'construction-arc'),
			'full' => esc_html__('Full' , 'construction-arc'),
		)
	));

	$wp_customize->add_setting('constructionarc_calltoaction_image', array(
		'transport' => 'postMessage',
		'sanitize_callback'	=> 'esc_url_raw',
		'default' => get_template_directory_uri() . '/assets/images/bg.jpg',	
	));
	$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'constructionarc_calltoaction_image', array(
		'label'	   => esc_html__('Background Image','construction-arc'),
		'section'  => 'constructionarc_calltoaction_section'
	)));

	$wp_customize->add_setting('constructionarc_cta_layout', array(
		'sanitize_callback' => 'sanitize_text_field',
		'transport' => 'postMessage',
		'default' => 'cta-above'
	));
	$wp_customize->add_control(new constructionarc_Selector($wp_customize, 'constructionarc_cta_layout', array(
		'section' => 'constructionarc_calltoaction_section',
		'label' => esc_html__('Select Layout', 'construction-arc'),
		'options' => array(
			'cta-above' => get_template_directory_uri() . '/inc/customizer/images/cta-image-top.webp',
			'cta-left' => get_template_directory_uri() . '/inc/customizer/images/cta-image-left.webp',
			'cta-right' => get_template_directory_uri() . '/inc/customizer/images/cta-image-right.webp',
			'cta-below' => get_template_directory_uri() . '/inc/customizer/images/cta-image-bottom.webp',
		)
	)));

	$wp_customize->add_setting('constructionarc_calltoaction_height', array(
		'sanitize_callback' => 'absint',
		'default' => 450,
		'transport' => 'postMessage'
	));
	$wp_customize->add_control(new constructionarc_Themes_Range_Control($wp_customize, 'constructionarc_calltoaction_height', array(
		'section' => 'constructionarc_calltoaction_section',
		'label' => esc_html__('Call To Action Height (px)', 'construction-arc'),
		'input_attrs' => array(
			'min' => 300,
			'max' => 900,
			'step' => 1
		)
	)));

	$wp_customize->add_setting( 'constructionarc_cta_alignment', array(
		'default'           => 'center',
		'sanitize_callback' => 'constructionarc_themes_sanitize_select',
		'transport'         => 'postMessage',
	) );
	$wp_customize->add_control( new constructionarc_Custom_Control_Buttonset( $wp_customize, 'constructionarc_cta_alignment', array(
		'choices'  => array(
			'start' => esc_html__('Left', 'construction-arc'),
			'center' => esc_html__('Center', 'construction-arc'),
			'end' => esc_html__('Right', 'construction-arc'),
		),
		'label'    => esc_html__( 'Alignment', 'construction-arc' ),
		'section'  => 'constructionarc_calltoaction_section',
	)));

	$wp_customize->add_setting('constructionarc_calltoaction_icon', array(
		'sanitize_callback' => 'constructionarc_themes_sanitize_text',
		'default' => 'fa-solid fa-headset',
		'transport' => 'postMessage'
	));
	$wp_customize->add_control(new constructionarc_Fontawesome_Icon_Chooser($wp_customize, 'constructionarc_calltoaction_icon', array(
		'section' => 'constructionarc_calltoaction_section',
		'label' => esc_html__('Icon', 'construction-arc')
	)));

	$wp_customize->add_setting('constructionarc_call_to_action_title', array(
		'transport' => 'postMessage',
		'default' => esc_html__('Welcome to our Construction WordPress Themes!', 'construction-arc'),
		'sanitize_callback'	=> 'sanitize_text_field'		
	));
	$wp_customize->add_control('constructionarc_call_to_action_title', array(
		'label'	   => esc_html__('Title','construction-arc'),
		'section'  => 'constructionarc_calltoaction_section',
		'type'	   => 'text',
	));

	$wp_customize->add_setting('constructionarc_call_to_action_subtitle', array(
		'transport' => 'postMessage',
		'default' => esc_html__('Try our premium themes risk-free. If you are not 100% satisfied with the features and performance of our premium themes, we will credit your original payment method without any question.', 'construction-arc'),
		'sanitize_callback'	=> 'constructionarc_themes_sanitize_text'		
	));
	$wp_customize->add_control('constructionarc_call_to_action_subtitle', array(
		'label'	   => esc_html__('Description','construction-arc'),
		'section'  => 'constructionarc_calltoaction_section',
		'type'	   => 'textarea',
	));
	
	$wp_customize->add_setting('constructionarc_call_to_action_button', array(
		'transport' => 'postMessage',
		'default' => esc_html__('WordPress Themes', 'construction-arc'),
		'sanitize_callback'	=> 'sanitize_text_field'		
	));
	$wp_customize->add_control('constructionarc_call_to_action_button', array(
		'label'	   => esc_html__('Button One Text','construction-arc'),
		'section'  => 'constructionarc_calltoaction_section',
		'type'	   => 'text',
	));
	$wp_customize->add_setting('constructionarc_call_to_action_link', array(
		'transport' => 'postMessage',
		'sanitize_callback'	=> 'esc_url_raw'		
	));
	$wp_customize->add_control('constructionarc_call_to_action_link', array(
		'label'	   => esc_html__('Button One Link','construction-arc'),
		'section'  => 'constructionarc_calltoaction_section',
		'type'	   => 'url',
	));

	$wp_customize->add_setting('constructionarc_call_to_action_button_one', array(
		'transport' => 'postMessage',
		'default' => esc_html__('Buy Now', 'construction-arc'),
		'sanitize_callback'	=> 'sanitize_text_field'		
	));
	$wp_customize->add_control('constructionarc_call_to_action_button_one', array(
		'label'	   => esc_html__('Button Two Text','construction-arc'),
		'section'  => 'constructionarc_calltoaction_section',
		'type'	   => 'text',
	));
	$wp_customize->add_setting('constructionarc_call_to_action_link_one', array(
		'transport' => 'postMessage',
		'sanitize_callback'	=> 'esc_url_raw'		
	));
	$wp_customize->add_control('constructionarc_call_to_action_link_one', array(
		'label'	   => esc_html__('Button Two Link','construction-arc'),
		'section'  => 'constructionarc_calltoaction_section',
		'type'	   => 'url',
	));


	$wp_customize->add_setting("constructionarc_cta_title_font_size", array(
		'transport' => 'postMessage',
		'sanitize_callback' => 'constructionarc_themes_sanitize_number_blank',
		'default' => 28
	));
	$wp_customize->add_control(new constructionarc_Themes_Range_Control($wp_customize, "constructionarc_cta_title_font_size", array(
		'section' => "constructionarc_calltoaction_section",
		'label' => esc_html__('Title Font Size', 'construction-arc'),
		'input_attrs' => array(
			'min' => 10,
			'max' => 200,
			'step' => 1,
		)
	)));
	$wp_customize->add_setting("constructionarc_cta_desc_font_size", array(
		'transport' => 'postMessage',
		'sanitize_callback' => 'constructionarc_themes_sanitize_number_blank',
		'default' => 18,
	));
	$wp_customize->add_control(new constructionarc_Themes_Range_Control($wp_customize, "constructionarc_cta_desc_font_size", array(
		'section' => "constructionarc_calltoaction_section",
		'label' => esc_html__('Description Font Size', 'construction-arc'),
		'input_attrs' => array(
			'min' => 10,
			'max' => 200,
			'step' => 1,
		)
	)));

	$wp_customize->add_setting("constructionarc_calltoaction_box_bg_color", array(
        'default' => '',
        'sanitize_callback' => 'constructionarc_themes_sanitize_color_alpha',
        'transport' => 'postMessage'
    ));
    $wp_customize->add_control(new constructionarc_Alpha_Color_Control($wp_customize, "constructionarc_calltoaction_box_bg_color", array(
        'section' => "constructionarc_calltoaction_section",
        'label' => esc_html__('Background Color', 'construction-arc'),
        'priority' => 54
    )));

	$wp_customize->add_setting('constructionarc_pro_calltoaction', array(
        'sanitize_callback' => 'constructionarc_sanitize_text'
    ));
    $wp_customize->add_control(new constructionarc_Themes_Upgrade_Text($wp_customize, 'constructionarc_pro_calltoaction', array(
        'section' => 'constructionarc_calltoaction_section',
        'label' => esc_html__('For More Settings,', 'construction-arc'),
        'choices' => array(
            esc_html__('(5+) Different Layout & Settings', 'construction-arc'),
            esc_html__('Title, sub title & text color options', 'construction-arc'),
			esc_html__('4+ Different Background Options( Color/Video/Gradient/Image ) ', 'construction-arc'),
			esc_html__('More Than 35+ Top & Bottom Separator Shape Illustrator with Color & Height Option', 'construction-arc'),
        ),
        'priority' => 250,
    )));

$wp_customize->selective_refresh->add_partial( "constructionarc_calltoaction_refresh", array (
	'settings' => array(
		'constructionarc_cta_disable',
		'constructionarc_cta_width',
		'constructionarc_calltoaction_image',
		'constructionarc_calltoaction_icon',
	),
	'selector' => "#calltoaction-section",
	'fallback_refresh' => true,
	'container_inclusive' => true,
	'render_callback' => function () {
		return get_template_part( 'section/section-calltoaction' );
	}
));