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

add_action( 'customize_register', 'bootstrap_coach_customize_register_scroll_to_top_section' );

function bootstrap_coach_customize_register_scroll_to_top_section( $wp_customize ) {

	$wp_customize->add_section( 'bootstrap_coach_scroll_to_top_section', array(
		'title'      => esc_attr__( 'Scroll to top', 'bootstrap-coach' ),
		'panel'      => 'bootstrap_coach_general_panel',
		'priority'   => 9,
		'capability' => 'edit_theme_options',
	) );

	$wp_customize->add_setting( 'bootstrap_coach_scroll_to_top_display', array(
		'default'           => false,
		'sanitize_callback' => 'bootstrap_coach_sanitize_checkbox',
	) );

	$wp_customize->add_control( new Bootstrap_Coach_Toggle_Control(
		$wp_customize, 'bootstrap_coach_scroll_to_top_display', array(
			'label'    => esc_attr__( 'Show Scroll to Top Button', 'bootstrap-coach' ),
			'section'  => 'bootstrap_coach_scroll_to_top_section',
			'settings' => 'bootstrap_coach_scroll_to_top_display',
			'type'     => 'toggle',
		)
	) );

	$wp_customize->add_setting( 'bootstrap_coach_scroll_to_top_color', array(
		'default'           => '#FF6C2E',
		'sanitize_callback' => 'bootstrap_coach_sanitize_hex_color',
	) );

	$wp_customize->add_control( new WP_Customize_Color_Control(
		$wp_customize, 'bootstrap_coach_scroll_to_top_color', array(
			'label'    => esc_attr__( 'Button color', 'bootstrap-coach' ),
			'section'  => 'bootstrap_coach_scroll_to_top_section',
			'settings' => 'bootstrap_coach_scroll_to_top_color',
		)
	) );

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

	$wp_customize->add_control( new Bootstrap_Coach_Slider_Control(
		$wp_customize, 'bootstrap_coach_scroll_to_top_size', array(
			'label'    => esc_attr__( 'Button size', 'bootstrap-coach' ),
			'section'  => 'bootstrap_coach_scroll_to_top_section',
			'settings' => 'bootstrap_coach_scroll_to_top_size',
			'choices'  => array(
				'min'    => 20,
				'max'    => 60,
				'step'   => 1,
				'suffix' => 'px',
			),
		)
	) );

	$wp_customize->selective_refresh->add_partial( 'bootstrap_coach_scroll_to_top_display', array(
		'selector'            => '#bootstrap_coach_scroll_to_top',
		'settings'            => array(
			'bootstrap_coach_scroll_to_top_display',
			'bootstrap_coach_scroll_to_top_color',
			'bootstrap_coach_scroll_to_top_size',
		),
		'render_callback'     => 'bootstrap_coach_render_scroll_to_top',
		'container_inclusive' => true,
	) );
}
