<?php

function car_wash_services_remove_customize_register() {
    global $wp_customize;
   

    $wp_customize->remove_setting( 'automobile_hub_mail_text' );
    $wp_customize->remove_control( 'automobile_hub_mail_text' );

    $wp_customize->remove_setting( 'automobile_hub_call_text' );
    $wp_customize->remove_control( 'automobile_hub_call_text' );

    $wp_customize->remove_setting( 'automobile_hub_search_icon' );
    $wp_customize->remove_control( 'automobile_hub_search_icon' );
    
    $wp_customize->remove_setting( 'automobile_hub_tp_color_option_link' );
    $wp_customize->remove_control( 'automobile_hub_tp_color_option_link' );

    $wp_customize->remove_setting( 'automobile_hub_cart_option' );
    $wp_customize->remove_control( 'automobile_hub_cart_option' );

    $wp_customize->remove_setting( 'automobile_hub_cart_icon' );
    $wp_customize->remove_control( 'automobile_hub_cart_icon' );

    $wp_customize->remove_setting( 'automobile_hub_slider_icon' );
    $wp_customize->remove_control( 'automobile_hub_slider_icon' );
    
    $wp_customize->remove_setting( 'automobile_hub_about_icon' );
    $wp_customize->remove_control( 'automobile_hub_about_icon' );

    $wp_customize->remove_setting( 'automobile_hub_slider_content_layout' );
    $wp_customize->remove_control( 'automobile_hub_slider_content_layout' );

    $wp_customize->remove_setting( 'automobile_hub_slider_text' );
    $wp_customize->remove_control( 'automobile_hub_slider_text' );

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

if ( ! defined( 'CAR_WASH_SERVICES_TEXT' ) ) {
    define( 'CAR_WASH_SERVICES_TEXT', __( 'Car Wash Services Pro','car-wash-services' ));
}
if ( ! defined( 'CAR_WASH_SERVICES_BUY_TEXT' ) ) {
    define( 'CAR_WASH_SERVICES_BUY_TEXT', __( 'Upgrade Pro','car-wash-services' ));
}


add_action( 'customize_register', function( $manager ) {

// Load custom sections.
load_template( trailingslashit( get_template_directory() ) . '/inc/section-pro.php' );

    $manager->register_section_type( Automobile_Hub_Button::class );

    $manager->add_section(
        new Automobile_Hub_Button( $manager, 'automobile_hub_pro', [
            'title'       => esc_html( CAR_WASH_SERVICES_TEXT,'car-wash-services' ),
            'priority'    => 0,
            'button_text' => __( 'GET PREMIUM', 'car-wash-services' ),
            'button_url'  => esc_url( AUTOMOBILE_HUB_PRO_THEME_URL )
        ] )
    );

} );

function car_wash_services_customize_register( $wp_customize ) {

	// Pro Version
    class Car_Wash_Services_Customize_Pro_Version extends WP_Customize_Control {
        public $type = 'pro_options';

        public function render_content() {
            echo '<span>Unlock Premium <strong>'. esc_html( $this->label ) .'</strong>? </span>';
            echo '<a href="'. esc_url($this->description) .'" target="_blank">';
                echo '<span class="dashicons dashicons-info"></span>';
                echo '<strong> '. esc_html( CAR_WASH_SERVICES_BUY_TEXT,'car-wash-services' ) .'<strong></a>';
            echo '</a>';
        }
    }

    // Custom Controls
    function car_wash_services_sanitize_custom_control( $input ) {
        return $input;
    }

$wp_customize->register_control_type( 'Car_Wash_Service_Toggle_Control' );


	$wp_customize->add_setting('car_wash_services_slider_content_layout',array(
        'default' => 'CENTER-ALIGN',
        'sanitize_callback' => 'automobile_hub_sanitize_choices'
	));
	$wp_customize->add_control('car_wash_services_slider_content_layout',array(
        'type' => 'radio',
        'label'     => __('Slider Content Layout', 'car-wash-services'),
        'section' => 'automobile_hub_slider_section',
        'choices' => array(
        	'CENTER-ALIGN' => __('CENTER-ALIGN','car-wash-services'),
            'LEFT-ALIGN' => __('LEFT-ALIGN','car-wash-services'),        	
            'RIGHT-ALIGN' => __('RIGHT-ALIGN','car-wash-services'),
        ),
	) );

	//color option
    $wp_customize->add_setting( 'car_wash_services_tp_secondary_color_option', array(
	    'default' => '',
	    'sanitize_callback' => 'sanitize_hex_color',

  	));
  	$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'car_wash_services_tp_secondary_color_option', array(
			'label'     => __('Theme Secondary  Color', 'car-wash-services'),
	    'description' => __('It will change the complete theme secondary color in one click.', 'car-wash-services'),
	    'section' => 'automobile_hub_color_option',
	    'settings' => 'car_wash_services_tp_secondary_color_option',
  	)));

  	//Topbar section
	$wp_customize->add_setting('car_wash_services_location',array(
		'default'	=> '',
		'sanitize_callback'	=> 'sanitize_text_field'
	));
	$wp_customize->add_control('car_wash_services_location',array(
		'label'	=> __('Add Location','car-wash-services'),
		'section'	=> 'automobile_hub_topbar',
		'type'		=> 'text'
	));

	//Featured car section
	$wp_customize->add_section( 'car_wash_services_featured_car_section' , array(
    	'title'      => __( 'Servies Settings', 'car-wash-services' ),
		'panel' => 'automobile_hub_panel_id',
		'priority' => 4,
	) );

    $wp_customize->add_setting( 'car_wash_services_featured_car_show_hide', array(
		'default'           => true,
		'transport'         => 'refresh',
		'sanitize_callback' => 'automobile_hub_sanitize_checkbox',
	) );
	$wp_customize->add_control( new Car_Wash_Service_Toggle_Control( $wp_customize, 'car_wash_services_featured_car_show_hide', array(
		'label'       => esc_html__( 'Show / Hide section', 'car-wash-services' ),
		'section'     => 'car_wash_services_featured_car_section',
		'type'        => 'toggle',
		'settings'    => 'car_wash_services_featured_car_show_hide',
	) ) );

	$wp_customize->add_setting( 'car_wash_services_featured_sec_animation', array(
		'default'           => true,
		'transport'         => 'refresh',
		'sanitize_callback' => 'automobile_hub_sanitize_checkbox',
	) );
	$wp_customize->add_control( new Automobile_Hub_Toggle_Control( $wp_customize, 'car_wash_services_featured_sec_animation', array(
		'label'       => esc_html__( 'Show / Hide Featured Section Animation', 'car-wash-services' ),
		'section'     => 'car_wash_services_featured_car_section',
		'type'        => 'toggle',
		'settings'    => 'car_wash_services_featured_sec_animation',
	) ) );
	
	$wp_customize->add_setting('car_wash_services_featured_car_section_tittle',array(
		'default'	=> '',
		'sanitize_callback'	=> 'sanitize_text_field'
	));
	$wp_customize->add_control('car_wash_services_featured_car_section_tittle',array(
		'label'	=> __('Section Title','car-wash-services'),
		'section'	=> 'car_wash_services_featured_car_section',
		'type'		=> 'text'
	));
	$categories = get_categories();
	$cats = array();
	$i = 0;
	$car_wash_services_offer_cat[]= 'select';
	foreach($categories as $category){
		if($i==0){
			$default = $category->slug;
			$i++;
		}
		$car_wash_services_offer_cat[$category->slug] = $category->name;
	}
	$wp_customize->add_setting('car_wash_services_featured_car_section_category',array(
		'default'	=> 'select',
		'sanitize_callback' => 'automobile_hub_sanitize_choices',
	));
	$wp_customize->add_control('car_wash_services_featured_car_section_category',array(
		'type'    => 'select',
		'choices' => $car_wash_services_offer_cat,
		'label' => __('Select Category','car-wash-services'),
		'section' => 'car_wash_services_featured_car_section',
	));

	// Pro Version
    $wp_customize->add_setting( 'car_wash_services_services_pro_version_logo', array(
        'sanitize_callback' => 'car_wash_services_sanitize_custom_control'
    ));
    $wp_customize->add_control( new Car_Wash_Services_Customize_Pro_Version ( $wp_customize,'car_wash_services_services_pro_version_logo', array(
        'section'     => 'car_wash_services_featured_car_section',
        'type'        => 'pro_options',
        'label'       => esc_html__( 'Features ', 'car-wash-services' ),
        'description' => esc_url( AUTOMOBILE_HUB_PRO_THEME_URL ),
        'priority'    => 10,
    )));
}
add_action( 'customize_register', 'car_wash_services_customize_register' );
