<?php

/**
 * Theme Customizer - Site Identity tab
 * @package Glaciers
 * @since 1.0.0
 */

if (!defined('ABSPATH')) {
	exit; // Exit if accessed directly.
}

function glaciers_customize_register_site($wp_customize)
{

	/** Add postMessage support for site title and description */
	$wp_customize->get_setting('blogname')->transport         = 'postMessage';
	$wp_customize->get_setting('blogdescription')->transport  = 'postMessage';
	$wp_customize->get_setting('background_color')->transport = 'refresh';
	$wp_customize->get_setting('background_image')->transport = 'refresh';


	// Show site title
	$wp_customize->add_setting('glaciers_hide_site_title',	array(
		'default' => false,
		'transport'  => 'postMessage',
		'sanitize_callback' => 'glaciers_sanitize_checkbox',
	));

	$wp_customize->add_control(new Glaciers_Toggle_Control(
		$wp_customize,
		'glaciers_hide_site_title',
		array(
			'label'    => esc_html__('Hide the Site Title', 'glaciers'),
			'description' => esc_html__('Show or hide the site title.', 'glaciers'),
			'section'  => 'title_tagline',
		)
	));

	// Show site description
	$wp_customize->add_setting('glaciers_hide_tagline', array(
		'default' => false,
		'transport'  => 'postMessage',
		'sanitize_callback' => 'glaciers_sanitize_checkbox',
	));

	$wp_customize->add_control(new Glaciers_Toggle_Control(
		$wp_customize,
		'glaciers_hide_tagline',
		array(
			'label'    => esc_html__('Hide the Site Description', 'glaciers'),
			'description' => esc_html__('Show or hide the site tagline [description].', 'glaciers'),
			'section'  => 'title_tagline',
		)
	));

	// Site title colour
	$wp_customize->add_setting('glaciers_site_title_colour', array(
		'default'           => '#000000',
		'transport' => 'postMessage',
		'sanitize_callback' => 'sanitize_hex_color'
	));

	$wp_customize->add_control(new WP_Customize_Color_Control(
		$wp_customize,
		'glaciers_site_title_colour',
		array(
			'label'       => esc_html__('Site Title Colour', 'glaciers'),
			'description' => esc_html__('Sets the site title colour in the sidebar area.', 'glaciers'),
			'section'     => 'title_tagline',
		)
	));

	// Site tagline colour
	$wp_customize->add_setting('glaciers_tagline_colour', array(
		'default'           => '#6c757d',
		'transport' => 'postMessage',
		'sanitize_callback' => 'sanitize_hex_color'
	));

	$wp_customize->add_control(new WP_Customize_Color_Control(
		$wp_customize,
		'glaciers_tagline_colour',
		array(
			'label'       => esc_html__('Site Tagline Colour', 'glaciers'),
			'description' => esc_html__('Sets the site tagline [ description ] colour in the header area.', 'glaciers'),
			'section'     => 'title_tagline',
		)
	));

	// Site Logo size
	$wp_customize->add_setting('glaciers_logo_width', array(
		'default'           => 250,
		'transport'         => 'postMessage',
		'sanitize_callback' => 'absint',
	));

	$wp_customize->add_control(
		new Glaciers_Slider_Control($wp_customize, 'glaciers_logo_width', array(
			'section'	  => 'title_tagline',
			'label'		  => esc_html__('Site Logo Size', 'glaciers'),
			'description' => esc_html__('Change the site logo size for your sidebar column.', 'glaciers'),
			'choices'	  => array(
				'min' 	=> 100,
				'max' 	=> 280,
				'step'	=> 20,
			)
		))
	);


	// Site Title Font Size
	$wp_customize->add_setting('site_title_font_size', array(
		'default'           => 1.75,
		'transport'         => 'postMessage',
		'sanitize_callback' => 'glaciers_sanitize_number_decimal',
	));

	$wp_customize->add_control(
		new Glaciers_Slider_Control($wp_customize, 'site_title_font_size', array(
			'section'	  => 'title_tagline',
			'label'		  => esc_html__('Site Title Font Size', 'glaciers'),
			'description' => esc_html__('Change the font size of your site title.', 'glaciers'),
			'priority'    => 65,
			'choices'	  => array(
				'min' 	=> 1,
				'max' 	=> 3,
				'step'	=> 0.05,
			)
		))
	);

	// Site Tagline Font Size
	$wp_customize->add_setting('site_tagline_font_size', array(
		'default'           => 0.75,
		'transport'         => 'postMessage',
		'sanitize_callback' => 'glaciers_sanitize_number_decimal',
	));

	$wp_customize->add_control(
		new Glaciers_Slider_Control($wp_customize, 'site_tagline_font_size', array(
			'section'	  => 'title_tagline',
			'label'		  => esc_html__('Site Tagline Font Size', 'glaciers'),
			'description' => esc_html__('Change the font size of your site tagline (description).', 'glaciers'),
			'priority'    => 65,
			'choices'	  => array(
				'min' 	=> 0.75,
				'max' 	=> 2,
				'step'	=> 0.05,
			)
		))
	);
}
add_action('customize_register', 'glaciers_customize_register_site');
