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

add_action( 'customize_register', 'chic_lifestyle_customize_register_scroll_to_top_section' );

function chic_lifestyle_customize_register_scroll_to_top_section( $wp_customize ) {

	$wp_customize->add_section( 'chic_lifestyle_scroll_to_top_section', array(
		'title'      => esc_attr__( 'Scroll to top', 'chic-lifestyle' ),
		'panel'      => 'chic_lifestyle_general_panel',
		'priority'   => 9,
		'capability' => 'edit_theme_options',
	) );

	$wp_customize->add_setting( 'chic_lifestyle_scroll_to_top_display', array(
		'default'           => true,
		'sanitize_callback' => 'chic_lifestyle_sanitize_checkbox',
	) );

	$wp_customize->add_control( new Chic_Lifestyle_Toggle_Control(
		$wp_customize, 'chic_lifestyle_scroll_to_top_display', array(
			'label'    => esc_attr__( 'Show Scroll to Top Button', 'chic-lifestyle' ),
			'section'  => 'chic_lifestyle_scroll_to_top_section',
			'settings' => 'chic_lifestyle_scroll_to_top_display',
			'type'     => 'toggle',
		)
	) );

	$wp_customize->add_setting( 'chic_lifestyle_scroll_to_top_color', array(
		'default'           => '#66d6d2',
		'sanitize_callback' => 'chic_lifestyle_sanitize_hex_color',
	) );

	$wp_customize->add_control( new WP_Customize_Color_Control(
		$wp_customize, 'chic_lifestyle_scroll_to_top_color', array(
			'label'    => esc_attr__( 'Button color', 'chic-lifestyle' ),
			'section'  => 'chic_lifestyle_scroll_to_top_section',
			'settings' => 'chic_lifestyle_scroll_to_top_color',
		)
	) );

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

	$wp_customize->add_control( new Chic_Lifestyle_Slider_Control(
		$wp_customize, 'chic_lifestyle_scroll_to_top_size', array(
			'label'    => esc_attr__( 'Button size', 'chic-lifestyle' ),
			'section'  => 'chic_lifestyle_scroll_to_top_section',
			'settings' => 'chic_lifestyle_scroll_to_top_size',
			'choices'  => array(
				'min'    => 20,
				'max'    => 60,
				'step'   => 1,
				'suffix' => 'px',
			),
		)
	) );

	$wp_customize->selective_refresh->add_partial( 'chic_lifestyle_scroll_to_top_display', array(
		'selector'            => '#chic_lifestyle_scroll_to_top',
		'settings'            => array(
			'chic_lifestyle_scroll_to_top_display',
			'chic_lifestyle_scroll_to_top_color',
			'chic_lifestyle_scroll_to_top_size',
		),
		'render_callback'     => 'chic_lifestyle_render_scroll_to_top',
		'container_inclusive' => true,
	) );
}
