<?php

/**
 * Shortcode for review section Settings
 *
 * @package Travel Tour
 */

add_action( 'customize_register', 'travel_tour_customize_testimonial_section' );

function travel_tour_customize_testimonial_section( $wp_customize ) {

	$wp_customize->add_section( 'travel_tour_testimonial_section', array(
    'title'          => esc_html__( 'Testimonial Section', 'travel-tour' ),
    'panel'          => 'travel_tour_homepage_panel',
    'priority'       => 9,
  ) );

  $wp_customize->add_setting( 'travel_tour_testimonial_section_display_option', array(
    'sanitize_callback'     =>  'travel_tour_sanitize_checkbox',
    'default'               =>  true
  ) );

  $wp_customize->add_control( new Travel_Tour_Toggle_Control(
  	$wp_customize, 'travel_tour_testimonial_section_display_option', array(
      'label' => esc_html__( 'Hide / Show', 'travel-tour' ),
      'section' => 'travel_tour_testimonial_section',
      'settings' => 'travel_tour_testimonial_section_display_option',
      'type'=> 'toggle',
      'priority'  =>  1
  	)
  ) );

  $wp_customize->selective_refresh->add_partial( 'travel_tour_testimonial_section_display_option', array(
      'selector' => '.testimonials .container-xl',
  ) );

  $wp_customize->add_setting( 'travel_tour_testimonial_section_title', array(
    'sanitize_callback'     =>  'sanitize_text_field',
    'default'               =>  esc_html__( 'What our clients have to say about us', 'travel-tour' )
  ) );

  $wp_customize->add_control( 'travel_tour_testimonial_section_title', array(
    'label' => esc_html__( 'Title', 'travel-tour' ),
    'section' => 'travel_tour_testimonial_section',
    'settings' => 'travel_tour_testimonial_section_title',
    'type'=> 'text',
    'priority'  =>  2
  ) );

  $wp_customize->selective_refresh->add_partial( 'travel_tour_testimonial_section_title', array(
      'selector' => '.testimonials h2',
  ) );

  $wp_customize->add_setting( 'travel_tour_testimonial_section_bg_color', array(
    'capability'  => 'edit_theme_options',
    'default'     => '#f7f7f7',
    'sanitize_callback' => 'travel_tour_sanitize_hex_color',
    'transport'   => 'refresh'
  ) );

  $wp_customize->add_control( new WP_Customize_Color_Control(
  	$wp_customize, 'travel_tour_testimonial_section_bg_color', array(
      'label'      => esc_html__( 'Background Color', 'travel-tour' ),
      'section'    => 'travel_tour_testimonial_section',
      'settings'   => 'travel_tour_testimonial_section_bg_color',
      'priority'   => 3
  ) ) );

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

  $wp_customize->add_control( new Travel_Tour_Text_Message_Control(
    $wp_customize, 'travel_tour_testimonial_section_text_message', array(
      'section' => 'travel_tour_testimonial_section',
      'title' => esc_html__('Use widget', 'travel-tour'),
      'description' => __('Insert your own testimonials into the "Testimonials" widget on the <a href="/wp-admin/widgets.php" target="_blank">Widgets page</a>. Separate individual testimonials by new line.', 'travel-tour'),
    ) 
  ) );

  $wp_customize->add_setting( 'travel_tour_testimonial_shortcode', array(
    'sanitize_callback' => 'sanitize_textarea_field',
    'default' => '',
  ) );

  $wp_customize->add_control( 'travel_tour_testimonial_shortcode', array(
    'label' => esc_html__( 'Use shortcode', 'travel-tour' ),
    'description' => esc_html__( 'You can use external plugin to display testimonials from Tripadvisor, Hotels.com, Booking.com and more. Insert the plugin shortcode below:', 'travel-tour' ),
    'section' => 'travel_tour_testimonial_section',
    'settings' => 'travel_tour_testimonial_shortcode',
    'type'=> 'textarea',
  ) );

}