<?php
/**
 * Menu options
 *
 * @package Theme Palace
 * @subpackage  Charity Give
 * @since  Charity Give 1.0.0
 */

// Add sidebar section
$wp_customize->add_section( 'charity_give_menu',
	array(
		'title'             => esc_html__('Header Menu','charity-give'),
		'description'       => esc_html__( 'Header Menu options.', 'charity-give' ),
		'panel'             => 'nav_menus',
	)
);

$wp_customize->add_setting( 'charity_give_theme_options[search_icon_in_primary_menu_enable]', array(
	'sanitize_callback' => 'charity_give_sanitize_switch_control',
	'default'           => $options['search_icon_in_primary_menu_enable'],
) );

$wp_customize->add_control( new Charity_Give_Switch_Control( $wp_customize, 'charity_give_theme_options[search_icon_in_primary_menu_enable]', array(
	'label'             => esc_html__( 'Enable Search', 'charity-give' ),
	'section'           => 'charity_give_menu',
	'on_off_label' 		=> charity_give_switch_options(),
) ) );

// button enable setting and control.
$wp_customize->add_setting( 'charity_give_theme_options[nav_btn]', array(
	'sanitize_callback' => 'charity_give_sanitize_switch_control',
	'default'           => $options['nav_btn'],
) );

$wp_customize->add_control( new Charity_Give_Switch_Control( $wp_customize, 'charity_give_theme_options[nav_btn]', array(
	'label'             => esc_html__( 'Enable Button', 'charity-give' ),
	'section'           => 'charity_give_menu',
	'on_off_label' 		=> charity_give_switch_options(),
) ) );

// button text setting and control
$wp_customize->add_setting( 'charity_give_theme_options[nav_btn_txt]', array(
	'sanitize_callback' => 'sanitize_text_field',
	'default'			=> $options['nav_btn_txt'],
	'transport'			=> 'postMessage',
) );

$wp_customize->add_control( 'charity_give_theme_options[nav_btn_txt]', array(
	'label'           	=> esc_html__( 'Button Label', 'charity-give' ),
	'active_callback' 	=> 'charity_give_is_nav_btn_enable',
	'section'        	=> 'charity_give_menu',
) );

// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'charity_give_theme_options[nav_btn_txt]', array(
		'selector'            => '#site-menu li.custom-menu-item a',
		'settings'            => 'charity_give_theme_options[nav_btn_txt]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'charity_give_nav_btn_txt_partial',
    ) );
}

// button url setting and control
$wp_customize->add_setting( 'charity_give_theme_options[nav_btn_url]', array(
	'sanitize_callback' => 'esc_url_raw',
	'default'			=> $options['nav_btn_url'],
) );

$wp_customize->add_control( 'charity_give_theme_options[nav_btn_url]', array(
	'label'           	=> esc_html__( 'Button URL', 'charity-give' ),
	'section'        	=> 'charity_give_menu',
	'active_callback' 	=> 'charity_give_is_nav_btn_enable',
	'type'				=> 'url'
) );