<?php

// Load customize controls.
//require get_template_directory().'/inc/customizer/class-custom-toggle-control.php';
get_template_part( '/inc/customizer/class-custom-toggle-control' );
//require get_template_directory().'/inc/customizer/class-custom-range-control.php';
get_template_part( '/inc/customizer/class-custom-range-control' );


/* Customizer Settings
/* ------------------------------------ */
function luxuryconceptfree_customize_register( $wp_customize ) {


	
			/* Invert color logo when using transparent header  */
			$wp_customize->add_setting( 'luxuryconceptfree_logo_invert_color' , array(
				'default'   => 0,
				'transport' => 'refresh',
				'sanitize_callback' => 'luxuryconceptfree_sanitize_callback_checkbox',
			));

			$wp_customize->add_control( new luxuryconceptfree_Customizer_Toggle_Control( $wp_customize, 'luxuryconceptfree_logo_invert_color_control', array(
				'label'      => __( 'Invert color logo', 'luxuryconceptfree' ),
				'description'  => __( 'You can invert the color logo (ex. from black to white)', 'luxuryconceptfree' ),
				'section'    => 'title_tagline',
				'settings'   => 'luxuryconceptfree_logo_invert_color'
			)) );	

			
			/* Display Site Title (no logo)  */
			$wp_customize->add_setting( 'luxuryconceptfree_site_title' , array(
				'default'   => 1,
				'transport' => 'refresh',
				'sanitize_callback' => 'luxuryconceptfree_sanitize_callback_checkbox',
			));

			$wp_customize->add_control( new luxuryconceptfree_Customizer_Toggle_Control( $wp_customize, 'luxuryconceptfree_site_title_control', array(
				'label'      => __( 'Display Site Title', 'luxuryconceptfree' ),
				'section'    => 'title_tagline',
				'settings'   => 'luxuryconceptfree_site_title'
			)) );	


			/* Display Site Description Tagline (no logo)  */
			$wp_customize->add_setting( 'luxuryconceptfree_site_description' , array(
				'default'   => 0,
				'transport' => 'refresh',
				'sanitize_callback' => 'luxuryconceptfree_sanitize_callback_checkbox',
			));

			$wp_customize->add_control( new luxuryconceptfree_Customizer_Toggle_Control( $wp_customize, 'luxuryconceptfree_site_description_control', array(
				'label'      => __( 'Display Site Description', 'luxuryconceptfree' ),
				'section'    => 'title_tagline',
				'settings'   => 'luxuryconceptfree_site_description'
			)) );	





	$wp_customize->add_panel( 'luxuryconceptfree_getpremium', array(
				'title' => __( 'GET PREMIUM for more functionalities', 'luxuryconceptfree' ),
				'description' => __( 'All Theme Settings', 'luxuryconceptfree' ), 
				'priority' => 1, // Mixed with top-level-section hierarchy.
	) );





  	$wp_customize->add_panel( 'luxuryconceptfree_main', array(
  				'title' => __( 'Luxury Concept Settings', 'luxuryconceptfree' ),
	  			'description' => __( 'All Theme Settings', 'luxuryconceptfree' ), 
  				'priority' => 2, // Mixed with top-level-section hierarchy.
  	) );
	
	
	/* --- Typography Section --- */
	$wp_customize->add_section( 'luxuryconceptfree_typography' , array(
    'title'      => __( 'Typography', 'luxuryconceptfree' ),
	'panel' => 'luxuryconceptfree_main',
    'priority'   => 1,
	));
	      		

			/* Font Name */
			$wp_customize->add_setting( 'luxuryconceptfree_google_font' , array(
				'default'   => 'Inter',
				'transport' => 'refresh',
				'sanitize_callback' => 'luxuryconceptfree_sanitize_callback_text',
			));

			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'luxuryconceptfree_google_font_control', array(
				'label'      => __( 'Google Font (ex. Roboto )', 'luxuryconceptfree' ),
				'section'    => 'luxuryconceptfree_typography',
				'settings'   => 'luxuryconceptfree_google_font',
				'type'   => 'text'			
			)) );

			/* Font Weights */
			$wp_customize->add_setting( 'luxuryconceptfree_google_font_weight' , array(
				'default'   => '300,400,700',
				'transport' => 'refresh',
				'sanitize_callback' => 'luxuryconceptfree_sanitize_callback_text',
			));

			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'luxuryconceptfree_google_font_weight_control', array(
				'label'      => __( 'Font Weight (ex. 300,400,700 )', 'luxuryconceptfree' ),
				'section'    => 'luxuryconceptfree_typography',
				'settings'   => 'luxuryconceptfree_google_font_weight',
				'type'   => 'text'			
			)));
	
			/* Global Site Font Size */
			$wp_customize->add_setting( 'luxuryconceptfree_site_font_size' , array(
				'default'   => '16px',
				'transport' => 'refresh',
				'sanitize_callback' => 'luxuryconceptfree_sanitize_callback_text',
			));

			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'luxuryconceptfree_site_font_size_control', array(
				'label'      => __( 'Global Font Size (ex. 16px, 2rem, 80%)', 'luxuryconceptfree' ),
				'section'    => 'luxuryconceptfree_typography',
				'settings'   => 'luxuryconceptfree_site_font_size',
				'type'   => 'text'			
			)));
		   /* --- End Typography Section --- */ 
	
			/* TITLE 1 (h1) Font Size */
			$wp_customize->add_setting( 'luxuryconceptfree_title1_font_size' , array(
				'default'   => '2.4rem',
				'transport' => 'refresh',
				'sanitize_callback' => 'luxuryconceptfree_sanitize_callback_text',
			));

			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'luxuryconceptfree_title1_font_size_control', array(
				'label'      => __( 'Title 1 Font Size - h1 (ex. 16px, 2rem, 80%)', 'luxuryconceptfree' ),
				'section'    => 'luxuryconceptfree_typography',
				'settings'   => 'luxuryconceptfree_title1_font_size',
				'type'   => 'text'			
			)));
		   /* --- End Typography Section --- */ 
	
			/* TITLE 2 (h2) Font Size */
			$wp_customize->add_setting( 'luxuryconceptfree_title2_font_size' , array(
				'default'   => '1.5rem',
				'transport' => 'refresh',
				'sanitize_callback' => 'luxuryconceptfree_sanitize_callback_text',
			));

			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'luxuryconceptfree_title2_font_size_control', array(
				'label'      => __( 'Title 2 Font Size - h2 (ex. 16px, 2rem, 80%)', 'luxuryconceptfree' ),
				'section'    => 'luxuryconceptfree_typography',
				'settings'   => 'luxuryconceptfree_title2_font_size',
				'type'   => 'text'			
			)));
		   /* --- End Typography Section --- */ 

		
	
	
		
	/* --- Colors Section --- */
			/* Link color */
			$wp_customize->add_setting( 'luxuryconceptfree_link_color' , array(
				'default'   => '#45cfbe',
				'transport' => 'refresh',
				'sanitize_callback' => 'sanitize_hex_color',
			));

			$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'luxuryconceptfree_link_color_control', array(
				'label'      => __( 'Link Color', 'luxuryconceptfree' ),
				'section'    => 'colors',
				'settings'   => 'luxuryconceptfree_link_color',
			)));


			/* Link color hover */
			$wp_customize->add_setting( 'luxuryconceptfree_link_color_hover' , array(
				'default'   => '#3eb2bc',
				'transport' => 'refresh',
				'sanitize_callback' => 'sanitize_hex_color',
			));

			$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'luxuryconceptfree_link_color_hover_control', array(
				'label'      => __( 'Link Color Hover', 'luxuryconceptfree' ),
				'section'    => 'colors',
				'settings'   => 'luxuryconceptfree_link_color_hover',
			)));

			/* Header Background Color */
			$wp_customize->add_setting( 'luxuryconceptfree_header_bg_color' , array(
				'default'   => '#FFFFFF',
				'transport' => 'refresh',
				'sanitize_callback' => 'sanitize_hex_color',
			));

			$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'luxuryconceptfree_header_bg_color_control', array(
				'label'      => __( 'Header Color', 'luxuryconceptfree' ),
				'section'    => 'colors',
				'settings'   => 'luxuryconceptfree_header_bg_color',
			)));
	
			/* TOPBAR Color */
			$wp_customize->add_setting( 'luxuryconceptfree_topbar_background_color' , array(
				'default'   => '#45cfbe',
				'transport' => 'refresh',
				'sanitize_callback' => 'sanitize_hex_color',
			));

			$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'luxuryconceptfree_topbar_background_color_control', array(
				'label'      => __( 'Top Bar Background Color', 'luxuryconceptfree' ),
				'section'    => 'colors',
				'settings'   => 'luxuryconceptfree_topbar_background_color',
			)));
	
			/* TOPBAR text Color */
			$wp_customize->add_setting( 'luxuryconceptfree_topbar_text_color' , array(
				'default'   => '#FFFFFF',
				'transport' => 'refresh',
				'sanitize_callback' => 'sanitize_hex_color',
			));

			$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'luxuryconceptfree_topbar_text_color_control', array(
				'label'      => __( 'Top Bar Text Color', 'luxuryconceptfree' ),
				'section'    => 'colors',
				'settings'   => 'luxuryconceptfree_topbar_text_color',
			)));

			/* Border Color */
			$wp_customize->add_setting( 'luxuryconceptfree_border_color' , array(
				'default'   => '#eaeaea',
				'transport' => 'refresh',
				'sanitize_callback' => 'sanitize_hex_color',
			));

			$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'luxuryconceptfree_border_color_control', array(
				'label'      => __( 'Border Color', 'luxuryconceptfree' ),
				'section'    => 'colors',
				'settings'   => 'luxuryconceptfree_border_color',
			)));
	
			/* Global Site Text Color */
			$wp_customize->add_setting( 'luxuryconceptfree_site_text_color' , array(
				'default'   => '#000000',
				'transport' => 'refresh',
				'sanitize_callback' => 'sanitize_hex_color',
			));

			$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'luxuryconceptfree_site_text_color_control', array(
				'label'      => __( 'Global Site Text Color', 'luxuryconceptfree' ),
				'section'    => 'colors',
				'settings'   => 'luxuryconceptfree_site_text_color',
			)));
	
	
			/* Header Text Color With Transparent Header */
			$wp_customize->add_setting( 'luxuryconceptfree_header_transparent_text_color' , array(
				'default'   => '#FFFFFF',
				'transport' => 'refresh',
				'sanitize_callback' => 'sanitize_hex_color',
			));

			$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'luxuryconceptfree_header_transparent_text_color_control', array(
				'label'      => __( 'Header Transparent Text Color', 'luxuryconceptfree' ),
				'description'      => __( 'Header Text Color when you set Home Page template with transparent header', 'luxuryconceptfree' ),
				'section'    => 'colors',
				'settings'   => 'luxuryconceptfree_header_transparent_text_color',
			)));
	
			/* Posts Background Color */
			$wp_customize->add_setting( 'luxuryconceptfree_posts_background_color' , array(
				'default'   => '#f9f9f9',
				'transport' => 'refresh',
				'sanitize_callback' => 'sanitize_hex_color',
			));

			$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'luxuryconceptfree_posts_background_color_control', array(
				'label'      => __( 'Posts Background Color', 'luxuryconceptfree' ),
				'section'    => 'colors',
				'settings'   => 'luxuryconceptfree_posts_background_color',
			)));
	
	
    /* --- END Colors Section --- */
	

	/* --- Layout & Header Section --- */
	$wp_customize->add_section( 'luxuryconceptfree_layouts' , array(
		'title'      => __( 'Layouts & Header', 'luxuryconceptfree' ),
		'panel' => 'luxuryconceptfree_main',
    	'priority'   => 2,
	));
	
			/* Layout Type (Full witdth or Boxed) */	
			$wp_customize->add_setting( 'luxuryconceptfree_layout_type' , array(
				'default'   => 'full',
				'transport' => 'refresh',
				'sanitize_callback' => 'luxuryconceptfree_sanitize_callback_select',
			));

			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'luxuryconceptfree_layout_type_control', array(
				'label'      => __( 'Full width or Boxed layout', 'luxuryconceptfree' ),
				'section'    => 'luxuryconceptfree_layouts',
				'settings'   => 'luxuryconceptfree_layout_type',
				'type'   	 => 'select',
				'choices' => array(
						'full' => __( 'Full width layout', 'luxuryconceptfree' ),
						'disabled' => __( 'PRO FEATURE - Boxed layout', 'luxuryconceptfree' ),
  				)
			)) );


			/* Max Width Grid Wrapper Layout with Full Layout */
			$wp_customize->add_setting( 'luxuryconceptfree_wrapper_max_width' , array(
				'default'   => '1300px',
				'transport' => 'refresh',
				'sanitize_callback' => 'luxuryconceptfree_sanitize_callback_text',
			));

			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'luxuryconceptfree_wrapper_max_width_control', array(
				'label'      => __( 'Max Width Grid Wrapper Layout (Default 1300px) - Only works With Full Width Layout selected ', 'luxuryconceptfree' ),
				'section'    => 'luxuryconceptfree_layouts',
				'settings'   => 'luxuryconceptfree_wrapper_max_width',
				'type'   => 'text'			
			)) );	
			
	
			/* Content Padding with Full Layout */
			$wp_customize->add_setting( 'luxuryconceptfree_content_padding' , array(
				'default'   => '5%',
				'transport' => 'refresh',
				'sanitize_callback' => 'luxuryconceptfree_sanitize_callback_text',
			));

			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'luxuryconceptfree_content_padding_control', array(
				'label'      => __( 'Content Padding (Left / Right) (ex. 3% or 20px) - Only works With Full Width Layout selected ', 'luxuryconceptfree' ),
				'section'    => 'luxuryconceptfree_layouts',
				'settings'   => 'luxuryconceptfree_content_padding',
				'type'   => 'text'			
			)) );
	
	
	
	
			/* Sticky Header */
			$wp_customize->add_setting( 'luxuryconceptfree_sticky_header' , array(
				'default'   => 1,
				'transport' => 'refresh',
				'sanitize_callback' => 'luxuryconceptfree_sanitize_callback_checkbox',
			));

			$wp_customize->add_control( new luxuryconceptfree_Customizer_Toggle_Control( $wp_customize, 'luxuryconceptfree_sticky_header_control', array(
				'label'      => __( 'Enable Sticky Header', 'luxuryconceptfree' ),
				'section'    => 'luxuryconceptfree_layouts',
				'settings'   => 'luxuryconceptfree_sticky_header'
			)) );	
	
	

			/* Center Logo */
			$wp_customize->add_setting( 'luxuryconceptfree_center_logo_menu_left' , array(
				'default'   => 'no',
				'transport' => 'refresh',
				'sanitize_callback' => 'luxuryconceptfree_sanitize_callback_select',
			));

			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'luxuryconceptfree_center_logo_menu_left_control', array(
				'label'      => __( 'Logo and Menu Position', 'luxuryconceptfree' ),
				'section'    => 'luxuryconceptfree_layouts',
				'settings'   => 'luxuryconceptfree_center_logo_menu_left',
				'type'   => 'select',
				'choices' => array(
						'no' => __( 'Left Logo / Center Menu', 'luxuryconceptfree' ),
						'disabled' => __( 'PRO FEATURE - Left Menu / Center Logo', 'luxuryconceptfree' ),
  				)				
			)) );
	
	
			/* Article Image After Title */
			$wp_customize->add_setting( 'luxuryconceptfree_article_img' , array(
				'default'   => 'no',
				'transport' => 'refresh',
				'sanitize_callback' => 'luxuryconceptfree_sanitize_callback_select',
			));
			
			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'luxuryconceptfree_article_img_control', array(
				'label'      => __( 'Article list image', 'luxuryconceptfree' ),
				'section'    => 'luxuryconceptfree_layouts',
				'settings'   => 'luxuryconceptfree_article_img',
				'type'   => 'select',
				'choices' => array(
						'no' => __( 'Don\'t Show Image', 'luxuryconceptfree' ),
						'disabled' => __( 'PRO FEATURE - Before Title', 'luxuryconceptfree' ),
						'after' => __( 'After Title', 'luxuryconceptfree' ),
  				)
			)) );
	
	
			/* Blog numbers column */	
			$wp_customize->add_setting( 'luxuryconceptfree_number_col_blog' , array(
				'default'   => 3,
				'transport' => 'refresh',
				'sanitize_callback' => 'luxuryconceptfree_sanitize_callback_number_range',
			));			

	
			$wp_customize->add_control( new luxuryconceptfree_Customizer_Range_Control( $wp_customize, 'luxuryconceptfree_number_col_blog_control', array(
			   'type' => 'range',
			   'section' => 'luxuryconceptfree_layouts',
			   'settings' => 'luxuryconceptfree_number_col_blog',
			   'label' => __( 'Blog Number Columns', 'luxuryconceptfree' ),
			   'input_attrs' => array(
								 'min' => 1,
								 'max' => 6,
								 'step' => 1,
			  ),
			) ) );
	
		
			/* Show Header and Footer Borders */
			$wp_customize->add_setting( 'luxuryconceptfree_header_footer_borders' , array(
				'default'   => 1,
				'transport' => 'refresh',
				'sanitize_callback' => 'luxuryconceptfree_sanitize_callback_checkbox',
			));

			$wp_customize->add_control( new luxuryconceptfree_Customizer_Toggle_Control( $wp_customize, 'luxuryconceptfree_header_footer_borders_control', array(
				'label'      => __( 'Show Header and Footer Borders', 'luxuryconceptfree' ),
				'section'    => 'luxuryconceptfree_layouts',
				'settings'   => 'luxuryconceptfree_header_footer_borders'
			)) );	
	
		
			/* Breadcrumbs */	
			$wp_customize->add_setting( 'luxuryconceptfree_breadcrumbs' , array(
				'default'   => 'no',
				'transport' => 'refresh',
				'sanitize_callback' => 'luxuryconceptfree_sanitize_callback_select',
			));

			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'luxuryconceptfree_breadcrumbs_control', array(
				'label'      => __( 'Breadcrumbs', 'luxuryconceptfree' ),
				'section'    => 'luxuryconceptfree_layouts',
				'settings'   => 'luxuryconceptfree_breadcrumbs',
				'type'   	 => 'select',
				'choices' => array(
						'no' => __( 'Don\'t show Breadcrumbs', 'luxuryconceptfree' ),
						'disabled' => __( 'PRO FEATURE - Show Custom theme Breadcrumbs', 'luxuryconceptfree' ),
						'yoast' => __( 'Show YOAST SEO Breadcrumbs', 'luxuryconceptfree' ),
  				)
			)) );
		
	
    /* --- END Header Section --- */
		


/* Sanitize function Text */
function luxuryconceptfree_sanitize_callback_text( $luxuryconceptfree_input_to_sanitize ) {    
		return sanitize_text_field( $luxuryconceptfree_input_to_sanitize );	
	}
	
/* Sanitize function Checkbox (Toggle) */
function luxuryconceptfree_sanitize_callback_checkbox( $luxuryconceptfree_input_to_sanitize ) {
		return ( 1 === absint( $luxuryconceptfree_input_to_sanitize ) ) ? 1 : 0;
	}
	
}

/* Sanitize function Hex Color */
function luxuryconceptfree_sanitize_callback_hex_color( $hex_color, $setting ) {
	// Sanitize $input as a hex value without the hash prefix.
	$hex_color = sanitize_hex_color( $hex_color );
	
	// If $input is a valid hex value, return it; otherwise, return the default.
	return ( ! is_null( $hex_color ) ? $hex_color : $setting->default );
}

/* Sanitize function Number Range */
function luxuryconceptfree_sanitize_callback_number_range( $number, $setting ) {
	// Ensure input is an absolute integer.
	$number = absint( $number );
	
	// Get the input attributes associated with the setting.
	$atts = $setting->manager->get_control( ($setting->id) . '_control' )->input_attrs;
	
	// Get minimum number in the range.
	$min = ( isset( $atts['min'] ) ? $atts['min'] : $number );
	
	// Get maximum number in the range.
	$max = ( isset( $atts['max'] ) ? $atts['max'] : $number );
	
	// Get step.
	$step = ( isset( $atts['step'] ) ? $atts['step'] : 1 );
	
	// If the number is within the valid range, return it; otherwise, return the default
	return ( $min <= $number && $number <= $max && is_int( $number / $step ) ? $number : $setting->default );
}

/* Sanitize function Select */
function luxuryconceptfree_sanitize_callback_select( $input, $setting ) {
      $input   = sanitize_key( $input );
      $choices = $setting->manager->get_control( $setting->id . '_control' )->choices;
      return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
}


add_action( 'customize_register', 'luxuryconceptfree_customize_register' );
