<?php
/**
 * Testimonial Section
*/
$wp_customize->add_section(new constructionarc_Toggle_Section($wp_customize, 'constructionarc_testimonial_section', array(
    'title'		=> 	esc_html__('Testimonials Section','construction-arc'),
    'panel'		=> 'constructionarc_frontpage_settings',
    'priority'  => constructionarc_themes_get_section_position('constructionarc_testimonial_section'),
    'hiding_control' => 'constructionarc_testimonial_disable'
)));

//ENABLE/DISABLE TESTIMONIAL SECTION
$wp_customize->add_setting('constructionarc_testimonial_disable', array(
	'default' => 'enable',
	'transport' => 'postMessage',
	'sanitize_callback' => 'constructionarc_themes_sanitize_switch',    
));
$wp_customize->add_control(new constructionarc_Switch_Control($wp_customize, 'constructionarc_testimonial_disable', array(
	'label' => esc_html__('Section', 'construction-arc'),
	'section' => 'constructionarc_testimonial_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_testimonial_section_nav', array(
        'transport' => 'postMessage',
        'sanitize_callback' => 'wp_kses_post',
    ));
    $wp_customize->add_control(new constructionarc_Custom_Control_Tab($wp_customize, 'constructionarc_testimonial_section_nav', array(
        'type' => 'tab',
        'section' => 'constructionarc_testimonial_section',
        'priority' => 1,
        'buttons' => array(
            array(
                'name' => esc_html__('Content', 'construction-arc'),
                'fields' => array(
                    'constructionarc_testimonial_title',
                    'constructionarc_testimonial_super_title',
                    'constructionarc_testimonial_title_style_heading',
                    'constructionarc_testimonial_title_style',
                    'constructionarc_testimonial_title_align',
                    'constructionarc_testimonial_type_heading',
                    'constructionarc_testimonial_type',
                    'constructionarc_testimonial_page',
                    'constructionarc_testimonial_advance_settings',
                    'constructionarc_testimonial_review_link',
                    'constructionarc_testimonial_layout',
                    'constructionarc_testimonial_display_style',
                ),
                'active' => true,
            ),
            array(
                'name' => esc_html__('Style', 'construction-arc'),
                'fields' => array(
                ),
            ),
            array(
                'name' => esc_html__('Advanced', 'construction-arc'),
                'fields' => array(
                    'constructionarc_testimonial_bg_type',
                    'constructionarc_testimonial_bg_color',
                    'constructionarc_testimonial_bg_image',
                    'constructionarc_testimonial_overlay_color',
                    'constructionarc_testimonial_padding',
                    'constructionarc_testimonial_cs_seperator',
                ),
            ),
        ),
    )));

    $wp_customize->add_setting('constructionarc_testimonial_super_title', array(
        'transport' => 'postMessage',
        'sanitize_callback'	=> 'sanitize_text_field'		
    ));
    $wp_customize->add_control('constructionarc_testimonial_super_title', array(
        'label'	   => esc_html__('Super Title','construction-arc'),
        'section'  => 'constructionarc_testimonial_section',
        'type'	   => 'text',
    ));
   
    $wp_customize->add_setting('constructionarc_testimonial_title', array(
        'transport' => 'postMessage',
        'sanitize_callback'	=> 'sanitize_text_field'		
    ));
    $wp_customize->add_control('constructionarc_testimonial_title', array(
        'label'	   => esc_html__('Title','construction-arc'),
        'section'  => 'constructionarc_testimonial_section',
        'type'	   => 'text',
    ));

    $wp_customize->add_setting('constructionarc_testimonial_title_align', array(
        'default' => 'text-center',
        'sanitize_callback' => 'constructionarc_themes_sanitize_select',
        'transport' => 'postMessage'
    ));
    $wp_customize->add_control(
        new constructionarc_Custom_Control_Buttonset( $wp_customize, 'constructionarc_testimonial_title_align',
            array(
                'choices'  => array(
                    'text-left' => esc_html__('Left', 'construction-arc'),
                    'text-center' => esc_html__('Center', 'construction-arc'),
                    'text-right' => esc_html__('Right', 'construction-arc'),
                ),
                'label'    => esc_html__( 'Alignment', 'construction-arc' ),
                'section'  => 'constructionarc_testimonial_section',
            )
        )
    );
   
    $wp_customize->add_setting('constructionarc_testimonial_title_style_heading', array(
        'sanitize_callback' => 'sanitize_text_field',
        'transport' => 'postMessage',
    ));
    $wp_customize->add_control(new constructionarc_Customize_Heading($wp_customize, 'constructionarc_testimonial_title_style_heading', array(
        'section' => 'constructionarc_testimonial_section',
        'label' => esc_html__('Section Title Style', 'construction-arc')
    )));

    $wp_customize->add_setting('constructionarc_testimonial_title_style', array(
        'default' => 'style1',
        'transport' => 'postMessage',
        'sanitize_callback' => 'constructionarc_themes_sanitize_select'         
    ));
    $wp_customize->add_control('constructionarc_testimonial_title_style', array(
        'section' => 'constructionarc_testimonial_section',
        'type'    => 'select',
        'choices' => array(
            'style1' => esc_html__('Style 1','construction-arc'),
            'style2' => esc_html__('Style 2','construction-arc'),			
            'style3' => esc_html__('Style 3','construction-arc'),		
        )
    ));

   
    $wp_customize->add_setting('constructionarc_testimonial_type_heading', array(
        'sanitize_callback' => 'sanitize_text_field',
        'transport' => 'postMessage',
    ));
    $wp_customize->add_control(new constructionarc_Customize_Heading($wp_customize, 'constructionarc_testimonial_type_heading', array(
        'section' => 'constructionarc_testimonial_section',
        'label' => esc_html__('Select Type', 'construction-arc')
    )));

    $wp_customize->add_setting('constructionarc_testimonial_type', array(
        'default' => 'default',
        'transport' => 'postMessage',
        'sanitize_callback' => 'constructionarc_themes_sanitize_select'
    ));
    $wp_customize->add_control('constructionarc_testimonial_type', array(
        'section' => 'constructionarc_testimonial_section',
        'type' => 'radio',
        'choices' => array(
            'default' => esc_html__('Default', 'construction-arc'),
            'advance' => esc_html__('Advanced', 'construction-arc')
        )
    ));

    $wp_customize->add_setting('constructionarc_testimonial_page', array(
        'transport' => 'postMessage',
        'sanitize_callback' => 'constructionarc_themes_sanitize_repeater',		
        'default' => json_encode(array(
            array(
                'testimonial_page' => '',
                'designation'   =>'',
                'rating'    => ''
            )
        ))
    ));
    $wp_customize->add_control(new constructionarc_Themes_Repeater_Control( $wp_customize, 'constructionarc_testimonial_page', 
        array(
            'label' 	   => esc_html__('Default Testimonial Settings', 'construction-arc'),
            'section' 	   => 'constructionarc_testimonial_section',
            'settings' 	   => "constructionarc_testimonial_page",
            'box_label' => esc_html__('Testimonial Item', 'construction-arc'),
            'add_label' => esc_html__('Add New', 'construction-arc'),
            'limit' => 6,
        ),
        array(
            'testimonial_page' => array(
                'type' => 'select',
                'label' => esc_html__('Select Page', 'construction-arc'),
                'options' => $pages
            ),
            'designation' => array(
                'type' => 'text',
                'label' => esc_html__('Designation', 'construction-arc'),
                'default' => ''
            ),
            'rating' => array(
                'type' => 'number',
                'label' => esc_html__('Rating', 'construction-arc'),
                'default' => '5'
            )
        )
    ));

    $wp_customize->add_setting("constructionarc_testimonial_advance_settings", array(
        'transport' => 'postMessage',
        'sanitize_callback' => 'constructionarc_themes_sanitize_repeater',		
        'default' => json_encode(array(
            array(
                'block_image'      => '',
                'block_title'      => '',
                'block_designation' => '',
                'block_text'    => '',
                'block_rating'     => '',
            )
        ))
    ));
    $wp_customize->add_control(new constructionarc_Themes_Repeater_Control( $wp_customize, "constructionarc_testimonial_advance_settings", 
        array(
            'label' 	   => esc_html__('Advance Testimonial Settings', 'construction-arc'),
            'section' 	   => "constructionarc_testimonial_section",
            'settings' 	   => "constructionarc_testimonial_advance_settings",
            'box_label' => esc_html__('Testimonial Item', 'construction-arc'),
            'add_label' => esc_html__('Add New', 'construction-arc'),
            'limit' => 6,
        ),
        array(
            'block_image' => array(
                'type' => 'upload',
                'label' => __("Upload Image", 'construction-arc'),
            ),
            'block_title' => array(
                'type' => 'text',
                'label' => __("Title", 'construction-arc'),
            ),
            'block_designation' => array(
                'type' => 'text',
                'label' => __("Designation", 'construction-arc'),
            ),
            'block_text' => array(
                'type' => 'textarea',
                'label' => __("Text", 'construction-arc'),
            ),
            'block_rating' => array(
                'type' => 'number',
                'label' => esc_html__('Rating', 'construction-arc'),
                'default' => ''
            )
        )
    ));

    $wp_customize->add_setting('constructionarc_testimonial_layout', array(
        'sanitize_callback' => 'constructionarc_themes_sanitize_options',
        'default' => 'style1',
        'transport' => 'postMessage'
    ));
    $wp_customize->add_control(new constructionarc_Selector($wp_customize, 'constructionarc_testimonial_layout', array(
        'section' => 'constructionarc_testimonial_section',
        'label' => esc_html__('Select Layout', 'construction-arc'),
        'options' => array(
            'style1' => get_template_directory_uri() . '/inc/customizer/images/testimonial-1.webp',
            'style2' => get_template_directory_uri() . '/inc/customizer/images/testimonial-2.webp',
        )
    )));

    $wp_customize->add_setting('constructionarc_testimonial_display_style', array(
        'default' => 'slide',
        'transport' => 'postMessage',
        'sanitize_callback' => 'constructionarc_themes_sanitize_select'         
    ));
    $wp_customize->add_control('constructionarc_testimonial_display_style', array(
        'section' => 'constructionarc_testimonial_section',
        'type'    => 'select',
        'label' => esc_html__('Display Style', 'construction-arc'),
        'choices' => array(
            'grid' => esc_html__('Grid','construction-arc'),
            'slide' => esc_html__('Slide','construction-arc'),			
        )
    ));

    $wp_customize->add_setting('constructionarc_testimonial_review_link', array(
        'transport' => 'postMessage',
        'sanitize_callback'	=> 'sanitize_text_field'		
    ));
    $wp_customize->add_control('constructionarc_testimonial_review_link', array(
        'label'	   => esc_html__('All Review Link','construction-arc'),
        'section'  => 'constructionarc_testimonial_section',
        'type'	   => 'text',
    ));

    $wp_customize->add_setting('constructionarc_pro_testimonial', array(
        'sanitize_callback' => 'constructionarc_sanitize_text'
    ));
    $wp_customize->add_control(new constructionarc_Themes_Upgrade_Text($wp_customize, 'constructionarc_pro_testimonial', array(
        'section' => 'constructionarc_testimonial_section',
        'label' => esc_html__('For More Settings,', 'construction-arc'),
        'choices' => array(
            esc_html__('(4+) Different Layout & Settings', 'construction-arc'),
            esc_html__('Add Unlimited Testimonial Items', 'construction-arc'),
            esc_html__('(5+) Different Section Title Style', '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_testimonial_refresh", array (
    'settings' => array( 
        'constructionarc_testimonial_disable',
        'constructionarc_testimonial_type',
        'constructionarc_testimonial_layout',
        'constructionarc_testimonial_display_style',
        'constructionarc_testimonial_page',
        'constructionarc_testimonial_advance_settings',
        'constructionarc_testimonial_review_link',
    ),
    'selector' => "#testimonial-section",
    'fallback_refresh' => true,
    'container_inclusive' => true,
    'render_callback' => function () {
        return get_template_part( 'section/section-testimonial' );
    }
));