<?php

function travel_vlogger_remove_customize_register() {
    global $wp_customize;
    $wp_customize->remove_section( 'adventure_travelling_slider_section' );

    $wp_customize->remove_section( 'adventure_travelling_topbar' );

    $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_slider_buttom_mob' );
    $wp_customize->remove_control( 'adventure_travelling_slider_buttom_mob' );
    
    $wp_customize->remove_setting( 'adventure_travelling_menu_font_size' );
    $wp_customize->remove_control( 'adventure_travelling_menu_font_size' );

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

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

if ( ! defined( 'TRAVEL_VLOGGER_TEXT' ) ) {
    define( 'TRAVEL_VLOGGER_TEXT', __( 'Travel Vlogger Pro','travel-vlogger' ));
}
if ( ! defined( 'TRAVEL_VLOGGER_BUY_TEXT' ) ) {
    define( 'TRAVEL_VLOGGER_BUY_TEXT', __( 'Upgrade Pro','travel-vlogger' ));
}


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_VLOGGER_TEXT,'travel-vlogger' ),
            'priority'    => 0,
            'button_text' => __( 'GET PREMIUM', 'travel-vlogger' ),
            'button_url'  => esc_url( ADVENTURE_TRAVELLING_PRO_THEME_URL )
        ] )
    );

} );

function travel_vlogger_customize_register( $wp_customize ) {

    // Pro Version
    class travel_vlogger_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_VLOGGER_BUY_TEXT,'travel-vlogger' ) .'<strong></a>';
            echo '</a>';
        }
    }

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

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

    $wp_customize->add_setting( 'travel_vlogger_search_icon', array(
        'default'           => true,
        'transport'         => 'refresh',
        'sanitize_callback' => 'adventure_travelling_sanitize_checkbox',
    ) );
    $wp_customize->add_control( new Adventure_Travelling_Toggle_Control( $wp_customize, 'travel_vlogger_search_icon', array(
        'label'       => esc_html__( 'Show / Hide Search Option','travel-vlogger'),
        'section'     => 'adventure_travelling_social_media',
        'type'        => 'toggle',
        'settings'    => 'travel_vlogger_search_icon',
    ) ) );

    // Slider Section
    $wp_customize->add_section( 'travel_vlogger_slider_post_section' , array(
        'title'      => __( 'Post Slider Settings', 'travel-vlogger' ),
        'panel' => 'adventure_travelling_panel_id',
        'priority' => 3,
    ) );

    $wp_customize->add_setting( 'travel_vlogger_slider_show_hide', array(
        'default'           => true,
        'transport'         => 'refresh',
        'sanitize_callback' => 'adventure_travelling_sanitize_checkbox',
    ) );
    $wp_customize->add_control( new Travel_Vlogger_Toggle_Control( $wp_customize, 'travel_vlogger_slider_show_hide', array(
        'label'       => esc_html__( 'Show / Hide Slider section', 'travel-vlogger' ),
        'section'     => 'travel_vlogger_slider_post_section',
        'type'        => 'toggle',
        'settings'    => 'travel_vlogger_slider_show_hide',
    ) ) );

    $wp_customize->add_setting( 'travel_vlogger_slider_animation', array(
        'default'           => true,
        'transport'         => 'refresh',
        'sanitize_callback' => 'adventure_travelling_sanitize_checkbox',
    ) );
    $wp_customize->add_control( new adventure_travelling_Toggle_Control( $wp_customize, 'travel_vlogger_slider_animation', array(
        'label'       => esc_html__( 'Show / Hide Animation', 'travel-vlogger' ),
        'section'     => 'travel_vlogger_slider_post_section',
        'type'        => 'toggle',
        'settings'    => 'travel_vlogger_slider_animation',
    ) ) );

    $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_vlogger_slider_section_category',array(
        'default'   => 'select',
        'sanitize_callback' => 'adventure_travelling_sanitize_choices',
    ));
    $wp_customize->add_control('travel_vlogger_slider_section_category',array(
        'type'    => 'select',
        'choices' => $offer_cat,
        'label' => __('Select Category','travel-vlogger'),
        'section' => 'travel_vlogger_slider_post_section',
    ));

    $wp_customize->add_setting( 'travel_vlogger_slider_remove_date', array(
        'default'           => true,
        'transport'         => 'refresh',
        'sanitize_callback' => 'adventure_travelling_sanitize_checkbox',
    ) );
    $wp_customize->add_control( new Adventure_Travelling_Toggle_Control( $wp_customize, 'travel_vlogger_slider_remove_date', array(
        'label'       => esc_html__( 'Show / Hide Date','travel-vlogger'),
        'section'     => 'travel_vlogger_slider_post_section',
        'type'        => 'toggle',
        'settings'    => 'travel_vlogger_slider_remove_date',
    ) ) );

    //Slider height
    $wp_customize->add_setting('travel_vlogger_slider_img_height',array(
        'default'=> '',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('travel_vlogger_slider_img_height',array(
        'label' => __('Slider Height','adventure-travelling'),
        'description'   => __('Add slider height in px(eg. 700px).','travel-vlogger'),
        'section'=> 'travel_vlogger_slider_post_section',
        'type'=> 'text'
    ));

    // Pro Version
    $wp_customize->add_setting( 'travel_vlogger_post_pro_version_logo', array(
        'sanitize_callback' => 'travel_vlogger_sanitize_custom_control'
    ));
    $wp_customize->add_control( new travel_vlogger_Customize_Pro_Version ( $wp_customize,'travel_vlogger_post_pro_version_logo', array(
        'section'     => 'travel_vlogger_slider_post_section',
        'type'        => 'pro_options',
        'label'       => esc_html__( 'Features ', 'travel-vlogger' ),
        'description' => esc_url( ADVENTURE_TRAVELLING_PRO_THEME_URL ),
    )));

    // Post Section
	$wp_customize->add_section( 'travel_vlogger_trip_offer_section' , array(
        'title'      => __( 'Explore Destination Settings', 'travel-vlogger' ),
        'panel' => 'adventure_travelling_panel_id',
        'priority' => 3,
    ) );

    $wp_customize->add_setting( 'travel_vlogger_offer_show_hide', array(
        'default'           => true,
        'transport'         => 'refresh',
        'sanitize_callback' => 'adventure_travelling_sanitize_checkbox',
    ) );
    $wp_customize->add_control( new Travel_Vlogger_Toggle_Control( $wp_customize, 'travel_vlogger_offer_show_hide', array(
        'label'       => esc_html__( 'Show / Hide section', 'travel-vlogger' ),
        'section'     => 'travel_vlogger_trip_offer_section',
        'type'        => 'toggle',
        'settings'    => 'travel_vlogger_offer_show_hide',
    ) ) );

    $wp_customize->add_setting( 'travel_vlogger_offer_show_animation', array(
        'default'           => true,
        'transport'         => 'refresh',
        'sanitize_callback' => 'adventure_travelling_sanitize_checkbox',
    ) );
    $wp_customize->add_control( new adventure_travelling_Toggle_Control( $wp_customize, 'travel_vlogger_offer_show_animation', array(
        'label'       => esc_html__( 'Show / Hide Animation', 'travel-vlogger' ),
        'section'     => 'travel_vlogger_trip_offer_section',
        'type'        => 'toggle',
        'settings'    => 'travel_vlogger_offer_show_animation',
    ) ) );

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

    $wp_customize->add_setting('travel_vlogger_offer_section_text',array(
        'default'   => '',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('travel_vlogger_offer_section_text',array(
        'label' => __('Section Description','travel-vlogger'),
        'section'   => 'travel_vlogger_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_vlogger_offer_section_category',array(
        'default'   => 'select',
        'sanitize_callback' => 'adventure_travelling_sanitize_choices',
    ));
    $wp_customize->add_control('travel_vlogger_offer_section_category',array(
        'type'    => 'select',
        'choices' => $offer_cat,
        'label' => __('Select Category','travel-vlogger'),
        'section' => 'travel_vlogger_trip_offer_section',
    ));

    $wp_customize->add_setting( 'travel_vlogger_latest_remove_date', array(
        'default'           => true,
        'transport'         => 'refresh',
        'sanitize_callback' => 'adventure_travelling_sanitize_checkbox',
    ) );
    $wp_customize->add_control( new Adventure_Travelling_Toggle_Control( $wp_customize, 'travel_vlogger_latest_remove_date', array(
        'label'       => esc_html__( 'Show / Hide Date','travel-vlogger'),
        'section'     => 'travel_vlogger_trip_offer_section',
        'type'        => 'toggle',
        'settings'    => 'travel_vlogger_latest_remove_date',
    ) ) );

    // Pro Version
    $wp_customize->add_setting( 'travel_vlogger_services_pro_version_logo', array(
        'sanitize_callback' => 'travel_vlogger_sanitize_custom_control'
    ));
    $wp_customize->add_control( new travel_vlogger_Customize_Pro_Version ( $wp_customize,'travel_vlogger_services_pro_version_logo', array(
        'section'     => 'travel_vlogger_trip_offer_section',
        'type'        => 'pro_options',
        'label'       => esc_html__( 'Features ', 'travel-vlogger' ),
        'description' => esc_url( ADVENTURE_TRAVELLING_PRO_THEME_URL ),
    )));

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