<?php
/**
 * Scroll to Top Button Settings
 *
 * @package Travel Tour
 */

add_action( 'customize_register', 'travel_tour_customize_register_scroll_to_top_section' );

function travel_tour_customize_register_scroll_to_top_section( $wp_customize ) {

	$wp_customize->add_section( 'travel_tour_scroll_to_top_section', array(
		'title'      => esc_attr__( 'Scroll to top', 'travel-tour' ),
		'panel'      => 'travel_tour_general_panel',
		'priority'   => 9,
		'capability' => 'edit_theme_options',
	) );

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

	$wp_customize->add_control( new Travel_Tour_Toggle_Control(
		$wp_customize, 'travel_tour_scroll_to_top_display', array(
			'label'    => esc_attr__( 'Show Scroll to Top Button', 'travel-tour' ),
			'section'  => 'travel_tour_scroll_to_top_section',
			'settings' => 'travel_tour_scroll_to_top_display',
			'type'     => 'toggle',
		)
	) );

	$wp_customize->add_setting( 'travel_tour_scroll_to_top_color', array(
		'default'           => '#1bb0ce',
		'sanitize_callback' => 'travel_tour_sanitize_hex_color',
	) );

	$wp_customize->add_control( new WP_Customize_Color_Control(
		$wp_customize, 'travel_tour_scroll_to_top_color', array(
			'label'    => esc_attr__( 'Button color', 'travel-tour' ),
			'section'  => 'travel_tour_scroll_to_top_section',
			'settings' => 'travel_tour_scroll_to_top_color',
		)
	) );

	$wp_customize->add_setting( 'travel_tour_scroll_to_top_size', array(
		'default'           => 36,
		'sanitize_callback' => 'absint',
	) );

	$wp_customize->add_control( new Travel_Tour_Slider_Control(
		$wp_customize, 'travel_tour_scroll_to_top_size', array(
			'label'    => esc_attr__( 'Button size', 'travel-tour' ),
			'section'  => 'travel_tour_scroll_to_top_section',
			'settings' => 'travel_tour_scroll_to_top_size',
			'choices'  => array(
				'min'    => 20,
				'max'    => 60,
				'step'   => 1,
				'suffix' => 'px',
			),
		)
	) );

	$wp_customize->selective_refresh->add_partial( 'travel_tour_scroll_to_top_display', array(
		'selector'            => '#travel_tour_scroll_to_top',
		'settings'            => array(
			'travel_tour_scroll_to_top_display',
			'travel_tour_scroll_to_top_color',
			'travel_tour_scroll_to_top_size',
		),
		'render_callback'     => 'travel_tour_render_scroll_to_top',
		'container_inclusive' => true,
	) );
}
