<?php

function car_paint_job_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_footer_widget_image' );
    $wp_customize->remove_control( 'automobile_hub_footer_widget_image' );

    $wp_customize->remove_setting( 'automobile_hub_tp_footer_bg_color_option' );
    $wp_customize->remove_control( 'automobile_hub_tp_footer_bg_color_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_tp_body_layout_settings' );
    $wp_customize->remove_control( 'automobile_hub_tp_body_layout_settings' );

    $wp_customize->remove_setting( 'automobile_hub_tp_color_option_link' );
    $wp_customize->remove_control( 'automobile_hub_tp_color_option_link' );
}
add_action( 'customize_register', 'car_paint_job_remove_customize_register', 11 );


if ( ! defined( 'CAR_PAINT_JOB_TEXT' ) ) {
    define( 'CAR_PAINT_JOB_TEXT', __( 'Auto Car Care Pro','car-paint-job' ));
}
if ( ! defined( 'CAR_PAINT_JOB_BUY_TEXT' ) ) {
    define( 'CAR_PAINT_JOB_BUY_TEXT', __( 'Upgrade Pro','car-paint-job' ));
}


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_PAINT_JOB_TEXT,'car-paint-job' ),
            'priority'    => 0,
            'button_text' => __( 'GET PREMIUM', 'car-paint-job' ),
            'button_url'  => esc_url( AUTOMOBILE_HUB_PRO_THEME_URL )
        ] )
    );

} );

function car_paint_job_customize_register( $wp_customize ) {

	// Pro Version
    class Car_Paint_Job_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_PAINT_JOB_BUY_TEXT,'car-paint-job' ) .'<strong></a>';
            echo '</a>';
        }
    }

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

	$wp_customize->add_setting( 'car_paint_job_paint_job_arrows', array(
		'default'           => true,
		'transport'         => 'refresh',
		'sanitize_callback' => 'automobile_hub_sanitize_checkbox',
	) );
	$wp_customize->add_control( new Automobile_Hub_Toggle_Control( $wp_customize, 'car_paint_job_paint_job_arrows', array(
		'label'       => esc_html__( 'Show / Hide Car Paint Job Section', 'automobile-hub' ),
		'priority' => 1,
		'section'     => 'car_paint_job_featured_car_section',
		'type'        => 'toggle',
		'settings'    => 'car_paint_job_paint_job_arrows',
	) ) );

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

	$wp_customize->add_setting('car_paint_job_location',array(
		'default'	=> '',
		'sanitize_callback'	=> 'sanitize_text_field'
	));
	$wp_customize->add_control('car_paint_job_location',array(
		'label'	=> __('Add Location','car-paint-job'),
		'section'	=> 'automobile_hub_topbar',
		'type'		=> 'text'
	));

	//featured car section
    $wp_customize->add_section( 'car_paint_job_featured_car_section' , array(
    	'title'      => __( 'Car Paint Job Services Settings', 'car-paint-job' ),
		'panel' => 'automobile_hub_panel_id',
		'priority' => 4,
	) );

	$wp_customize->add_setting( 'car_paint_job_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_paint_job_featured_sec_animation', array(
		'label'       => esc_html__( 'Show / Hide Slider Section Animation', 'car-paint-job' ),
		'section'     => 'car_paint_job_featured_car_section',
		'type'        => 'toggle',
		'settings'    => 'car_paint_job_featured_sec_animation',
	) ) );

	$wp_customize->add_setting('car_paint_job_featured_car_section_tittle',array(
		'default'	=> '',
		'sanitize_callback'	=> 'sanitize_text_field'
	));
	$wp_customize->add_control('car_paint_job_featured_car_section_tittle',array(
		'label'	=> __('Section Title','car-paint-job'),
		'section'	=> 'car_paint_job_featured_car_section',
		'type'		=> 'text'
	));

	$categories = get_categories();
	$cats = array();
	$i = 0;
	$car_paint_job_offer_cat[]= 'select';
	foreach($categories as $category){
		if($i==0){
			$default = $category->slug;
			$i++;
		}
		$car_paint_job_offer_cat[$category->slug] = $category->name;
	}

	$wp_customize->add_setting('car_paint_job_featured_car_section_category',array(
		'default'	=> 'select',
		'sanitize_callback' => 'automobile_hub_sanitize_choices',
	));
	$wp_customize->add_control('car_paint_job_featured_car_section_category',array(
		'type'    => 'select',
		'choices' => $car_paint_job_offer_cat,
		'label' => __('Select Category','car-paint-job'),
		'section' => 'car_paint_job_featured_car_section',
	));

	// Pro Version
    $wp_customize->add_setting( 'car_paint_job_services_pro_version_logo', array(
        'sanitize_callback' => 'car_paint_job_sanitize_custom_control'
    ));
    $wp_customize->add_control( new Car_Paint_Job_Customize_Pro_Version ( $wp_customize,'car_paint_job_services_pro_version_logo', array(
        'section'     => 'car_paint_job_featured_car_section',
        'type'        => 'pro_options',
        'label'       => esc_html__( 'Features ', 'car-paint-job' ),
        'description' => esc_url( AUTOMOBILE_HUB_PRO_THEME_URL ),
        'priority'    => 10,
    )));
}
add_action( 'customize_register', 'car_paint_job_customize_register' );
