<?php
/**
 * Theme Customizer Controls
 *
 * @package somalite
 */


if ( ! function_exists( 'somalite_customizer_topbar_register' ) ) :
function somalite_customizer_topbar_register( $wp_customize ) {
 
 	//Top Header Bar Settings
    $wp_customize->add_section(
        'soma_top_bar_settings',
        array (
            'priority'      => 25,
            'capability'    => 'edit_theme_options',
            'theme_supports'=> '',
            'title'         => esc_html__( 'Top Bar Settings', 'somalite' )
        )
    );
   
    // Title label
	$wp_customize->add_setting( 
		'somalite_label_topbar_settings_title', 
		array(
		    'sanitize_callback' => 'somalite_sanitize_title',
		) 
	);

	$wp_customize->add_control( 
		new Somalite_Title_Info_Control( $wp_customize, 'somalite_label_topbar_settings_title', 
		array(
		    'label'       => esc_html__( 'Topbar Settings', 'somalite' ),
		    'section'     => 'soma_top_bar_settings',
		    'type'        => 'somalite-title',
		    'settings'    => 'somalite_label_topbar_settings_title',
		) 
	));

    // top phone
    $wp_customize->add_setting(
        'sm_topbar_phone',
        array(
            'type' => 'theme_mod',
            'default'           => '',
            'sanitize_callback' => 'somalite_sanitize_text_field'
        )
    );

    $wp_customize->add_control(
        'sm_topbar_phone',
        array(
            'settings'      => 'sm_topbar_phone',
            'section'       => 'soma_top_bar_settings',
            'type'          => 'textbox',
            'label'         => esc_html__( 'Topbar Phone Number', 'somalite' ),
            'description'   => esc_html__( 'Add your phone number.', 'somalite' )
        )
    );

    $wp_customize->selective_refresh->add_partial( 'sm_topbar_phone', array(
        'selector'            => 'span.topbar-phone',   
        'settings'            => 'sm_topbar_phone',     
        'render_callback'     => 'somalite_topbar_phone_render_callback',
        'fallback_refresh'    => false, 
    ));


    // Title label
    $wp_customize->add_setting( 
        'somalite_label_topbar_icon1_settings', 
        array(
            'sanitize_callback' => 'somalite_sanitize_title',
        ) 
    );

    $wp_customize->add_control( 
        new Somalite_Title_Info_Control( $wp_customize, 'somalite_label_topbar_icon1_settings', 
        array(
            'label'       => esc_html__( 'Icon 1 Settings', 'somalite' ),
            'section'     => 'soma_top_bar_settings',
            'type'        => 'somalite-title',
            'settings'    => 'somalite_label_topbar_icon1_settings',
        ) 
    ));

    // top social icon1
    $wp_customize->add_setting(
        'sm_topbar_icon1',
        array(
            'type' => 'theme_mod',
            'default'           => '',
            'sanitize_callback' => 'somalite_sanitize_text_field'
        )
    );

    $wp_customize->add_control(
        'sm_topbar_icon1',
        array(
            'settings'      => 'sm_topbar_icon1',
            'section'       => 'soma_top_bar_settings',
            'type'          => 'textbox',
            'label'         => esc_html__( 'Topbar Icon 1', 'somalite' ),
            'description'   => esc_html__( 'Add fontawesome code here eg fa-facebook.', 'somalite' )
        )
    );

    // top social icon1_url
    $wp_customize->add_setting(
        'sm_topbar_icon1_url',
        array(
            'type' => 'theme_mod',
            'default'           => '',
            'sanitize_callback' => 'somalite_sanitize_url'
        )
    );

    $wp_customize->add_control(
        'sm_topbar_icon1_url',
        array(
            'settings'      => 'sm_topbar_icon1_url',
            'section'       => 'soma_top_bar_settings',
            'type'          => 'textbox',
            'label'         => esc_html__( 'Topbar Icon 1 Url', 'somalite' ),
            'description'   => esc_html__( 'Add icon url', 'somalite' )
        )
    );

    // Title label
    $wp_customize->add_setting( 
        'somalite_label_topbar_icon2_settings', 
        array(
            'sanitize_callback' => 'somalite_sanitize_title',
        ) 
    );

    $wp_customize->add_control( 
        new Somalite_Title_Info_Control( $wp_customize, 'somalite_label_topbar_icon2_settings', 
        array(
            'label'       => esc_html__( 'Icon 2 Settings', 'somalite' ),
            'section'     => 'soma_top_bar_settings',
            'type'        => 'somalite-title',
            'settings'    => 'somalite_label_topbar_icon2_settings',
        ) 
    ));

    // top social icon2
    $wp_customize->add_setting(
        'sm_topbar_icon2',
        array(
            'type' => 'theme_mod',
            'default'           => '',
            'sanitize_callback' => 'somalite_sanitize_text_field'
        )
    );

    $wp_customize->add_control(
        'sm_topbar_icon2',
        array(
            'settings'      => 'sm_topbar_icon2',
            'section'       => 'soma_top_bar_settings',
            'type'          => 'textbox',
            'label'         => esc_html__( 'Topbar Icon 2', 'somalite' ),
            'description'   => esc_html__( 'Add fontawesome code here eg fa-twitter. Note: fa-twitter will show X icon', 'somalite' )
        )
    );

    // top social icon2_url
    $wp_customize->add_setting(
        'sm_topbar_icon2_url',
        array(
            'type' => 'theme_mod',
            'default'           => '',
            'sanitize_callback' => 'somalite_sanitize_url'
        )
    );

    $wp_customize->add_control(
        'sm_topbar_icon2_url',
        array(
            'settings'      => 'sm_topbar_icon2_url',
            'section'       => 'soma_top_bar_settings',
            'type'          => 'textbox',
            'label'         => esc_html__( 'Topbar Icon 2 Url', 'somalite' ),
            'description'   => esc_html__( 'Add icon url', 'somalite' )
        )
    );

    // Title label
    $wp_customize->add_setting( 
        'somalite_label_topbar_icon3_settings', 
        array(
            'sanitize_callback' => 'somalite_sanitize_title',
        ) 
    );

    $wp_customize->add_control( 
        new Somalite_Title_Info_Control( $wp_customize, 'somalite_label_topbar_icon3_settings', 
        array(
            'label'       => esc_html__( 'Icon 3 Settings', 'somalite' ),
            'section'     => 'soma_top_bar_settings',
            'type'        => 'somalite-title',
            'settings'    => 'somalite_label_topbar_icon3_settings',
        ) 
    ));

    // top social icon3
    $wp_customize->add_setting(
        'sm_topbar_icon3',
        array(
            'type' => 'theme_mod',
            'default'           => '',
            'sanitize_callback' => 'somalite_sanitize_text_field'
        )
    );

    $wp_customize->add_control(
        'sm_topbar_icon3',
        array(
            'settings'      => 'sm_topbar_icon3',
            'section'       => 'soma_top_bar_settings',
            'type'          => 'textbox',
            'label'         => esc_html__( 'Topbar Icon 3', 'somalite' ),
            'description'   => esc_html__( 'Add fontawesome code here eg fa-instagram.', 'somalite' )
        )
    );

    // top social icon3_url
    $wp_customize->add_setting(
        'sm_topbar_icon3_url',
        array(
            'type' => 'theme_mod',
            'default'           => '',
            'sanitize_callback' => 'somalite_sanitize_url'
        )
    );

    $wp_customize->add_control(
        'sm_topbar_icon3_url',
        array(
            'settings'      => 'sm_topbar_icon3_url',
            'section'       => 'soma_top_bar_settings',
            'type'          => 'textbox',
            'label'         => esc_html__( 'Topbar Icon 3 Url', 'somalite' ),
            'description'   => esc_html__( 'Add icon url', 'somalite' )
        )
    );

}
endif;

add_action( 'customize_register', 'somalite_customizer_topbar_register' );