<?php
/**
 * Contains methods for customizing the theme customization screen.
 */
 
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}



if ( ! class_exists( 'Kktfwp_Settings' ) && class_exists( 'WP_Customize_Control' ) ) {
  
	class Kktfwp_Settings {	
		
	    /**
		* This hooks into 'customize_register' (available as of WP 3.4) and allows
		* you to add new sections and controls to the Theme Customize screen.
		* 
		*/
				
		public static function register ( $wp_customize ) {	

			// DEFAULT COLORS
			
			$defaultAttr = array();
			
					 
			// SECTIONS
			
			$wp_customize->add_section( 'kktfwp_miscellaneous', array(
				'priority'       => 160,
				'capability'     => 'edit_theme_options',
				'title'          => esc_html__('Miscellaneous', 'toppic'),
			) );
			
			$wp_customize->add_section( 'kktfwp_appearance', array(
				'priority'       => 20,
				'capability'     => 'edit_theme_options',
				'title'          => esc_html__('Appearance', 'toppic'),
			) );
			
			$wp_customize->add_section( 'kktfwp_slider', array(
				'priority'       => 139,
				'capability'     => 'edit_theme_options',
				'title'          => esc_html__('Background Slider', 'toppic'),
			) );
			
			$wp_customize->add_section( 'kktfwp_gallery', array(
				'priority'       => 140,
				'capability'     => 'edit_theme_options',
				'title'          => esc_html__('Fullscreen Gallery', 'toppic'),
			) );
			
			$wp_customize->add_section( 'kktfwp_bg_image', array(
				'priority'       => 141,
				'capability'     => 'edit_theme_options',
				'title'          => esc_html__('Background Image', 'toppic'),
			) );
			
			$wp_customize->add_section( 'kktfwp_footer', array(
				'priority'       => 142,
				'capability'     => 'edit_theme_options',
				'title'          => esc_html__('Footer', 'toppic'),
			) );
			
			$wp_customize->add_section( 'kktfwp_fonts', array(
				'priority'       => 144,
				'capability'     => 'edit_theme_options',
				'title'          => esc_html__('Typography', 'toppic'),
			) );
			
			$wp_customize->add_section( 'kktfwp_social', array(
				'priority'       => 146,
				'capability'     => 'edit_theme_options',
				'title'          => esc_html__('Social Profiles', 'toppic'),
			) );			
			
			// Settings
			
			
			/*
			// Menu style
			*/
			
			$wp_customize->add_setting( 'kktfwp_menu_style' , array(
				'default'     => 'kk-menu-default',
				'transport'   => 'refresh',
				'sanitize_callback' => 'kktfwp_sanitize_select',
			));

			$wp_customize->add_control( 'kktfwp_menu_style', array(
				'type'       => 'select',
				'label'    	 => esc_html__('Menu style', 'toppic'),
				'section'    => 'kktfwp_appearance',
				'choices' => array(
						"kk-menu-default" 			=> esc_html__( 'Default', 'toppic' ),
						"kk-menu-default-hidden" 	=> esc_html__( 'Default (hidden)', 'toppic' ),
						"kk-menu-classic"		 	=> esc_html__( 'Classic', 'toppic' ),
						"kk-menu-left-boxed" 		=> esc_html__( 'Left Boxed', 'toppic' ),
						"kk-menu-slide-right" 		=> esc_html__( 'Creative', 'toppic' ),
						"kk-menu-fullscreen" 		=> esc_html__( 'Fullscreen', 'toppic' ),
				),
				'priority'   => 1,				
			));				
			
			/*
			// Menu opacity
			*/
			
			$wp_customize->add_setting( 'kktfwp_menu_opacity' , array(
				'default'     => '85',
				'transport'   => 'refresh',
				'sanitize_callback' => 'kktfwp_sanitize_float',
				'sanitize_js_callback' => 'kktfwp_sanitize_float',
			));			
					
			$wp_customize->add_control( new KKTFWP_Range_Control ( $wp_customize, 'kktfwp_menu_opacity', array(
				'type'        => 'kktfwp_range',
				'section'     => 'kktfwp_appearance',
				'label'    	 => esc_html__('Menu opacity', 'toppic'),
				'priority'   => 4,
				'input_attrs' => array(
					'min'   => 1,
					'max'   => 100,
					'step'  => 1,
				),
				'active_callback' => function() {
					if ( ! in_array( get_theme_mod( 'kktfwp_menu_style', 'kk-menu-default' ), array( 'kk-menu-left-boxed', 'kk-menu-fullscreen' ) ) ) return false;
				}
			) ) );
			
			/*
			// Menu color
			*/
			
			$wp_customize->add_setting( 'kktfwp_menu_bg_color' , array(
				'default'     => '',
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_hex_color',
				'sanitize_js_callback' => 'sanitize_hex_color',
			));

			$wp_customize->add_control( new Kktfwp_Customize_Control_Color( $wp_customize, 'kktfwp_menu_bg_color', array(
				'label'        => esc_html__('Menu background color', 'toppic'),
				'description'  => esc_html__('Select a color to be used as background menu color', 'toppic'),
				'section'    => 'kktfwp_appearance',	
				'priority'   => 4
			) ) );
			
			$wp_customize->add_setting( 'kktfwp_menu_txt_color' , array(
				'default'     => '',
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_hex_color',
				'sanitize_js_callback' => 'sanitize_hex_color',
			));

			$wp_customize->add_control( new Kktfwp_Customize_Control_Color( $wp_customize, 'kktfwp_menu_txt_color', array(
				'label'        => esc_html__('Menu text color', 'toppic'),
				'description'  => esc_html__('Select a color to be used for text', 'toppic'),
				'section'    => 'kktfwp_appearance',	
				'priority'   => 4
			) ) );	

			/*
			// Content width
			*/			
			
			$wp_customize->add_setting( 'kktfwp_content_width' , array(
				'default'     => 'kk-boxed',
				'transport'   => 'refresh',
				'sanitize_callback' => 'kktfwp_sanitize_select',
			));

			$wp_customize->add_control( 'kktfwp_content_width', array(
				'type'       => 'select',
				'label'    	 => esc_html__('Content area width', 'toppic'),
				'section'    => 'kktfwp_appearance',
				'choices' => array(
					'kk-boxed' => esc_html__('Boxed', 'toppic'),
					'kk-full' => esc_html__('Wide', 'toppic'),
				),
				'priority'   => 4,	
				'active_callback' => function() {
					if ( in_array( get_theme_mod( 'kktfwp_menu_style', 'kk-menu-default' ), array( 'kk-menu-classic', 'kk-menu-left-boxed', 'kk-menu-slide-right' ) ) ) return false;
				}				
			));
			
			/*
			// Bordered Layout
			*/
			
			$wp_customize->add_setting( 'kktfwp_borders' , array(
				'default'     => 0,
				'transport'   => 'refresh',
				'sanitize_callback' => 'kktfwp_switch_sanitization',
			));
			
			$wp_customize->add_control( new KKTFWP_Toggle_Control( $wp_customize, 'kktfwp_borders', array(
				'label'        => esc_html__('Enable borders', 'toppic'),
				'section'    => 'kktfwp_appearance',
				'priority'   => 4,
				'active_callback' => function() {
					if ( in_array( get_theme_mod( 'kktfwp_menu_style', 'kk-menu-default' ), array( 'kk-menu-default', 'kk-menu-classic', 'kk-menu-left-boxed', 'kk-menu-fullscreen', 'kk-menu-default-hidden' ) ) ) return false;
				}				
				)
			) );
			
			/*
			// Content width
			*/			
			
			$wp_customize->add_setting( 'kktfwp_skin' , array(
				'default'     => 'light',
				'transport'   => 'refresh',
				'sanitize_callback' => 'kktfwp_sanitize_select',
			));

			$wp_customize->add_control( 'kktfwp_skin', array(
				'type'       => 'select',
				'label'    	 => esc_html__('Colorscheme', 'toppic'),
				'section'    => 'kktfwp_appearance',
				'choices' => array(
					'light' => esc_html__('Light', 'toppic'),
					'dark' => esc_html__('Dark', 'toppic'),
				),
				'priority'   => 4
			));
			
			/*
			// Accent Color
			*/
			
			$wp_customize->add_setting( 'kktfwp_accent_color' , array(
				'default'     => '',
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_hex_color',
				'sanitize_js_callback' => 'sanitize_hex_color',
			));

			$wp_customize->add_control( new Kktfwp_Customize_Control_Color( $wp_customize, 'kktfwp_accent_color', array(
				'label'        => esc_html__('Accent color', 'toppic'),
				'description'  => esc_html__('Select a color to be used as accents color', 'toppic'),
				'section'    => 'kktfwp_appearance',	
				'priority'   => 4
			) ) );
			
			/*
			// Secondary Accent Color
			*/
			
			$wp_customize->add_setting( 'kktfwp_secondary_accent_color' , array(
				'default'     => '',
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_hex_color',
				'sanitize_js_callback' => 'sanitize_hex_color',
			));

			$wp_customize->add_control( new Kktfwp_Customize_Control_Color( $wp_customize, 'kktfwp_secondary_accent_color', array(
				'label'        => esc_html__('Secondary accent color', 'toppic'),
				'description'  => esc_html__('Select a color to be used as secondary accents color', 'toppic'),
				'section'    => 'kktfwp_appearance',	
				'priority'   => 4
			) ) );
			
			
			/*
			// Blog Sidebar
			*/
			
			$wp_customize->add_setting( 'kktfwp_blog_sidebar' , array(
				'default'     => 'right',
				'transport'   => 'refresh',
				'sanitize_callback' => 'kktfwp_sanitize_select',
			));

			$wp_customize->add_control( 'kktfwp_blog_sidebar', array(
				'type'       => 'select',
				'label'    	 => esc_html__('Blog sidebar position', 'toppic'),
				'section'    => 'kktfwp_appearance',
				'choices' => array(
					'right' => esc_html__('Right', 'toppic'),
					'left' => esc_html__('Left', 'toppic'),
					'full' => esc_html__('No sidebar', 'toppic'),
				),
				'priority'   => 4,				
			));
			
			/*
			// Blog Single Post Sidebar
			*/
			
			$wp_customize->add_setting( 'kktfwp_blog_single' , array(
				'default'     => 0,
				'transport'   => 'refresh',
				'sanitize_callback' => 'kktfwp_switch_sanitization',
			));
			
			$wp_customize->add_control( new KKTFWP_Toggle_Control( $wp_customize, 'kktfwp_blog_single', array(
				'label'        => esc_html__('Disable sidebar in single posts', 'toppic'),
				'section'    => 'kktfwp_appearance',
				'priority'   => 4,	
				'active_callback' => function() {
					if ( get_theme_mod('kktfwp_blog_sidebar', 'right') === 'full' ) return false;
				}			
				)				
			) );			
			
			/*
			// Project Navigation
			*/
			
			$wp_customize->add_setting( 'kktfwp_project_nav' , array(
				'default'     => 0,
				'transport'   => 'refresh',
				'sanitize_callback' => 'kktfwp_switch_sanitization',
			));
			
			$wp_customize->add_control( new KKTFWP_Toggle_Control( $wp_customize, 'kktfwp_project_nav', array(
				'label'        => esc_html__('Reverse project navigation', 'toppic'),
				'description'  => esc_html__('Older projects will be shown as next project', 'toppic'),
				'section'    => 'kktfwp_miscellaneous',
				'priority'   => 20,
			) ) );
			
			
			/*
			// Responsive layout
			*/
			
			$wp_customize->add_setting( 'kktfwp_responsive' , array(
				'default'     => 1,
				'transport'   => 'refresh',
				'sanitize_callback' => 'kktfwp_switch_sanitization',
			));
			
			$wp_customize->add_control( new KKTFWP_Toggle_Control( $wp_customize, 'kktfwp_responsive', array(
				'label'        => esc_html__('Enable responsive layout', 'toppic'),
				'section'    => 'kktfwp_miscellaneous'
				)
			) );
			
			/*
			// Animated page change
			*/
			
			$wp_customize->add_setting( 'kktfwp_animation' , array(
				'default'     => 1,
				'transport'   => 'refresh',
				'sanitize_callback' => 'kktfwp_switch_sanitization',
			));
			
			$wp_customize->add_control( new KKTFWP_Toggle_Control( $wp_customize, 'kktfwp_animation', array(
				'label'        => esc_html__('Enable animation between pages', 'toppic'),
				'section'    => 'kktfwp_miscellaneous'
				)
			) );
			
			/*
			// Disable Right Click
			*/
			
			$wp_customize->add_setting( 'kktfwp_protection' , array(
				'default'     => 0,
				'transport'   => 'refresh',
				'sanitize_callback' => 'kktfwp_switch_sanitization',
			));
			
			$wp_customize->add_control( new KKTFWP_Toggle_Control( $wp_customize, 'kktfwp_protection', array(
				'label'        => esc_html__('Disable Right Click', 'toppic'),
				'section'    => 'kktfwp_miscellaneous',
				'auto_control'  => true,
				'js_vars' => array (
					'elements' => array(					
						'kktfwp_protection_message'						
					),
				'state' => '1'
				)
			) ) );
			
			$wp_customize->add_setting( 'kktfwp_protection_message' , array(
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field',
			));
			
			$wp_customize->add_control( 'kktfwp_protection_message', array(
				'type' 		 => 'textarea',
				'label' 	 => esc_html__('Message to display when right button is clicked', 'toppic'),
				'section'    => 'kktfwp_miscellaneous',
			) );		
			
			
			/*
			// Search button
			*/
			
			$wp_customize->add_setting( 'kktfwp_search_btn' , array(
				'default'     => 0,
				'transport'   => 'refresh',
				'sanitize_callback' => 'kktfwp_switch_sanitization',
			));
			
			$wp_customize->add_control( new KKTFWP_Toggle_Control( $wp_customize, 'kktfwp_search_btn', array(
				'label'        => esc_html__('Hide search button', 'toppic'),
				'section'    => 'kktfwp_miscellaneous'
				)
			) );			
			
			
			/*
			// Backgroind slider type
			*/
			
			$wp_customize->add_setting( 'kktfwp_slider_type' , array(
				'default'     => 'kk_royal',
				'transport'   => 'refresh',
				'sanitize_callback' => 'kktfwp_sanitize_select',
			));

			$wp_customize->add_control( 'kktfwp_slider_type', array(
				'type'       => 'select',
				'label'    	 => esc_html__('Slider Type', 'toppic'),
				'section'    => 'kktfwp_slider',
				'choices' => array(
					'kk_royal' => esc_html__('Default Slider', 'toppic'),
					'ken_b' => esc_html__('Zoom Slider', 'toppic'),
				),
				'priority'   => 1,				
			));			
		
			/*
			// Backgroind slider transition
			*/
			
			$wp_customize->add_setting( 'kktfwp_slider_effect' , array(
				'default'     => 'fade',
				'transport'   => 'refresh',
				'sanitize_callback' => 'kktfwp_sanitize_select',
			));

			$wp_customize->add_control( 'kktfwp_slider_effect', array(
				'type'       => 'select',
				'label'    	 => esc_html__('Animation Effect', 'toppic'),
				'section'    => 'kktfwp_slider',
				'choices' => array(
					"fade" 	=> esc_html__('Fade', 'toppic'),
					"move" 	=> esc_html__('Move', 'toppic'),
				),
				'priority'   => 1,	
				'active_callback' => function() {
					if ( get_theme_mod('kktfwp_slider_type', 'kk_royal') !== 'kk_royal' ) return false;
				}			
			));			
			
			$wp_customize->add_setting( 'kktfwp_slider_transition' , array(
				'default'     => '900',
				'transport'   => 'refresh',
				'sanitize_callback' => 'kktfwp_sanitize_float',
				'sanitize_js_callback' => 'kktfwp_sanitize_float',
			));			
					
			$wp_customize->add_control( new KKTFWP_Range_Control ( $wp_customize, 'kktfwp_slider_transition', array(
				'type'        => 'kktfwp_range',
				'section'     => 'kktfwp_slider',
				'label'    	 => esc_html__('Transition Speed', 'toppic'),
				'description' => esc_html__('In ms. Default: 900', 'toppic'),
				'priority'   => 1,
				'input_attrs' => array(
					'min'   => 100,
					'max'   => 10000,
					'step'  => 25,
				),
				'active_callback' => function() {
					if ( get_theme_mod('kktfwp_slider_type', 'kk_royal') !== 'kk_royal' ) return false;
				}
			) ) );
						
			$wp_customize->add_setting( 'kktfwp_slider_lenght' , array(
				'default'     => '4000',
				'transport'   => 'refresh',
				'sanitize_callback' => 'kktfwp_sanitize_float',
				'sanitize_js_callback' => 'kktfwp_sanitize_float',
			));			
					
			$wp_customize->add_control( new KKTFWP_Range_Control ( $wp_customize, 'kktfwp_slider_lenght', array(
				'type'        => 'kktfwp_range',
				'section'     => 'kktfwp_slider',
				'label'    	 => esc_html__('Length between transitions', 'toppic'),
				'description' => esc_html__('In ms. Default: 4000', 'toppic'),
				'priority'   => 1,
				'input_attrs' => array(
					'min'   => 100,
					'max'   => 10000,
					'step'  => 25,
				),
				'active_callback' => function() {
					if ( get_theme_mod('kktfwp_slider_type', 'kk_royal') !== 'kk_royal' ) return false;
				}
			) ) );			
			
			$wp_customize->add_setting( 'kktfwp_slider_random' , array(
				'default'     => 0,
				'transport'   => 'refresh',
				'sanitize_callback' => 'kktfwp_switch_sanitization',
			));
			
			$wp_customize->add_control( new KKTFWP_Toggle_Control( $wp_customize, 'kktfwp_slider_random', array(
				'label'    	 => esc_html__('Randomize order', 'toppic'),
				'description' => esc_html__('Randomizes all slides at start', 'toppic'),
				'section'    => 'kktfwp_slider',
				'priority'   => 20,
				'active_callback' => function() {
					if ( get_theme_mod('kktfwp_slider_type', 'kk_royal') !== 'kk_royal' ) return false;
				}
			) ) );

			$wp_customize->add_setting( 'kktfwp_kenb_transition' , array(
				'default'     => '1000',
				'transport'   => 'refresh',
				'sanitize_callback' => 'kktfwp_sanitize_float',
				'sanitize_js_callback' => 'kktfwp_sanitize_float',
			));			
					
			$wp_customize->add_control( new KKTFWP_Range_Control ( $wp_customize, 'kktfwp_kenb_transition', array(
				'type'        => 'kktfwp_range',
				'section'     => 'kktfwp_slider',
				'label'    	 => esc_html__('Transition Speed', 'toppic'),
				'description' => esc_html__('In ms. Default: 1000', 'toppic'),
				'priority'   => 1,
				'input_attrs' => array(
					'min'   => 100,
					'max'   => 10000,
					'step'  => 25,
				),
				'active_callback' => function() {
					if ( get_theme_mod('kktfwp_slider_type', 'kk_royal') !== 'ken_b' ) return false;
				}
			) ) );
			
			$wp_customize->add_setting( 'kktfwp_kenb_lenght' , array(
				'default'     => '4000',
				'transport'   => 'refresh',
				'sanitize_callback' => 'kktfwp_sanitize_float',
				'sanitize_js_callback' => 'kktfwp_sanitize_float',
			));			
					
			$wp_customize->add_control( new KKTFWP_Range_Control ( $wp_customize, 'kktfwp_kenb_lenght', array(
				'type'        => 'kktfwp_range',
				'section'     => 'kktfwp_slider',
				'label'    	 => esc_html__('Length between transitions', 'toppic'),
				'description' => esc_html__('In ms. Default: 4000', 'toppic'),
				'priority'   => 1,
				'input_attrs' => array(
					'min'   => 100,
					'max'   => 10000,
					'step'  => 25,
				),
				'active_callback' => function() {
					if ( get_theme_mod('kktfwp_slider_type', 'kk_royal') !== 'ken_b' ) return false;
				}
			) ) );

			$wp_customize->add_setting( 'kktfwp_kenb_fps' , array(
				'default'     => '60',
				'transport'   => 'refresh',
				'sanitize_callback' => 'kktfwp_sanitize_float',
				'sanitize_js_callback' => 'kktfwp_sanitize_float',
			));			
					
			$wp_customize->add_control( new KKTFWP_Range_Control ( $wp_customize, 'kktfwp_kenb_fps', array(
				'type'        => 'kktfwp_range',
				'section'     => 'kktfwp_slider',
				'label'    	 => esc_html__('Frames Per Second', 'toppic'),
				'description' => esc_html__('Default: 60', 'toppic'),
				'priority'   => 1,
				'input_attrs' => array(
					'min'   => 1,
					'max'   => 120,
					'step'  => 1,
				),
				'active_callback' => function() {
					if ( get_theme_mod('kktfwp_slider_type', 'kk_royal') !== 'ken_b' ) return false;
				}
			) ) );			
			
			$wp_customize->add_setting( 'kktfwp_kenb_zoom' , array(
				'default'     => '1.2',
				'transport'   => 'refresh',
				'sanitize_callback' => 'kktfwp_sanitize_float',
				'sanitize_js_callback' => 'kktfwp_sanitize_float',
			));			
					
			$wp_customize->add_control( new KKTFWP_Range_Control ( $wp_customize, 'kktfwp_kenb_zoom', array(
				'type'        => 'kktfwp_range',
				'section'     => 'kktfwp_slider',
				'label'    	 => esc_html__('Zoom', 'toppic'),
				'priority'   => 1,
				'input_attrs' => array(
					'min'   => 1,
					'max'   => 3,
					'step'  => 0.1,
				),
				'active_callback' => function() {
					if ( get_theme_mod('kktfwp_slider_type', 'kk_royal') !== 'ken_b' ) return false;
				}
			) ) );
			
			
			/*
			// Fullscreen gallery defaults
			*/
			
			$wp_customize->add_setting( 'kktfwp_fs_gallery' , array(
				'default'     => 'fade',
				'transport'   => 'refresh',
				'sanitize_callback' => 'kktfwp_sanitize_select',
			));

			$wp_customize->add_control( 'kktfwp_fs_gallery', array(
				'type'       => 'select',
				'label'    	 => esc_html__('Animation Effect', 'toppic'),
				'section'    => 'kktfwp_gallery',
				'choices' => array(
					"fade" 	=> esc_html__('Fade', 'toppic'),
					"move" 	=> esc_html__('Move', 'toppic'),
				),
				'priority'   => 1,			
			));	
			
			$wp_customize->add_setting( 'kktfwp_fs_gallery_transition' , array(
				'default'     => '900',
				'transport'   => 'refresh',
				'sanitize_callback' => 'kktfwp_sanitize_float',
				'sanitize_js_callback' => 'kktfwp_sanitize_float',
			));			
					
			$wp_customize->add_control( new KKTFWP_Range_Control ( $wp_customize, 'kktfwp_fs_gallery_transition', array(
				'type'        => 'kktfwp_range',
				'section'     => 'kktfwp_gallery',
				'label'    	 => esc_html__('Transition Speed', 'toppic'),
				'description' => esc_html__('In ms. Default: 900', 'toppic'),
				'priority'   => 1,
				'input_attrs' => array(
					'min'   => 100,
					'max'   => 10000,
					'step'  => 25,
				)
			) ) );
						
			$wp_customize->add_setting( 'kktfwp_fs_gallery_lenght' , array(
				'default'     => '4000',
				'transport'   => 'refresh',
				'sanitize_callback' => 'kktfwp_sanitize_float',
				'sanitize_js_callback' => 'kktfwp_sanitize_float',
			));			
					
			$wp_customize->add_control( new KKTFWP_Range_Control ( $wp_customize, 'kktfwp_fs_gallery_lenght', array(
				'type'        => 'kktfwp_range',
				'section'     => 'kktfwp_gallery',
				'label'    	 => esc_html__('Length between transitions', 'toppic'),
				'description' => esc_html__('In ms. Default: 4000', 'toppic'),
				'priority'   => 1,
				'input_attrs' => array(
					'min'   => 100,
					'max'   => 10000,
					'step'  => 25,
				)
			) ) );	
			
			$wp_customize->add_setting( 'kktfwp_fs_gallery_autoplay' , array(
				'default'     => 0,
				'transport'   => 'refresh',
				'sanitize_callback' => 'kktfwp_switch_sanitization',
			));
			
			$wp_customize->add_control( new KKTFWP_Toggle_Control( $wp_customize, 'kktfwp_fs_gallery_autoplay', array(
				'label'    	 => esc_html__('Autoplay', 'toppic'),
				'section'    => 'kktfwp_gallery',
				'priority'   => 20
			) ) );
			
			$wp_customize->add_setting( 'kktfwp_fs_gallery_loop' , array(
				'default'     => 1,
				'transport'   => 'refresh',
				'sanitize_callback' => 'kktfwp_switch_sanitization',
			));
			
			$wp_customize->add_control( new KKTFWP_Toggle_Control( $wp_customize, 'kktfwp_fs_gallery_loop', array(
				'label'    	 => esc_html__('Loop', 'toppic'),
				'description' => esc_html__('Makes slider to go from last slide to first', 'toppic'),
				'section'    => 'kktfwp_gallery',
				'priority'   => 20
			) ) );
			
			/*
			// Default Background Image
			*/
			
			$wp_customize->add_setting( 'kktfwp_bg_image' , array(
				'capability' => 'edit_theme_options',
				'sanitize_callback' => 'absint'
			) 	);

			$wp_customize->add_control( new WP_Customize_Media_Control( $wp_customize, 'kktfwp_bg_image', array(
				'label'      	=> esc_html( 'Default background image', 'toppic' ),
				'description'	=> esc_html__('This image will be used as default background for all pages. This image will be ignored if you use background slideshow.', 'toppic'),
				'section'    	=> 'kktfwp_bg_image',
				'mime_type'  	=> 'image',
				'priority'   => 1,	
			) ) );
			
			/*
			// Default Background Image
			*/
			
			$wp_customize->add_setting( 'kktfwp_404_image' , array(
				'capability' => 'edit_theme_options',
				'sanitize_callback' => 'absint'
			) 	);

			$wp_customize->add_control( new WP_Customize_Media_Control( $wp_customize, 'kktfwp_404_image', array(
				'label'      	=> esc_html( '404 page', 'toppic' ),
				'description'	=> esc_html__('Background image for 404 page', 'toppic'),
				'section'    	=> 'kktfwp_bg_image',
				'mime_type'  	=> 'image',
				'priority'   => 1,	
			) ) );
			
			
			/*
			// Footer Copyrights
			*/
			
			$wp_customize->add_setting( 'kktfwp_copyrights' , array(
				'default'     => "toppic theme by <a target='_blank' href='http://themeforest.net/user/kotofey?ref=kotofey'>kotofey</a>. All Rights Reserved.",
				'transport'   => 'postMessage',
				'sanitize_callback' => 'kktfwp_footer',
				'sanitize_js_callback' => 'kktfwp_footer',
			));
			
			$wp_customize->add_control( 'kktfwp_copyrights', array(
				'type' 		 => 'textarea',
				'label' 	 => esc_html__('Footer copyrights', 'toppic'),
				'description' 	 => esc_html__('HTML tags are allowed', 'toppic'),
				'section'    => 'kktfwp_footer'			
			) );
			
			$wp_customize->selective_refresh->add_partial( 'kktfwp_copyrights', array(
				'selector' => '.footer .copyright, .kk-inner-footer .copyright',
				'render_callback' => function() {
					return get_theme_mod('kktfwp_copyrights');
				}
			) );
			
			/*
			// Social Profiles
			*/

			
			$wp_customize->add_setting( 'kktfwp_social[facebook]' , array(
				'transport'   => 'postMessage',
				'sanitize_callback' => 'esc_html',
			));		
			
			$wp_customize->add_control( 'kktfwp_social[facebook]', array(
				'type'       => 'text',
				'label'    	 => esc_html__('Facebook', 'toppic'),
				'section'    => 'kktfwp_social',
			) );
			
			$wp_customize->add_setting( 'kktfwp_social[twitter]' , array(
				'transport'   => 'postMessage',
				'sanitize_callback' => 'esc_html',
			));		
			
			$wp_customize->add_control( 'kktfwp_social[twitter]', array(
				'type'       => 'text',
				'label'    	 => esc_html__('Twitter', 'toppic'),
				'section'    => 'kktfwp_social',
			) );
			
			$wp_customize->add_setting( 'kktfwp_social[google]' , array(
				'transport'   => 'postMessage',
				'sanitize_callback' => 'esc_html',
			));		
			
			$wp_customize->add_control( 'kktfwp_social[google]', array(
				'type'       => 'text',
				'label'    	 => esc_html__('Google+', 'toppic'),
				'section'    => 'kktfwp_social',
			) );
			
			$wp_customize->add_setting( 'kktfwp_social[pinterest]' , array(
				'transport'   => 'postMessage',
				'sanitize_callback' => 'esc_html',
			));		
			
			$wp_customize->add_control( 'kktfwp_social[pinterest]', array(
				'type'       => 'text',
				'label'    	 => esc_html__('Pinterest', 'toppic'),
				'section'    => 'kktfwp_social',
			) );
			
			$wp_customize->add_setting( 'kktfwp_social[instagram]' , array(
				'transport'   => 'postMessage',
				'sanitize_callback' => 'esc_html',
			));		
			
			$wp_customize->add_control( 'kktfwp_social[instagram]', array(
				'type'       => 'text',
				'label'    	 => esc_html__('Instagram', 'toppic'),
				'section'    => 'kktfwp_social',
			) );
			
			$wp_customize->add_setting( 'kktfwp_social[soundcloud]' , array(
				'transport'   => 'postMessage',
				'sanitize_callback' => 'esc_html',
			));		
			
			$wp_customize->add_control( 'kktfwp_social[soundcloud]', array(
				'type'       => 'text',
				'label'    	 => esc_html__('Soundcloud', 'toppic'),
				'section'    => 'kktfwp_social',
			) );
			
			$wp_customize->add_setting( 'kktfwp_social[youtube]' , array(
				'transport'   => 'postMessage',
				'sanitize_callback' => 'esc_html',
			));		
			
			$wp_customize->add_control( 'kktfwp_social[youtube]', array(
				'type'       => 'text',
				'label'    	 => esc_html__('Youtube', 'toppic'),
				'section'    => 'kktfwp_social',
			) );
			
			$wp_customize->add_setting( 'kktfwp_social[flickr]' , array(
				'transport'   => 'postMessage',
				'sanitize_callback' => 'esc_html',
			));		
			
			$wp_customize->add_control( 'kktfwp_social[flickr]', array(
				'type'       => 'text',
				'label'    	 => esc_html__('Flickr', 'toppic'),
				'section'    => 'kktfwp_social',
			) );
			
			$wp_customize->add_setting( 'kktfwp_social[skype]' , array(
				'transport'   => 'postMessage',
				'sanitize_callback' => 'esc_html',
			));		
			
			$wp_customize->add_control( 'kktfwp_social[skype]', array(
				'type'       => 'text',
				'label'    	 => esc_html__('Skype', 'toppic'),
				'section'    => 'kktfwp_social',
			) );
			
			$wp_customize->add_setting( 'kktfwp_social[vimeo]' , array(
				'transport'   => 'postMessage',
				'sanitize_callback' => 'esc_html',
			));		
			
			$wp_customize->add_control( 'kktfwp_social[vimeo]', array(
				'type'       => 'text',
				'label'    	 => esc_html__('Vimeo', 'toppic'),
				'section'    => 'kktfwp_social',
			) );
			
			$wp_customize->add_setting( 'kktfwp_social[linkedin]' , array(
				'transport'   => 'postMessage',
				'sanitize_callback' => 'esc_html',
			));		
			
			$wp_customize->add_control( 'kktfwp_social[linkedin]', array(
				'type'       => 'text',
				'label'    	 => esc_html__('Linkedin', 'toppic'),
				'section'    => 'kktfwp_social',
			) );
			
			$wp_customize->add_setting( 'kktfwp_social[tumblr]' , array(
				'transport'   => 'postMessage',
				'sanitize_callback' => 'esc_html',
			));		
			
			$wp_customize->add_control( 'kktfwp_social[tumblr]', array(
				'type'       => 'text',
				'label'    	 => esc_html__('Tumblr', 'toppic'),
				'section'    => 'kktfwp_social',
			) );
			
			$wp_customize->add_setting( 'kktfwp_social[500px]' , array(
				'transport'   => 'postMessage',
				'sanitize_callback' => 'esc_html',
			));		
			
			$wp_customize->add_control( 'kktfwp_social[500px]', array(
				'type'       => 'text',
				'label'    	 => esc_html__('500px', 'toppic'),
				'section'    => 'kktfwp_social',
			) );
			
			$wp_customize->selective_refresh->add_partial( 'kktfwp_social', array(
				'selector' => '.social',
				'settings' => array (
					'kktfwp_social[facebook]',
					'kktfwp_social[twitter]',
					'kktfwp_social[google]',
					'kktfwp_social[pinterest]',
					'kktfwp_social[instagram]',
					'kktfwp_social[soundcloud]',
					'kktfwp_social[youtube]',
					'kktfwp_social[flickr]',
					'kktfwp_social[skype]',
					'kktfwp_social[vimeo]',
					'kktfwp_social[linkedin]',
					'kktfwp_social[tumblr]',
					'kktfwp_social[500px]'
				),
				'render_callback' => function() {
					return kktfwp_social_profiles();
				}
			) );

			
			/*
			// Logo
			*/		

			$wp_customize->add_setting( 'kktfwp_logo' , array(
				'capability' => 'edit_theme_options',
				'sanitize_callback' => 'absint'
			) 	);
			
			$wp_customize->add_control( new WP_Customize_Media_Control( $wp_customize, 'kktfwp_logo', array(
				'label'      => esc_html( 'Logo', 'toppic' ),
				'section'    => 'title_tagline',
				'mime_type'  => 'image'
			) ) );
			
			$wp_customize->add_setting( 'kktfwp_logo2x' , array(
				'capability' => 'edit_theme_options',
				'sanitize_callback' => 'absint'
			) 	);
			
			$wp_customize->add_control( new WP_Customize_Media_Control( $wp_customize, 'kktfwp_logo2x', array(
				'label'        => esc_html( 'Retina Logo', 'toppic' ),
				'description'  => esc_html( 'This logo must be x2 bigger than the original logo', 'toppic' ),
				'section'    => 'title_tagline',
				'mime_type'  => 'image'
			) ) );
			
			$wp_customize->add_setting( 'kktfwp_logo_dark' , array(
				'capability' => 'edit_theme_options',
				'sanitize_callback' => 'absint'
			) 	);
			
			$wp_customize->add_control( new WP_Customize_Media_Control( $wp_customize, 'kktfwp_logo_dark', array(
				'label'        => esc_html( 'Logo - dark version', 'toppic' ),
				'description'  => esc_html( 'Logo for light background.', 'toppic' ),
				'section'    => 'title_tagline',
				'mime_type'  => 'image',
				'active_callback' => function() {
					if ( ! in_array( get_theme_mod( 'kktfwp_menu_style', 'kk-menu-default' ), array( 'kk-menu-slide-right', 'kk-menu-fullscreen', 'kk-menu-classic' ) ) ) return false;
				}
			) ) );
			
			$wp_customize->add_setting( 'kktfwp_logo_dark2x' , array(
				'capability' => 'edit_theme_options',
				'sanitize_callback' => 'absint'
			) 	);
			
			$wp_customize->add_control( new WP_Customize_Media_Control( $wp_customize, 'kktfwp_logo_dark2x', array(
				'label'        => esc_html( 'Retina Logo - dark version', 'toppic' ),
				'description'  => esc_html( 'This logo must be x2 bigger than the original logo', 'toppic' ),
				'section'    => 'title_tagline',
				'mime_type'  => 'image',
				'active_callback' => function() {
					if ( ! in_array( get_theme_mod( 'kktfwp_menu_style', 'kk-menu-default' ), array( 'kk-menu-slide-right', 'kk-menu-fullscreen', 'kk-menu-classic' ) ) ) return false;
				}
			) ) );

			/*
			// Fonts
			*/
			
			// Headers
			
			$wp_customize->add_setting( 'kktfwp_headers_font[font]' , array(
				'default'     => 'Open Sans',
				'transport'   => 'postMessage',
				'sanitize_callback' => 'esc_textarea',
			));
			$wp_customize->add_setting( 'kktfwp_headers_font[variant]' , array(
				'default'     => '400',
				'transport'   => 'postMessage',
				'sanitize_callback' => 'esc_textarea', 
			));

			$wp_customize->add_control( new KKTFWP_Control_Google_Font( $wp_customize, 'kktfwp_headers_font', array(
				'label'    	 => esc_html__('Headings Font', 'toppic'),
				'description'    	 => esc_html__('Default: Open Sans', 'toppic'),
				'section'    => 'kktfwp_fonts',
				'priority'   => 10,
				'settings'   => array(
					'default' => 'kktfwp_headers_font[font]',
					'variant' => 'kktfwp_headers_font[variant]',
				),
				'auto_control'  => 'font',
				'auto_preview'  => true,
					'js_vars' => array(
					'element'  => '.blog-date, h1, h2, h3, h4, h5, h6, #slidecaption, #filter, .gallery-title h2, .portfolio-title h2',
					'function' => 'css',
					'property' => 'fontWeight',
				)
			) ) );
			
			// Menu
			
			$wp_customize->add_setting( 'kktfwp_menu_font[font]' , array(
				'default'     => 'Open Sans',
				'transport'   => 'postMessage',
				'sanitize_callback' => 'esc_textarea',
			));
			$wp_customize->add_setting( 'kktfwp_menu_font[variant]' , array(
				'default'     => '600',
				'transport'   => 'postMessage',
				'sanitize_callback' => 'esc_textarea', 
			));

			$wp_customize->add_control( new KKTFWP_Control_Google_Font( $wp_customize, 'kktfwp_menu_font', array(
				'label'    	 => esc_html__('Menu Font', 'toppic'),
				'description'    	 => esc_html__('Default: Open Sans', 'toppic'),
				'section'    => 'kktfwp_fonts',
				'priority'   => 5,
				'settings'   => array(
					'default' => 'kktfwp_menu_font[font]',
					'variant' => 'kktfwp_menu_font[variant]',
				),
				'auto_control'  => 'font',
				'auto_preview'  => true,
					'js_vars' => array(
					'element'  => '.main-nav',
					'function' => 'css',
					'property' => 'fontWeight',
				)
			) ) );
			
			
			// Body
			
			$wp_customize->add_setting( 'kktfwp_body_font[font]' , array(
				'default'     => 'Roboto',
				'transport'   => 'postMessage',
				'sanitize_callback' => 'esc_textarea',
			));
			$wp_customize->add_setting( 'kktfwp_body_font[variant]' , array(
				'default'     => '400',
				'transport'   => 'postMessage',
				'sanitize_callback' => 'esc_textarea',
			));

			$wp_customize->add_control( new KKTFWP_Control_Google_Font( $wp_customize, 'kktfwp_body_font', array(
				'label'    	 => esc_html__('Body Font', 'toppic'),
				'description'  => esc_html__('Default: Roboto', 'toppic'),
				'section'    => 'kktfwp_fonts',
				'type' 		 => 'kktfwp_google_font',
				'priority'   => 5,
				'settings'   => array(
					'default' => 'kktfwp_body_font[font]',
					'variant' => 'kktfwp_body_font[variant]',
				),
				'auto_control'  => 'font',
				'auto_preview'  => true,
				'js_vars' => array(
					'element'  => '.kktfwp-site-content, .kktfwp-footer, a.has-overlay .proj-content .proj-title, .comment-list li.comment > article .comment-author .fn, .kktfwp-envira #envirabox-title, .woocommerce .kktfwp-woocommerce ul.products li.product h3',
					'function' => 'css',
					'property' => 'fontWeight',
				)
			) ) );
	
			
			/*
			// Blogname & description
			*/
			
			$wp_customize->get_setting( 'blogname' )->transport  = 'postMessage';
			$wp_customize->get_setting( 'kktfwp_logo' )->transport  = 'postMessage';
			$wp_customize->get_setting( 'kktfwp_logo2x' )->transport  = 'postMessage';
			$wp_customize->get_setting( 'kktfwp_logo_dark' )->transport  = 'postMessage';
			$wp_customize->get_setting( 'kktfwp_logo_dark2x' )->transport  = 'postMessage';
			
			$wp_customize->selective_refresh->add_partial( 'blogname', array(
				'selector' => '.logo',
				'render_callback' => function() {
					return kktfwp_the_custom_logo();
				}
			) );
			
			$wp_customize->selective_refresh->add_partial( 'logoimage', array(
				'selector' => '.logo',
				'settings' => array (
					'kktfwp_logo',
					'kktfwp_logo2x',
					'kktfwp_logo_dark',
					'kktfwp_logo_dark2x'
				),
				'render_callback' => function() {
					return kktfwp_the_custom_logo();
				}
			) );	
		}		
	}
	
	require_once get_theme_file_path( '/includes/customizer/class-kktfwp-customizer.php' );
	require_once get_theme_file_path( '/includes/customizer/class-kktfwp-customize-control.php' );
	require_once get_theme_file_path( '/includes/customizer/class-kktfwp-customize-control-color.php' );
}