<?php 
/**
 * Header Option Panel
 *
 * @package Newsxo
 */

$newsxo_default = newsxo_get_default_theme_options();

// Add Panel
Newsxo_Customizer_Control::add_panel(
	'newsxo_site_identity_panel',
	array(
        'title' => esc_html__('Site Identity', 'newsxo'),
        'priority' => 5,
        'capability' => 'edit_theme_options',
	)
);
// Add Section.
Newsxo_Customizer_Control::add_section(
	'title_tagline',
	array(
		'title' => esc_html__( 'Logo & Site Icon', 'newsxo' ), 
        'panel' => 'newsxo_site_identity_panel',
	)
);

Newsxo_Customizer_Control::add_field( 
	array(
		'type'     => 'newsxo-range', 
        'settings'  => 'side_main_logo_width',
        'label' => esc_html__('Logo Width', 'newsxo'),
		'section'  => 'title_tagline',
        'transport'         => 'postMessage',
        'media_query'   => true,
        'input_attr'    => array(
            'mobile'  => array(
                'min'           => 0,
                'max'           => 300,
                'step'          => 1,
                'default_value' => 150,
            ),
            'tablet'  => array(
                'min'           => 0,
                'max'           => 350,
                'step'          => 1,
                'default_value' => 200,
            ),
            'desktop' => array(
                'min'           => 0,
                'max'           => 400,
                'step'          => 1,
                'default_value' => 250,
            ),
        ),
    ),
);
// Add Section.
Newsxo_Customizer_Control::add_section(
	'newsxo_site_title_section',
	array(
		'title' => esc_html__( 'Site Title & Tagline', 'newsxo' ), 
        'panel' => 'newsxo_site_identity_panel',
	)
);

$wp_customize->get_control( 'blogname' )->section = 'newsxo_site_title_section';
$wp_customize->get_control( 'display_header_text' )->section = 'newsxo_site_title_section';
$wp_customize->get_control( 'display_header_text' )->label = esc_html__( 'Display Site Title', 'newsxo' );
$wp_customize->get_control( 'blogdescription' )->section = 'newsxo_site_title_section';

Newsxo_Customizer_Control::add_field( 
	array(
		'type'     => 'newsxo-range', 
        'settings'  => 'site_title_font_size',
        'label' => esc_html__('Site Title Size', 'newsxo'),
		'section'  => 'newsxo_site_title_section',
        'transport'         => 'postMessage',
        'media_query'   => true,
        'input_attr'    => array(
            'mobile'  => array(
                'min'           => 0,
                'max'           => 100,
                'step'          => 1,
                'default_value' => 30,
            ),
            'tablet'  => array(
                'min'           => 0,
                'max'           => 110,
                'step'          => 1,
                'default_value' => 35,
            ),
            'desktop' => array(
                'min'           => 0,
                'max'           => 120,
                'step'          => 1,
                'default_value' => 40,
            ),
        ),
    ),
);
Newsxo_Customizer_Control::add_field( 
    array(
        'type'              => 'checkbox', 
        'settings'          => 'display_header_tagline',
        'label'             => esc_html__('Display Tagline', 'newsxo'),
        'section'           => 'newsxo_site_title_section',
        'transport'         => 'postMessage',
        'priority'          => 100,
        'default'           => false,
        'sanitize_callback' => 'newsxo_sanitize_checkbox',
    )
);
// Enable/Disable header image overlay color
Newsxo_Customizer_Control::add_field( 
    array(
        'type'     => 'checkbox', 
        'settings'  => 'header_text_center',
        'label' => esc_html__('Display Center Site Title and Tagline', 'newsxo'),
        'section'  => 'newsxo_site_title_section',
        'priority'          => 100,
        'default' => false,
        'sanitize_callback' => 'newsxo_sanitize_checkbox',
    )
);
// Advertisement Section.
// Newsxo_Customizer_Control::add_section(
// 	'header_advert_section',
// 	array(
// 		'title' => esc_html__( 'Banner Advertisement', 'newsxo' ), 
//         'panel' => 'header_option_2_panel',
//         // 'priority' => 3,
// 	)
// );
// Setting banner_advertisement_section. 
Newsxo_Customizer_Control::add_field( 
	array(
		'type'     => 'cropped_image', 
        'settings'  => 'banner_ad_image',
        'label' => esc_html__('Banner Advertisement', 'newsxo'),
        'description' => sprintf(esc_html__('Recommended Size %1$s px X %2$s px', 'newsxo'), 930, 100),
        'section' => 'header_advert_section',
        'default' => $newsxo_default['banner_ad_image'],
        'width' => 930,
        'height' => 100,
        'flex_width' => true,
        'flex_height' => true,
        'sanitize_callback' => 'absint',
	)
);
/*banner_advertisement_section_url*/
Newsxo_Customizer_Control::add_field( 
	array(
		'type'     => 'text', 
        'settings'  => 'banner_ad_url',
        'label' => esc_html__('Link', 'newsxo'),
		'section'  => 'header_advert_section',
        'priority' => 15,
        'default' => '#',
        'sanitize_callback' => 'esc_url_raw',
	)
);

Newsxo_Customizer_Control::add_field( 
	array(
		'type'     => 'toggle', 
        'settings'  => 'banner_open_on_new_tab',
        'label' => esc_html__('Open link in a new tab', 'newsxo'),
		'section'  => 'header_advert_section',
        'priority' => 16,
        'default' => true,
        'sanitize_callback' => 'newsxo_sanitize_checkbox',
	)
);

// Header Rightbar
Newsxo_Customizer_Control::add_section(
	'header_rightbar',
	array(
		'title' => esc_html__( 'Menu', 'newsxo' ), 
        'panel' => 'header_option_2_panel',
        'priority' => 5,
	)
);