<?php

$wp_customize->add_section(new constructionarc_Toggle_Section($wp_customize, 'constructionarc_counter_section', array(
    'title'		=> 	esc_html__('Counter Section','construction-arc'),
    'panel'		=> 'constructionarc_frontpage_settings',
    'priority'  => constructionarc_themes_get_section_position('constructionarc_counter_section'),
    'hiding_control' => 'constructionarc_counter_disable'
)));

//ENABLE/DISABLE COUNTER SECTION
$wp_customize->add_setting('constructionarc_counter_disable', array(
	'default' => 'disable',
	'transport' => 'postMessage',
	'sanitize_callback' => 'constructionarc_themes_sanitize_switch',    
));
$wp_customize->add_control(new constructionarc_Switch_Control($wp_customize, 'constructionarc_counter_disable', array(
	'label' => esc_html__('Section', 'construction-arc'),
	'section' => 'constructionarc_counter_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_counter_section_nav', array(
        'transport' => 'postMessage',
        'sanitize_callback' => 'wp_kses_post',
    ));
    $wp_customize->add_control(new constructionarc_Custom_Control_Tab($wp_customize, 'constructionarc_counter_section_nav', array(
        'type' => 'tab',
        'section' => 'constructionarc_counter_section',
        'priority' => 1,
        'buttons' => array(
            array(
                'name' => esc_html__('Content', 'construction-arc'),
                'fields' => array(
                    'constructionarc_counter_super_title',
                    'constructionarc_counter_title',
                    'constructionarc_counter_title_style_heading',
                    'constructionarc_counter_title_style',
                    'constructionarc_counter_title_align',
                    'constructionarc_counter',
                    'constructionarc_counter_style',
                    'constructionarc_counter_display_style',
                    'constructionarc_counter_icon_disable',
                    'constructionarc_counter_col',
                ),
                'active' => true,
            ),
            array(
                'name' => esc_html__('Style', 'construction-arc'),
                'fields' => array(
                ),
            ),
            array(
                'name' => esc_html__('Advanced', 'construction-arc'),
                'fields' => array(
                    'constructionarc_counter_bg_type',
                    'constructionarc_counter_bg_color',
                    'constructionarc_counter_bg_image',
                    'constructionarc_counter_overlay_color',
                    'constructionarc_counter_padding',
                	'constructionarc_counter_cs_seperator',
                ),
            ),
        ),
    )));

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

    $wp_customize->add_setting('constructionarc_counter_title', array(
        'transport' => 'postMessage',
        'sanitize_callback'	=> 'sanitize_text_field'		
    ));
    $wp_customize->add_control('constructionarc_counter_title', array(
        'label'	   => esc_html__('Title','construction-arc'),
        'section'  => 'constructionarc_counter_section',
        'type'	   => 'text',
    ));
    
    $wp_customize->add_setting('constructionarc_counter_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_counter_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_counter_section',
                'settings' => 'constructionarc_counter_title_align',
            )
        )
    );

    $wp_customize->add_setting('constructionarc_counter_title_style_heading', array(
        'sanitize_callback' => 'sanitize_text_field',
        'transport' => 'postMessage',
    ));
    $wp_customize->add_control(new constructionarc_Customize_Heading($wp_customize, 'constructionarc_counter_title_style_heading', array(
        'section' => 'constructionarc_counter_section',
        'label' => esc_html__('Section Title Style', 'construction-arc')
    )));

    $wp_customize->add_setting('constructionarc_counter_title_style', array(
        'default' => 'style1',
        'transport' => 'postMessage',
        'sanitize_callback' => 'constructionarc_themes_sanitize_select'         
    ));
    $wp_customize->add_control('constructionarc_counter_title_style', array(
        'section' => 'constructionarc_counter_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_counter', array(
        'transport' => 'postMessage',
        'sanitize_callback' => 'constructionarc_themes_sanitize_repeater',	
        'default' => json_encode(array(
            array(
                'counter_icon'  =>'',
                'counter_title'  =>'',
                'counter_number'  =>'',	          
                'counter_suffix' => ''
            )
        ))
    ));
    $wp_customize->add_control(new constructionarc_Themes_Repeater_Control( $wp_customize, 
        'constructionarc_counter', 
        array(
            'label' 	   => esc_html__('Counter Settings', 'construction-arc'),
            'section' 	   => 'constructionarc_counter_section',
            'settings' 	   => 'constructionarc_counter',
            'box_label' => esc_html__('Counter Item', 'construction-arc'),
            'add_label' => esc_html__('Add New', 'construction-arc'),
             'limit' => 6,
        ),
        array(
            'counter_icon' => array(
                'type' => 'icon',
                'label' => esc_html__('Choose Icon', 'construction-arc'),
                'default' => 'fa fa-cogs'
            ),
            'counter_title' => array(
                'type' => 'text',
                'label' => esc_html__('Title', 'construction-arc'),
                'default' => ''
            ),
            'counter_number' => array(
                'type' => 'number',
                'label' => esc_html__('Ending Number', 'construction-arc'),
                'default' => ''
            ),
            'counter_suffix' => array(
                'type' => 'text',
                'label' => esc_html__('Suffix', 'construction-arc'),
                'default' => ''
            ),
        )
    ));

    $wp_customize->add_setting('constructionarc_counter_style', array(
        'sanitize_callback' => 'constructionarc_themes_sanitize_select',     
        'default' => 'style2',
        'transport' => 'postMessage',
    ));
    $wp_customize->add_control('constructionarc_counter_style', array(
        'label' => esc_html__('Select Layout', 'construction-arc'),
        'section' => 'constructionarc_counter_section',
        'type' => 'select',
        'choices' => array(
            'style1' => esc_html__('Layout One' , 'construction-arc'),
            'style2' => esc_html__('Layout Two' ,'construction-arc'),
            'style3' => esc_html__('Layout Three' ,'construction-arc'),
        )
    ));

    $wp_customize->add_setting('constructionarc_counter_display_style', array(
        'default' => 'above',
        'sanitize_callback' => 'constructionarc_themes_sanitize_select',
        'transport' => 'postMessage'
    ));
    $wp_customize->add_control(
        new constructionarc_Custom_Control_Buttonset( $wp_customize, 'constructionarc_counter_display_style',
            array(
                'choices'  => array(
                    'left' => esc_html__('Left', 'construction-arc'),
                    'right' => esc_html__('Right', 'construction-arc'),
                    'above' => esc_html__('Top', 'construction-arc'),
                    'below' => esc_html__('Below', 'construction-arc'),
                ),
                'label'    => esc_html__( 'Display Position', 'construction-arc' ),
                'section'  => 'constructionarc_counter_section',
            )
        )
    );

    $wp_customize->add_setting('constructionarc_counter_icon_disable', array(
        'default' => 'enable',
        'transport' => 'postMessage',
        'sanitize_callback' => 'constructionarc_themes_sanitize_switch',     
    ));
    $wp_customize->add_control(new constructionarc_Switch_Control($wp_customize, 'constructionarc_counter_icon_disable', array(
        'label' => esc_html__('Counter Icon', 'construction-arc'),
        'section' => 'constructionarc_counter_section',
        'switch_label' => array(
            'enable' => esc_html__('Enable', 'construction-arc'),
            'disable' => esc_html__('Disable', 'construction-arc'),
        ),
    )));

    $wp_customize->add_setting('constructionarc_counter_col', array(
        'sanitize_callback' => 'absint',
        'default' => 3,
        'transport' => 'postMessage'
    ));
    $wp_customize->add_control(new constructionarc_Themes_Range_Control($wp_customize, 'constructionarc_counter_col', array(
        'section' => 'constructionarc_counter_section',
        'label' => esc_html__('No of Column(s)', 'construction-arc'),
        'input_attrs' => array(
            'min' => 1,
            'max' => 6,
            'step' => 1,
        )
    )));

    $wp_customize->add_setting('constructionarc_pro_counter', array(
        'sanitize_callback' => 'constructionarc_sanitize_text'
    ));
    $wp_customize->add_control(new constructionarc_Themes_Upgrade_Text($wp_customize, 'constructionarc_pro_counter', array(
        'section' => 'constructionarc_counter_section',
        'label' => esc_html__('For More Settings,', 'construction-arc'),
        'choices' => array(
            esc_html__('Different Layout & Settings', 'construction-arc'),
            esc_html__('Add Unlimited Counter Items', 'construction-arc'),
            esc_html__('(5+) Different Section Title Style', 'construction-arc'),
            esc_html__('Advanced Counter Items Settings', 'construction-arc'),
            esc_html__('Counter Display Different Position', '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_counter_section_refresh", array (
    'settings' => array(
        'constructionarc_counter_disable',
        'constructionarc_counter',
        'constructionarc_counter_style',
        'constructionarc_counter_col',
    ),
    'selector' => "#counter-section",
    'fallback_refresh' => true,
    'container_inclusive' => true,
    'render_callback' => function () {
        return get_template_part( 'section/section-counter' );
    }
));