<?php

$wp_customize->add_section('constructionarc_header_button_section', array(
    'title' => esc_html__('Header Button', 'construction-arc'),
    'panel' => 'constructionarc_header_settings'
));

$wp_customize->add_setting('constructionarc_header_button_enable', array(
    'sanitize_callback' => 'constructionarc_themes_sanitize_text',
    'default' => 'enable',
    'transport' => 'postMessage',
    'priority' => -1,
));
$wp_customize->add_control(new constructionarc_Switch_Control($wp_customize, 'constructionarc_header_button_enable', array(
    'section' => 'constructionarc_header_button_section',
    'label' => esc_html__('Enable', 'construction-arc'),
    'switch_label' => array(
        'enable' => esc_html__('Yes', 'construction-arc'),
        'disable' => esc_html__('No', 'construction-arc')
    ),
    'class' => 'switch-section'
)));


$wp_customize->add_setting('constructionarc_header_button_nav', array(
    'transport' => 'postMessage',
    'sanitize_callback' => 'wp_kses_post',
    'priority' => -1,
));
$wp_customize->add_control(new constructionarc_Custom_Control_Tab($wp_customize, 'constructionarc_header_button_nav', array(
    'type' => 'tab',
    'section' => 'constructionarc_header_button_section',
    'buttons' => array(
        array(
            'name' => esc_html__('Content', 'construction-arc'),
            'fields' => array(
                'constructionarc_button_style',
                'constructionarc_hb_icon',
                'constructionarc_hb_title',
                'constructionarc_hb_text',
                'constructionarc_hb_link',
            ),
            'active' => true,
        ),
        array(
            'name' => esc_html__('Style', 'construction-arc'),
            'fields' => array(
                'constructionarc_header_button_bg_color',
                'constructionarc_header_button_color'
            ),
        )
    ),
)));


$wp_customize->add_setting('constructionarc_button_style', array(
    'sanitize_callback' => 'constructionarc_themes_sanitize_text',
    'default' => 'disable',
));
$wp_customize->add_control(new constructionarc_Switch_Control($wp_customize, 'constructionarc_button_style', array(
    'section' => 'constructionarc_header_button_section',
    'label' => esc_html__('Button Style', 'construction-arc'),
    'switch_label' => array(
        'enable' => esc_html__('Style 1', 'construction-arc'),
        'disable' => esc_html__('Style 2', 'construction-arc')
    ),
    'class' => 'button-style'
)));

$wp_customize->add_setting('constructionarc_hb_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_hb_icon', array(
    'section' => 'constructionarc_header_button_section',
    'label' => esc_html__('Icon', 'construction-arc')
)));


$wp_customize->add_setting('constructionarc_hb_title', array(
    'default' => esc_html__('Book Now', 'construction-arc'),
    'sanitize_callback' => 'constructionarc_themes_sanitize_text',
    'transport' => 'postMessage'
));
$wp_customize->add_control('constructionarc_hb_title', array(
    'section' => 'constructionarc_header_button_section',
    'type' => 'text',
    'label' => esc_html__('Title', 'construction-arc')
));

$wp_customize->add_setting('constructionarc_hb_text', array(
    'default' => '(5593)-236-8009',
    'sanitize_callback' => 'constructionarc_themes_sanitize_text',
    'transport' => 'postMessage'
));
$wp_customize->add_control('constructionarc_hb_text', array(
    'section' => 'constructionarc_header_button_section',
    'type' => 'text',
    'label' => esc_html__('Text', 'construction-arc')
));

$wp_customize->add_setting('constructionarc_hb_link', array(
    'default' => '#',
    'sanitize_callback' => 'constructionarc_themes_sanitize_text',
    'transport' => 'postMessage'
));
$wp_customize->add_control('constructionarc_hb_link', array(
    'section' => 'constructionarc_header_button_section',
    'type' => 'text',
    'label' => esc_html__('Link', 'construction-arc')
));


$wp_customize->add_setting('constructionarc_header_button_bg_color', array(
    'sanitize_callback' => 'constructionarc_themes_sanitize_color_alpha',
    'transport' => 'postMessage'
));
$wp_customize->add_control(new constructionarc_Alpha_Color_Control($wp_customize, "constructionarc_header_button_bg_color", array(
    'section' => "constructionarc_header_button_section",
    'label' => esc_html__('Background', 'construction-arc')
)));

$wp_customize->add_setting('constructionarc_header_button_color', array(
    'sanitize_callback' => 'constructionarc_themes_sanitize_color_alpha',
    'transport' => 'postMessage'
));
$wp_customize->add_control(new constructionarc_Alpha_Color_Control($wp_customize, "constructionarc_header_button_color", array(
    'section' => "constructionarc_header_button_section",
    'label' => esc_html__('Color', 'construction-arc')
)));

$wp_customize->selective_refresh->add_partial( 'constructionarc_header_button_refresh', array (
    'settings' => array( 
        'constructionarc_header_button_enable',
        'constructionarc_button_style',
        'constructionarc_hb_icon',
     ),
     'selector' => '#masthead',
     'container_inclusive' => true,
     'render_callback' => function () {
         $layout = get_theme_mod('constructionarc_header_layout','layout_two');
         return get_template_part('header/header', str_replace("layout_","", $layout));
     }
));