<?php
/**
 * Footer Settings
 *
 * @package Travel Tour
 */

add_action( 'customize_register', 'travel_tour_customize_register_footer_section' );

function travel_tour_customize_register_footer_section( $wp_customize ) {

    $wp_customize->add_section( 'travel_tour_footer_section', array(
        'title'          => esc_html__( 'Footer Section', 'travel-tour' ),
        'panel'          => 'travel_tour_general_panel',
        'priority'       => 7,
    ) );

    $wp_customize->add_setting( 'travel_tour_footer_layout', array(
      'capability'  => 'edit_theme_options',
      'default'     => '4',
      'sanitize_callback' => 'travel_tour_sanitize_select',
      'transport' => 'postMessage',
    ) );
    
    $wp_customize->add_control( 'travel_tour_footer_layout', array(
        'label'       =>  esc_html__( 'Number of footer widgets', 'travel-tour' ),
        'section'     => 'travel_tour_footer_section',
        'type'        => 'select',
        'default'     => '4',
        'choices'     =>  array(             
            '0' => 0,
            '1' => 1,
            '2' => 2,
            '3' => 3,
            '4' => 4,
        )
    ) );

    $wp_customize->selective_refresh->add_partial( 'travel_tour_footer_layout', array(
        'selector' => '#footer-widgets',
        'settings' => array( 'travel_tour_footer_layout' ),
        'render_callback' => 'travel_tour_footer_widgets',
        'container_inclusive' => true,
    ) );

    $wp_customize->add_setting( 'copyright_text', array(
        'sanitize_callback'     =>  'wp_kses_post',
        'default'               =>  ''
    ) );

    $wp_customize->add_control( 'copyright_text', array(
        'label' => esc_html__( 'Copyright :', 'travel-tour' ),
        'section' => 'travel_tour_footer_section',
        'settings' => 'copyright_text',
        'type'=> 'textarea',
    ) );

    $wp_customize->selective_refresh->add_partial( 'copyright_text', array(
        'selector' => '.copyright',
    ) );

    if ( fs_travel_tour()->is_free_plan() ) {
        $wp_customize->add_setting( 'travel_tour_footer_upgrade_to_pro', array(
            'sanitize_callback' => null,
        ) );
        $wp_customize->add_control( new Travel_Tour_Control_Upgrade_To_Pro(
            $wp_customize, 'travel_tour_footer_upgrade_to_pro', array(
                'section' => 'travel_tour_footer_section',
                'settings'    => 'travel_tour_footer_upgrade_to_pro',
                'title'   => __( 'Want the full control over your copyright?', 'travel-tour' ),
                'items' => array(
                    'one'   => array(
                        'title' => __( 'Remove WordPress links from the copyright', 'travel-tour' ),
                    ),
                ),
                'button_url'   => esc_url( 'https://thebootstrapthemes.com/travel-tour/#free-vs-pro' ),
                'button_text'   => __( 'Upgrade Now', 'travel-tour' ),
            )
        ) );
    }

}