<?php
function property_builder_remove_customize_register() {
    global $wp_customize;
    
    $wp_customize->remove_setting( 'construction_hub_slider_content_layout' );
    $wp_customize->remove_control( 'construction_hub_slider_content_layout' );

    $wp_customize->remove_setting( 'construction_hub_tp_color_option_link' );
    $wp_customize->remove_control( 'construction_hub_tp_color_option_link' );
    
    $wp_customize->remove_setting( 'construction_hub_slider_arrow' );
    $wp_customize->remove_control( 'construction_hub_slider_arrow' );

}
add_action( 'customize_register', 'property_builder_remove_customize_register', 11 );

function property_builder_customize_register( $wp_customize ) {

    $wp_customize->register_control_type( 'Property_Builder_Toggle_Control' );

    // 2nd color
    $wp_customize->add_setting( 'construction_hub_tp_color_option_sec', array(
        'default' => '#38615d',
        'sanitize_callback' => 'sanitize_hex_color'
    ));
    $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'construction_hub_tp_color_option_sec', array(
        'label'     => __('Theme Second Color', 'construction-hub'),
        'description' => __('It will change the complete theme color in one click.', 'construction-hub'),
        'section' => 'construction_hub_color_option',
        'settings' => 'construction_hub_tp_color_option_sec',
        'priority' => 20,
    )));

    // 3rd color
    $wp_customize->add_setting( 'construction_hub_tp_color_option_third', array(
        'default' => '#34b3a3',
        'sanitize_callback' => 'sanitize_hex_color'
    ));
    $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'construction_hub_tp_color_option_third', array(
        'label'     => __('Theme Third Color', 'construction-hub'),
        'description' => __('It will change the complete theme color in one click.', 'construction-hub'),
        'section' => 'construction_hub_color_option',
        'settings' => 'construction_hub_tp_color_option_third',
        'priority' => 30,
    )));

    $wp_customize->add_setting('property_builder_slider_content_layout',array(
        'default' => 'RIGHT-ALIGN',
        'sanitize_callback' => 'construction_hub_sanitize_choices'
    ));
    $wp_customize->add_control('property_builder_slider_content_layout',array(
        'type' => 'radio',
        'label'     => __('Slider Content Layout', 'property-builder'),
        'section' => 'construction_hub_slider_section',
        'choices' => array(
            'RIGHT-ALIGN' => __('RIGHT-ALIGN','property-builder'),
            'LEFT-ALIGN' => __('LEFT-ALIGN','property-builder'),
            'CENTER-ALIGN' => __('CENTER-ALIGN','property-builder'),
            
        ),
    ) );

    $wp_customize->add_setting( 'property_builder_show_hide_slider_section', array(
        'default'           => true,
        'transport'         => 'refresh',
        'sanitize_callback' => 'construction_hub_sanitize_checkbox',
    ) );
    $wp_customize->add_control( new Property_Builder_Toggle_Control( $wp_customize, 'property_builder_show_hide_slider_section', array(
        'priority' => 1,
        'label'       => esc_html__( 'Show / Hide Slider Section', 'property-builder' ),
        'section'     => 'construction_hub_slider_section',
        'type'        => 'toggle',
        'settings'    => 'property_builder_show_hide_slider_section',
    ) ) );

    $wp_customize->add_setting( 'property_builder_show_hide_contact_section', array(
        'default'           => true,
        'transport'         => 'refresh',
        'sanitize_callback' => 'construction_hub_sanitize_checkbox',
    ) );
    $wp_customize->add_control( new Property_Builder_Toggle_Control( $wp_customize, 'property_builder_show_hide_contact_section', array(
        'priority' => 2,
        'label'       => esc_html__( 'Show / Hide Contact Details', 'property-builder' ),
        'section'     => 'construction_hub_topbar',
        'type'        => 'toggle',
        'settings'    => 'property_builder_show_hide_contact_section',
    ) ) );

    $wp_customize->add_setting('property_builder_location_text',array(
        'default'=> '',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('property_builder_location_text',array(
        'priority' => 4,
        'label' => __('Add Location Text','property-builder'),
        'section'=> 'construction_hub_topbar',
        'type'=> 'text'
    ));

    $wp_customize->add_setting('property_builder_location',array(
        'default'=> '',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('property_builder_location',array(
        'label' => __('Add Location','property-builder'),
        'priority' => 6,
        'section'=> 'construction_hub_topbar',
        'type'=> 'text'
    ));

    $wp_customize->add_setting('property_builder_about_page_count',array(
        'default'=> '3',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('property_builder_about_page_count',array(
        'label' => __('Number of Projects','property-builder'),
        'section'=> 'construction_hub_about_section',
        'priority' => 3,
        'type'      => 'number',
        'input_attrs' => array(
          'step' => 1,
          'min'  => 0,
          'max'  => 3,
            ),
    ));

    $wp_customize->add_setting('construction_hub_slider_top_text',array(
        'default' => '',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('construction_hub_slider_top_text',array(
        'label' => __('Slider Top Text','construction-hub'),
        'section'   => 'construction_hub_slider_section',
        'priority' => 3,
        'type'      => 'text'
    ));

    $property_builder_count =  get_theme_mod('property_builder_about_page_count', '3');

    for ( $construction_hub_count = 1; $construction_hub_count <= $property_builder_count; $construction_hub_count++ ) {

        $wp_customize->add_setting( 'construction_hub_about_page' . $construction_hub_count, array(
            'default' => '',
            'sanitize_callback' => 'construction_hub_sanitize_dropdown_pages'
        ));
        $wp_customize->add_control( 'construction_hub_about_page' . $construction_hub_count, array(
            'label'    => __( 'Select Project Page', 'property-builder' ),
            'section'  => 'construction_hub_about_section',
            'priority' => 5,
            'type'     => 'dropdown-pages'
        ));
    }

    $wp_customize->add_setting('construction_hub_search_icon',array(
        'default' => true,
        'sanitize_callback' => 'construction_hub_sanitize_checkbox'
    ));
    $wp_customize->add_control('construction_hub_search_icon',array(
        'type' => 'checkbox',
        'priority' => 1,
        'label' => __('Show / Hide Search Option','property-builder'),
        'section' => 'construction_hub_topbar',
    ));

}
add_action( 'customize_register', 'property_builder_customize_register' );
