<?php
/**
 * Header Settings 
 *
 * @package Excel_Business
 */

function excel_business_customize_register_header( $wp_customize ){	
    
    //requiring repeater field
    require_once get_template_directory() . '/inc/customizer/repeater/class-repeater-setting.php';
    require_once get_template_directory() . '/inc/customizer/repeater/class-control-repeater.php';
    
    $wp_customize->add_panel( 'header_panel', array(
        'title'      => __( 'Header Settings', 'excel-business' ),
        'priority'   => 20,
        'capability' => 'edit_theme_options',
    ) );
    
    /** Move Site Identity section to Header Setting Panel */
    $wp_customize->get_section( 'title_tagline' )->panel = 'header_panel';
    
    /** Changing priority for static front page */
    $wp_customize->get_section( 'static_front_page' )->priority = 10;
    
        
    $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';
    
    /** Misc Settings */
    $wp_customize->add_section( 'header_misc_setting', array(
        'title'    => __( 'Misc Settings', 'excel-business' ),
        'priority' => 30,
        'panel'    => 'header_panel',
    ) );
    
    /** Header Email */
    $wp_customize->add_setting(
        'header_email',
        array(
            'default'           => 'info@exceltheme.com',
            'sanitize_callback' => 'sanitize_email',
        )
    );
    
    $wp_customize->add_control(
	   'header_email',
		array(
			'section'     => 'header_misc_setting',
			'label'	      => __( 'Header Email', 'excel-business' ),
            'description' => __( 'Add Email address here.', 'excel-business' ),
            'type'        => 'text'
		)		
	);
    
    /** Header Phone */
    $wp_customize->add_setting(
        'header_phone',
        array(
            'default'           => '(888) 123-4567',
            'sanitize_callback' => 'sanitize_text_field',
        )
    );
    
    $wp_customize->add_control(
        'header_phone',
        array(
            'label'       => __( 'Header Phone', 'excel-business' ),
            'description' => __( 'Add Telephone here.', 'excel-business' ),
            'section'     => 'header_misc_setting',
            'type'        => 'text',
        )
    );
    
    
    /** Social Links*/
    $wp_customize->add_setting( 
        new Excel_Repeater_Setting( 
            $wp_customize, 
            'social_links', 
            array(
                'default' => array(
                    array(
                        'url'   => 'http://facebook.com',
                        'font'  => 'fa-facebook',                        
                    ),
                    array(
                        'url'   => 'http://twitter.com',
                        'font'  => 'fa-twitter',                        
                    ),
                    array(
                        'url'   => 'http://linkedin.com',
                        'font'  => 'fa-linkedin',                        
                    ),
                    array(
                        'url'   => 'http://plus.google.com',
                        'font'  => 'fa-google-plus',                        
                    ),
                ),
                'sanitize_callback' => array( 'Excel_Repeater_Setting', 'sanitize_repeater_setting' ),
            ) 
        ) 
    );
    
    $wp_customize->add_control(
		new Excel_Control_Repeater(
			$wp_customize,
			'social_links',
			array(
				'section' => 'header_misc_setting',				
				'label'	  => __( 'Social Links', 'excel-business' ),
				'fields'  => array(
                    'font' => array(
            			'label'   => __( 'Font', 'excel-business' ),
            			'type'    => 'font',
            			'choices' => excel_business_get_fontawesome()
            		),
                    'url'     => array(
                        'type'  => 'url',
                        'label' => __( 'Link', 'excel-business' ),
                        'description'  => __( 'http://facebook.com', 'excel-business' ),
                    ),
                ),
                'row_label' => array(
                    'type' => 'field',
                    'value' => __( 'social link', 'excel-business' ),
                    'field' => 'url'
                ),                                             
			)
		)
	);
    
    /** Repeater Field Ends */
 
}
add_action( 'customize_register', 'excel_business_customize_register_header' );