<?php

function travel_agent_remove_customize_register() {
    global $wp_customize;
    $wp_customize->remove_section( 'adventure_travelling_social_media' );

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

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

    $wp_customize->remove_setting( 'adventure_travelling_timming_icon' );
    $wp_customize->remove_control( 'adventure_travelling_timming_icon' );
    
    $wp_customize->remove_setting( 'adventure_travelling_location_icon' );
    $wp_customize->remove_control( 'adventure_travelling_location_icon' );
    
    $wp_customize->remove_setting( 'adventure_travelling_slider_content_layout' );
    $wp_customize->remove_control( 'adventure_travelling_slider_content_layout' );

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

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


    if ( ! defined( 'TRAVEL_AGENT_TEXT' ) ) {
        define( 'TRAVEL_AGENT_TEXT', __( 'Travel Hub Pro','travel-agent' ));
    }
    if ( ! defined( 'TRAVEL_AGENT_BUY_TEXT' ) ) {
        define( 'TRAVEL_AGENT_BUY_TEXT', __( 'Upgrade Pro','travel-agent' ));
    }


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

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

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

        $manager->add_section(
            new Adventure_Travelling_Button( $manager, 'adventure_travelling_pro', [
                'title'       => esc_html( TRAVEL_AGENT_TEXT,'travel-agent' ),
                'priority'    => 0,
                'button_text' => __( 'GET PREMIUM', 'travel-agent' ),
                'button_url'  => esc_url( ADVENTURE_TRAVELLING_PRO_THEME_URL )
            ] )
        );

    } );

function travel_agent_customize_register( $wp_customize ) {

    // Pro Version
    class Travel_Agent_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( TRAVEL_AGENT_BUY_TEXT,'travel-agent' ) .'<strong></a>';
            echo '</a>';
        }
    }

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

    // Register the custom control type.
    $wp_customize->register_control_type( 'Travel_Agent_Toggle_Control' );


    $wp_customize->add_setting('adventure_travelling_slider_content_layout',array(
        'default' => 'CENTER-ALIGN',
        'sanitize_callback' => 'adventure_travelling_sanitize_choices'
    ));
    $wp_customize->add_control('adventure_travelling_slider_content_layout',array(
        'type' => 'radio',
        'label'     => __('Slider Content Layout', 'adventure-travelling'),
        'section' => 'adventure_travelling_slider_section',
        'choices' => array(
            'CENTER-ALIGN' => __('CENTER-ALIGN','adventure-travelling'),
            'LEFT-ALIGN' => __('LEFT-ALIGN','adventure-travelling'),
            'RIGHT-ALIGN' => __('RIGHT-ALIGN','adventure-travelling'),
        ),
    ) );

    $wp_customize->add_setting('travel_agent_slider_content_layout',array(
        'default' => 'CENTER-ALIGN',
        'priority'=> 2,
        'sanitize_callback' => 'adventure_travelling_sanitize_choices'
    ));
    $wp_customize->add_control('travel_agent_slider_content_layout',array(
        'type' => 'radio',
        'label'     => __('Slider Content Layout', 'travel-agent'),
        'section' => 'adventure_travelling_slider_section',
        'choices' => array(
            'CENTER-ALIGN' => __('CENTER-ALIGN','travel-agent'),
            'LEFT-ALIGN' => __('LEFT-ALIGN','travel-agent'),
            'RIGHT-ALIGN' => __('RIGHT-ALIGN','travel-agent'),
        ),
    ) );

	$wp_customize->add_section( 'travel_agent_trip_offer_section' , array(
        'title'      => __( 'Latest Offer Settings', 'travel-agent' ),
        'panel' => 'adventure_travelling_panel_id',
        'priority' => 4,
    ) );

    $wp_customize->add_setting( 'travel_agent_offer_show_hide', array(
        'default'           => true,
        'transport'         => 'refresh',
        'sanitize_callback' => 'adventure_travelling_sanitize_checkbox',
    ) );
    $wp_customize->add_control( new Travel_Agent_Toggle_Control( $wp_customize, 'travel_agent_offer_show_hide', array(
        'label'       => esc_html__( 'Show / Hide section', 'travel-agent' ),
        'section'     => 'travel_agent_trip_offer_section',
        'type'        => 'toggle',
        'settings'    => 'travel_agent_offer_show_hide',
    ) ) );

    $wp_customize->add_setting('travel_agent_offer_section_short_title',array(
        'default'   => '',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('travel_agent_offer_section_short_title',array(
        'label' => __('Short Title','travel-agent'),
        'section'   => 'travel_agent_trip_offer_section',
        'type'      => 'text'
    ));

    $wp_customize->add_setting('travel_agent_offer_section_tittle',array(
        'default'   => '',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('travel_agent_offer_section_tittle',array(
        'label' => __('Section Title','travel-agent'),
        'section'   => 'travel_agent_trip_offer_section',
        'type'      => 'text'
    ));

    $wp_customize->add_setting('travel_agent_offer_section_text',array(
        'default'   => '',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('travel_agent_offer_section_text',array(
        'label' => __('Section Description','travel-agent'),
        'section'   => 'travel_agent_trip_offer_section',
        'type'      => 'text'
    ));
    $categories = get_categories();
    $cats = array();
    $i = 0;
    $offer_cat[]= 'select';
    foreach($categories as $category){
        if($i==0){
            $default = $category->slug;
            $i++;
        }
        $offer_cat[$category->slug] = $category->name;
    }
    
    $wp_customize->add_setting('travel_agent_offer_section_category',array(
        'default'   => 'select',
        'sanitize_callback' => 'adventure_travelling_sanitize_choices',
    ));
    $wp_customize->add_control('travel_agent_offer_section_category',array(
        'type'    => 'select',
        'choices' => $offer_cat,
        'label' => __('Select Category','travel-agent'),
        'section' => 'travel_agent_trip_offer_section',
    ));

    $wp_customize->add_setting('travel_agent_slider_top',array(
        'default'=> '',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('travel_agent_slider_top',array(
        'label' => __('Add Slider Top Text','adventure-travelling'),
        'section'=> 'adventure_travelling_slider_section',
        'type'=> 'text'
    ));

    // Pro Version
    $wp_customize->add_setting( 'travel_agent_services_pro_version_logo', array(
        'sanitize_callback' => 'travel_agent_sanitize_custom_control'
    ));
    $wp_customize->add_control( new Travel_Agent_Customize_Pro_Version ( $wp_customize,'travel_agent_services_pro_version_logo', array(
        'section'     => 'travel_agent_trip_offer_section',
        'type'        => 'pro_options',
        'label'       => esc_html__( 'Features ', 'travel-agent' ),
        'description' => esc_url( ADVENTURE_TRAVELLING_PRO_THEME_URL ),
    )));

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