<?php

/**
 * Trips Settings
 *
 * @package Travel Tour
 */
if ( class_exists( 'Wp_Travel_Engine' ) ) {
    add_action( 'customize_register', 'travel_tour_customize_register_best_tours_section' );
}
function travel_tour_customize_register_best_tours_section(  $wp_customize  ) {
    $wp_customize->add_section( 'travel_tour_best_tours_sections', array(
        'title'       => esc_html__( 'Trip Section', 'travel-tour' ),
        'description' => esc_html__( 'Trip Section :', 'travel-tour' ),
        'panel'       => 'travel_tour_homepage_panel',
        'priority'    => 5,
    ) );
    $wp_customize->add_setting( 'best_tours_display_option', array(
        'sanitize_callback' => 'travel_tour_sanitize_checkbox',
        'default'           => true,
    ) );
    $wp_customize->add_control( new Travel_Tour_Toggle_Control($wp_customize, 'best_tours_display_option', array(
        'label'    => esc_html__( 'Hide / Show', 'travel-tour' ),
        'section'  => 'travel_tour_best_tours_sections',
        'settings' => 'best_tours_display_option',
        'type'     => 'toggle',
    )) );
    $wp_customize->selective_refresh->add_partial( 'best_tours_display_option', array(
        'selector' => '.trips-list .container-xl',
    ) );
    $wp_customize->add_setting( 'best_tours_category', array(
        'capability'        => 'edit_theme_options',
        'sanitize_callback' => 'travel_tour_sanitize_category',
        'default'           => '',
    ) );
    $wp_customize->add_control( new Travel_Tour_Customize_Dropdown_Taxonomies_Control($wp_customize, 'best_tours_category', array(
        'label'    => esc_html__( 'Choose category', 'travel-tour' ),
        'section'  => 'travel_tour_best_tours_sections',
        'settings' => 'best_tours_category',
        'type'     => 'dropdown-taxonomies',
        'taxonomy' => 'trip_types',
    )) );
    $wp_customize->add_setting( 'best_tours_title', array(
        'sanitize_callback' => 'sanitize_text_field',
        'default'           => '',
    ) );
    $wp_customize->add_control( 'best_tours_title', array(
        'label'    => esc_html__( 'Title', 'travel-tour' ),
        'section'  => 'travel_tour_best_tours_sections',
        'settings' => 'best_tours_title',
        'type'     => 'text',
    ) );
    $wp_customize->add_setting( 'number_of_best_tours', array(
        'sanitize_callback' => 'sanitize_text_field',
        'default'           => 8,
    ) );
    $wp_customize->add_control( 'number_of_best_tours', array(
        'label'       => esc_html__( 'Number of posts', 'travel-tour' ),
        'section'     => 'travel_tour_best_tours_sections',
        'settings'    => 'number_of_best_tours',
        'type'        => 'text',
        'description' => 'put -1 for unlimited',
    ) );
    if ( fs_travel_tour()->is_free_plan() ) {
        $wp_customize->add_setting( 'travel_tour_best_tours_section_upgrade_to_pro', array(
            'sanitize_callback' => null,
        ) );
        $wp_customize->add_control( new Travel_Tour_Control_Upgrade_To_Pro($wp_customize, 'travel_tour_best_tours_section_upgrade_to_pro', array(
            'section'     => 'travel_tour_best_tours_sections',
            'settings'    => 'travel_tour_best_tours_section_upgrade_to_pro',
            'title'       => __( 'Choose the styling of your tours.', 'travel-tour' ),
            'items'       => array(
                'one' => array(
                    'title' => __( 'Select from four beautiful card layouts.', 'travel-tour' ),
                ),
            ),
            'button_url'  => esc_url( 'https://thebootstrapthemes.com/travel-tour/#free-vs-pro' ),
            'button_text' => __( 'Upgrade Now', 'travel-tour' ),
        )) );
    }
}
