<?php
/**
 * Topbar Section options
 *
 * @package Theme Palace
 * @subpackage Enlightme
 * @since Enlightme 1.0.0
 */

// Add Topbar section
$wp_customize->add_section( 'enlightme_topbar_section', array(
	'title'             => esc_html__( 'Topbar','enlightme' ),
	'description'       => esc_html__( 'Topbar Section options.', 'enlightme' ),
	'panel'             => 'enlightme_front_page_panel',
) );

// topbar enable/disable control and setting
$wp_customize->add_setting( 'enlightme_theme_options[topbar_section_enable]', array(
	'default'			=> 	$options['topbar_section_enable'],
	'sanitize_callback' => 'enlightme_sanitize_switch_control',
) );

$wp_customize->add_control( new Enlightme_Switch_Control( $wp_customize, 'enlightme_theme_options[topbar_section_enable]', array(
	'label'             => esc_html__( 'Topbar Section Enable', 'enlightme' ),
	'section'           => 'enlightme_topbar_section',
	'on_off_label' 		=> enlightme_switch_options(),
) ) );

// Topbar content enable control and setting
$wp_customize->add_setting( 'enlightme_theme_options[social_menu_enable]', array(
	'default'			=> 	$options['social_menu_enable'],
	'sanitize_callback' => 'enlightme_sanitize_switch_control',
) );

$wp_customize->add_control( new Enlightme_Switch_Control( $wp_customize, 'enlightme_theme_options[social_menu_enable]', array(
	'label'             => esc_html__( 'Social Menu Enable', 'enlightme' ),
	'description'       => sprintf( '%1$s <a class="topbar-menu-trigger" href="#"> %2$s </a> %3$s', esc_html__( 'Note: To show secondary and social menu.', 'enlightme' ), esc_html__( 'Click Here', 'enlightme' ), esc_html__( 'to create menu', 'enlightme' ) ),
	'section'           => 'enlightme_topbar_section',
	'active_callback'   => 'enlightme_is_topbar_section_enable',
	'on_off_label' 		=> enlightme_switch_options(),
) ) );

$wp_customize->add_setting( 'enlightme_theme_options[topbar_field_1]', array(
    'default'           =>  $options['topbar_field_1'],
    'sanitize_callback' => 'sanitize_text_field',
) );

$wp_customize->add_control('enlightme_theme_options[topbar_field_1]', array(
    'label'             => esc_html__( 'Contact Number', 'enlightme' ),
    'section'           => 'enlightme_topbar_section',
    'type'              => 'text',
    'active_callback'   => 'enlightme_is_topbar_section_enable',
 ) );

$wp_customize->add_setting( 'enlightme_theme_options[topbar_field_2]', array(
    'default'           =>  $options['topbar_field_2'],
    'sanitize_callback' => 'sanitize_text_field',
) );

$wp_customize->add_control('enlightme_theme_options[topbar_field_2]', array(
    'label'             => esc_html__( 'Contact Email', 'enlightme' ),
    'section'           => 'enlightme_topbar_section',
    'type'              => 'text',
    'active_callback'   => 'enlightme_is_topbar_section_enable',
 ) );

 // topbar enable/disable control and setting
$wp_customize->add_setting( 'enlightme_theme_options[topbar_btn]', array(
	'default'			=> 	$options['topbar_btn'],
	'sanitize_callback' => 'enlightme_sanitize_switch_control',
) );

$wp_customize->add_control( new Enlightme_Switch_Control( $wp_customize, 'enlightme_theme_options[topbar_btn]', array(
	'label'             => esc_html__( 'Topbar Button Enable', 'enlightme' ),
	'section'           => 'enlightme_topbar_section',
	'on_off_label' 		=> enlightme_switch_options(),
	'active_callback'   => 'enlightme_is_topbar_section_enable',
) ) );

$wp_customize->add_setting( 'enlightme_theme_options[topbar_btn_title]', array(
    'default'           =>  $options['topbar_btn_title'],
    'sanitize_callback' => 'sanitize_text_field',
    'transport'			=> 'postMessage',
) );

$wp_customize->add_control('enlightme_theme_options[topbar_btn_title]', array(
    'label'             => esc_html__( 'Button Label', 'enlightme' ),
    'section'           => 'enlightme_topbar_section',
    'type'              => 'text',
    'active_callback'   => 'enlightme_is_topbar_btn_enable',
 ) );

// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'enlightme_theme_options[topbar_btn_title]', array(
		'selector'            => '.latest-content-title .page-header h2',
		'settings'            => 'enlightme_theme_options[topbar_btn_title]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'enlightme_topbar_btn_title_partial',
    ) );
}

$wp_customize->add_setting( 'enlightme_theme_options[topbar_btn_url]', array(
	'sanitize_callback' => 'esc_url_raw',
	'default'			=> $options['topbar_btn_url']
) );

$wp_customize->add_control( 'enlightme_theme_options[topbar_btn_url]', array(
	'label'           	=> esc_html__( 'Button Url', 'enlightme' ),
	'section'        	=> 'enlightme_topbar_section',
	'active_callback' 	=> 'enlightme_is_topbar_btn_enable',
	'type'				=> 'url',
) );