<?php

/**
 * Quick Info Settings
 *
 * @package Travel Tour
 */
add_action( 'customize_register', 'travel_tour_customize_register_info_section' );
function travel_tour_customize_register_info_section(  $wp_customize  ) {
    $wp_customize->add_section( 'travel_tour_info_section', array(
        'title'       => esc_html__( 'Quick Info Section', 'travel-tour' ),
        'description' => esc_html__( 'Quick Info section :', 'travel-tour' ),
        'panel'       => 'travel_tour_homepage_panel',
        'priority'    => 3,
    ) );
    $wp_customize->add_setting( 'travel_tour_info_section_display', array(
        'sanitize_callback' => 'travel_tour_sanitize_checkbox',
        'default'           => true,
    ) );
    $wp_customize->add_control( new Travel_Tour_Toggle_Control($wp_customize, 'travel_tour_info_section_display', array(
        'label'    => esc_html__( 'Hide / Show', 'travel-tour' ),
        'section'  => 'travel_tour_info_section',
        'settings' => 'travel_tour_info_section_display',
        'type'     => 'toggle',
    )) );
    $wp_customize->selective_refresh->add_partial( 'travel_tour_info_section_display', array(
        'selector' => '.info-section .container-xl',
    ) );
    $wp_customize->add_setting( 'travel_tour_info_section_title', array(
        'sanitize_callback' => 'sanitize_text_field',
        'default'           => '',
    ) );
    $wp_customize->add_control( 'travel_tour_info_section_title', array(
        'label'    => esc_html__( 'Title', 'travel-tour' ),
        'section'  => 'travel_tour_info_section',
        'settings' => 'travel_tour_info_section_title',
        'type'     => 'text',
    ) );
    $wp_customize->add_setting( new Travel_Tour_Repeater_Setting($wp_customize, 'travel_tour_quick_info_blocks', array(
        'default'           => '',
        'sanitize_callback' => array('Travel_Tour_Repeater_Setting', 'sanitize_repeater_setting'),
    )) );
    $wp_customize->add_control( new Travel_Tour_Control_Repeater($wp_customize, 'travel_tour_quick_info_blocks', array(
        'section'   => 'travel_tour_info_section',
        'settings'  => 'travel_tour_quick_info_blocks',
        'label'     => esc_html__( 'Add Info blocks', 'travel-tour' ),
        'row_label' => array(
            'type'  => 'field',
            'value' => esc_html__( 'Info Section', 'travel-tour' ),
            'field' => 'info_name',
        ),
        'fields'    => array(
            'info_name'      => array(
                'type'  => 'text',
                'label' => __( 'Title', 'travel-tour' ),
            ),
            'info_desc'      => array(
                'type'  => 'textarea',
                'label' => __( 'Description', 'travel-tour' ),
            ),
            'info_thumbnail' => array(
                'type'  => 'image',
                'label' => __( 'Thumbnail', 'travel-tour' ),
            ),
        ),
    )) );
    $wp_customize->add_setting( 'travel_tour_info_section_bg_color', array(
        'capability'        => 'edit_theme_options',
        'default'           => '#fff',
        'sanitize_callback' => 'travel_tour_sanitize_hex_color',
        'transport'         => 'refresh',
    ) );
    $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'travel_tour_info_section_bg_color', array(
        'label'    => esc_html__( 'Background Color', 'travel-tour' ),
        'section'  => 'travel_tour_info_section',
        'settings' => 'travel_tour_info_section_bg_color',
    )) );
    if ( fs_travel_tour()->is_free_plan() ) {
        $wp_customize->add_setting( 'travel_tour_info_section_upgrade_to_pro', array(
            'sanitize_callback' => null,
        ) );
        $wp_customize->add_control( new Travel_Tour_Control_Upgrade_To_Pro($wp_customize, 'travel_tour_info_section_upgrade_to_pro', array(
            'section'     => 'travel_tour_info_section',
            'settings'    => 'travel_tour_info_section_upgrade_to_pro',
            'title'       => __( 'Choose the styling of your info section.', 'travel-tour' ),
            'items'       => array(
                'one' => array(
                    'title' => __( 'Select from two beautiful info layouts.', 'travel-tour' ),
                ),
            ),
            'button_url'  => esc_url( 'https://thebootstrapthemes.com/travel-tour/#free-vs-pro' ),
            'button_text' => __( 'Upgrade Now', 'travel-tour' ),
        )) );
    }
}
