<?php
function expert_construction_company_header_settings( $wp_customize ) {
$selective_refresh = isset( $wp_customize->selective_refresh ) ? 'postMessage' : 'refresh';

    // Site Title Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'expert_construction_company_site_title_setting' , 
			array(
			'default' => true,
			'sanitize_callback' => 'expert_construction_company_sanitize_checkbox',
			'capability' => 'edit_theme_options',
		) 
	);
	
	$wp_customize->add_control(
	'expert_construction_company_site_title_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Site Title', 'expert-construction-company' ),
			'section'     => 'title_tagline',
			'settings'    => 'expert_construction_company_site_title_setting',
			'type'        => 'checkbox'
		) 
	);

	// Tagline Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'expert_construction_company_tagline_setting' , 
			array(
			'default' => false,
			'sanitize_callback' => 'expert_construction_company_sanitize_checkbox',
			'capability' => 'edit_theme_options',
		) 
	);
	
	$wp_customize->add_control(
	'expert_construction_company_tagline_setting', 
		array(
			'label'	      => esc_html__( 'Hide / Show Tagline', 'expert-construction-company' ),
			'section'     => 'title_tagline',
			'settings'    => 'expert_construction_company_tagline_setting',
			'type'        => 'checkbox'
		) 
	);

	// Add the setting for logo width
	$wp_customize->add_setting(
		'expert_construction_company_logo_width',
		array(
			'default'           => '170',
			'sanitize_callback' => 'expert_construction_company_sanitize_logo_width',
			'priority'          => 2,
		)
	);

	// Add control for logo width
	$wp_customize->add_control( 
		'expert_construction_company_logo_width',
		array(
			'label'     => __('Logo Width', 'expert-construction-company'),
			'section'   => 'title_tagline',
			'type'      => 'number',
			'input_attrs' => array(
				'min'   => 1,
				'max'   => 150,
				'step'  => 1,
			),
			'transport' => $selective_refresh,
		)  
	);

	$wp_customize->add_setting( 'expert_construction_company_upgrade_page_settings_583',
	array(
		'sanitize_callback' => 'sanitize_text_field'
	)
	);
	$wp_customize->add_control( new Expert_Construction_Company_Control_Upgrade(
		$wp_customize, 'expert_construction_company_upgrade_page_settings_583',
			array(
				'priority'      => 200,
				'section'       => 'title_tagline',
				'settings'      => 'expert_construction_company_upgrade_page_settings_583',
				'label'         => __( 'Expert Construction Company Pro comes with additional features.', 'expert-construction-company' ),
				'choices'       => array( __( '15+ Ready-Made Sections', 'expert-construction-company' ), __( 'One-Click Demo Import', 'expert-construction-company' ), __( 'WooCommerce Integrated', 'expert-construction-company' ), __( 'Drag & Drop Section Reordering', 'expert-construction-company' ),__( 'Advanced Typography Control', 'expert-construction-company' ),__( 'Intuitive Customization Options', 'expert-construction-company' ),__( '24/7 Support', 'expert-construction-company' ), )
			)
		)
	);

	/*=========================================
	Expert Construction Company Site Identity
	=========================================*/
	$wp_customize->add_section(
        'title_tagline',
        array(
        	'priority'      => 1,
            'title' 		=> __('Site Identity','expert-construction-company'),
			'panel'  		=> 'expert_construction_company_frontpage_sections',
		)
    );

	$wp_customize->register_panel_type( 'expert_construction_company_WP_Customize_Panel' );
	$wp_customize->register_section_type( 'Expert_Construction_Company_WP_Customize_Section' );

}
add_action( 'customize_register', 'expert_construction_company_header_settings' );

if ( class_exists( 'WP_Customize_Panel' ) ) {
  	class expert_construction_company_WP_Customize_Panel extends WP_Customize_Panel {
	   public $panel;
	   public $type = 'expert_construction_company_panel';
	   public function json() {

	      $array = wp_array_slice_assoc( (array) $this, array( 'id', 'description', 'priority', 'type', 'panel', ) );
	      $array['title'] = html_entity_decode( $this->title, ENT_QUOTES, get_bloginfo( 'charset' ) );
	      $array['content'] = $this->get_content();
	      $array['active'] = $this->active();
	      $array['instanceNumber'] = $this->instance_number;
	      return $array;
    	}
  	}
}

if ( class_exists( 'WP_Customize_Section' ) ) {
  	class Expert_Construction_Company_WP_Customize_Section extends WP_Customize_Section {
	   public $section;
	   public $type = 'expert_construction_company_section';
	   public function json() {

	      $array = wp_array_slice_assoc( (array) $this, array( 'id', 'description', 'priority', 'panel', 'type', 'description_hidden', 'section', ) );
	      $array['title'] = html_entity_decode( $this->title, ENT_QUOTES, get_bloginfo( 'charset' ) );
	      $array['content'] = $this->get_content();
	      $array['active'] = $this->active();
	      $array['instanceNumber'] = $this->instance_number;

	      if ( $this->panel ) {
	        $array['customizeAction'] = sprintf( 'Customizing &#9656; %s', esc_html( $this->manager->get_panel( $this->panel )->title ) );
	      } else {
	        $array['customizeAction'] = 'Customizing';
	      }
	      return $array;
    	}
  	}
}