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

$newsxo_default = newsxo_get_default_theme_options();

Newsxo_Customizer_Control::add_panel(
	'header_option_panel',
	array(
        'title' => __('Header Options', 'newsxo'),
        'priority' => 6,
        'capability' => 'edit_theme_options',
	)
);


    // Header Image
    Newsxo_Customizer_Control::add_section(
        'header_image',
        array(
            'title' => esc_html__( 'Header Image', 'newsxo' ),  
            'priority' => 5, 
            'panel' => 'header_option_panel',
        )
    );
        // Enable/Disable header image overlay color
        Newsxo_Customizer_Control::add_field( 
            array(
                'type'     => 'checkbox', 
                'settings'  => 'remove_header_image_overlay',
                'label' => esc_html__('Remove Overlay Color', 'newsxo'),
                'section'  => 'header_image',
                'default' => false,
                'sanitize_callback' => 'newsxo_sanitize_checkbox',
            )
        );
        Newsxo_Customizer_Control::add_field( 
            array(
                'type'     => 'color-alpha', 
                'settings'  => 'newsxo_header_overlay_color',
                'label' => esc_html__('Background Color', 'newsxo'),
                'section'  => 'header_image',
                'default' => '',
                'sanitize_callback' => 'newsxo_sanitize_alpha_color',
                'active_callback'   => function( $setting ) {
                    if ( $setting->manager->get_setting( 'remove_header_image_overlay' )->value() == false ) {
                        return true;
                    }
                    return false;
                }
            )
        );
        Newsxo_Customizer_Control::add_field( 
            array(
                'type'     => 'newsxo-range', 
                'settings'  => 'header_image_height',
                'label' => esc_html__('Height', 'newsxo'),
                'section'  => 'header_image',
                'transport'         => 'postMessage',
                'media_query'   => true,
                'input_attr'    => array(
                    'mobile'  => array(
                        'min'           => 0,
                        'max'           => 300,
                        'step'          => 1,
                        'default_value' => 130,
                    ),
                    'tablet'  => array(
                        'min'           => 0,
                        'max'           => 400,
                        'step'          => 1,
                        'default_value' => 150,
                    ),
                    'desktop' => array(
                        'min'           => 0,
                        'max'           => 500,
                        'step'          => 1,
                        'default_value' => 200,
                    ),
                ),
            ),
        );
    // Add Section.
    Newsxo_Customizer_Control::add_section(
        'header_top_section',
        array(
            'title' => __('Top Section', 'newsxo'),
            'priority' => 5,
            'panel' => 'header_option_panel',
        )
    );

        $wp_customize->add_setting(
            'top_bar_tabs',
            array(
                'default'           => '',
                'capability' => 'edit_theme_options',
                'sanitize_callback' => 'sanitize_text_field',
            )
        );
        $wp_customize->add_control( new Custom_Tab_Control ( $wp_customize,'top_bar_tabs',
            array(
                'label'                 => '',
                'type' => 'custom-tab-control',
                'section'               => 'header_top_section',
                'controls_general'      => json_encode( array(
                                                            '#customize-control-', 
                                                            '#customize-control-newsxo_header_topbar_repeater',
                ) ),
                'controls_design'       => json_encode( array( 
                                                            '#customize-control-header_top_bar_heading',
                                                            '#customize-control-top_bar_color',
                                                            '#customize-control-top_bar_bg_color',
                                                            '#customize-control-header_ticker_heading',
                                                            '#customize-control-ticker_color',
                                                            '#customize-control-ticker_color_bg_color',
                ) ),
            )
        ));

        Newsxo_Customizer_Control::add_field(
            array(
                'type'     => 'newsxo-hf-repeater', 
                'settings'  => 'newsxo_header_topbar_repeater',
                'label'   => __( 'Elements', 'newsxo' ),
                'section'  => 'header_top_section',
                'default' => $newsxo_default['newsxo_header_topbar_repeater'],
                'sanitize_callback' => 'wp_kses_post',
                'transport' => 'postMessage',
                'fields' => array(
                    'select'   => true,
                    'column'   => true,
                    'position' => true,
                ),
                'select_choices' => array(
                    'date-time'        => __( 'Date & Time', 'newsxo' ),
                    'head-social-icon' => __( 'Social Icon', 'newsxo' ),
                    'logo-title'       => __( 'Site Identity', 'newsxo' ),
                    'pri-menus'        => __( 'Primary Menus', 'newsxo' ),
                    'right-nav'        => __( 'Right Nav', 'newsxo'),
                    'ticker'           => __( 'Breaking', 'newsxo' ),
                    'custom-html'      => __( 'Custom HTML (Pro)', 'newsxo' ),
                    'top-nav'          => __( 'Top Navigation (Pro)', 'newsxo' ),
                    'widget-1'         => __( 'Widget 1 (Pro)', 'newsxo' ),
                    'widget-2'         => __( 'Widget 2 (Pro)', 'newsxo' ),
                    'widget-3'         => __( 'Widget 3 (Pro)', 'newsxo' ),
                ),
                'disabled_choices' => array(
                    'custom-html',
                    'top-nav',
                    'widget-1',
                    'widget-2',
                    'widget-3',
                ),
                'select_label'    => __( 'Choose Element', 'newsxo' ),
                'column_label'    => __( 'Column Width (%)', 'newsxo' ),
                'position_label'  => __( 'Alignment', 'newsxo' ),
                'add_button_text' => __( 'Add Element', 'newsxo' ),
                'edit_button_text' => __( 'Edit Element Settings', 'newsxo' ),

                'element_sections' => array(
                    'date-time'         =>   'date_time_section',
                    'head-social-icon'  =>   'social_icon_options',
                    'right-nav'         =>   'right_nav_section',
                    'ticker'            =>   'breaking_news_section'
                ),

                'element_panels' => array(
                    'logo-title'        =>   'newsxo_site_identity_panel',
                    'pri-menus'         =>   'nav_menus',
                ),
            )
        );
        
        // $wp_customize->add_setting( 'newsxo_head_top_upsell', array(
        //     'sanitize_callback' => 'esc_attr'
        // ) );
        // $wp_customize->add_control( new Newsxo_Pro_Upsell_Control( $wp_customize, 'newsxo_head_top_upsell', array(
        //     'label'           => __( 'Need more Header Options?', 'newsxo' ),
        //     'section'         => 'header_top_section',
        //     'features'        => array(
        //         __( 'Make This Section Sticky', 'newsxo' ),
        //         __( 'Add more header Elements', 'newsxo' ),
        //         __( 'Repeater Control for Social Icon', 'newsxo' ),
        //         __( 'Custom HTML 1', 'newsxo' ),
        //         __( 'Custom HTML 2', 'newsxo' ),
        //         __( 'Header Toggle Area', 'newsxo' ),
        //         __( 'Social Icon Area', 'newsxo' ),
        //         __( 'Advertisment Area', 'newsxo' ),
        //         __( 'Section background color', 'newsxo' ),
        //         __( 'And much More ...', 'newsxo' ),
        //     ),
        //     'url_pro'         => 'https://themeansar.com/themes/newsxo-pro/',
        //     'pro_button_text' => __( 'Upgrade to Pro ☆', 'newsxo' )
        // ) ) );

        // STYLE
        Newsxo_Customizer_Control::add_field( 
            array(
                'type'     => 'color-alpha', 
                'settings'  => 'top_bar_color',
                'label' => esc_html__('Color', 'newsxo'),
                'section'  => 'header_top_section',
                'default' => '',
                'sanitize_callback' => 'newsxo_sanitize_alpha_color',
            )
        );
        Newsxo_Customizer_Control::add_field( 
            array(
                'type'     => 'color-alpha', 
                'settings'  => 'top_bar_bg_color',
                'label' => esc_html__('Background Color', 'newsxo'),
                'section'  => 'header_top_section',
                'default' => '',
                'sanitize_callback' => 'newsxo_sanitize_alpha_color',
            )
        );
    
    // Add Section.
    Newsxo_Customizer_Control::add_section(
        'header_mid_section',
        array(
            'title' => __('Middle Section', 'newsxo'),
            'priority' => 10,
            'panel' => 'header_option_panel',
        )
    );
        Newsxo_Customizer_Control::add_field(
            array(
                'type'     => 'newsxo-hf-repeater', 
                'settings'  => 'newsxo_header_mid_repeater',
                'label'   => __( 'Elements', 'newsxo' ),
                'section'  => 'header_mid_section',
                'default' => $newsxo_default['newsxo_header_mid_repeater'],
                'sanitize_callback' => 'wp_kses_post',
                'transport' => 'postMessage',
                'fields' => array(
                    'select'   => true,
                    'column'   => true,
                    'position' => true,
                ),
                'select_choices' => array(
                    'date-time'        => __( 'Date & Time', 'newsxo' ),
                    'head-social-icon' => __( 'Social Icon', 'newsxo' ),
                    'logo-title'       => __( 'Site Identity', 'newsxo' ),
                    'pri-menus'        => __( 'Primary Menus', 'newsxo' ),
                    'right-nav'        => __( 'Right Nav', 'newsxo'),
                    'ticker'           => __( 'Breaking', 'newsxo' ),
                    'custom-html'      => __( 'Custom HTML (Pro)', 'newsxo' ),
                    'top-nav'          => __( 'Top Navigation (Pro)', 'newsxo' ),
                    'widget-1'         => __( 'Widget 1 (Pro)', 'newsxo' ),
                    'widget-2'         => __( 'Widget 2 (Pro)', 'newsxo' ),
                    'widget-3'         => __( 'Widget 3 (Pro)', 'newsxo' ),
                ),
                'disabled_choices' => array(
                    'custom-html',
                    'top-nav',
                    'widget-1',
                    'widget-2',
                    'widget-3',
                ),
                'select_label'    => __( 'Choose Element', 'newsxo' ),
                'column_label'    => __( 'Column Width (%)', 'newsxo' ),
                'position_label'  => __( 'Alignment', 'newsxo' ),
                'add_button_text' => __( 'Add Element', 'newsxo' ),
                'edit_button_text' => __( 'Edit Element Settings', 'newsxo' ),

                'element_sections' => array(
                    'date-time'         =>   'date_time_section',
                    'head-social-icon'  =>   'social_icon_options',
                    'right-nav'         =>   'right_nav_section',
                    'ticker'            =>   'breaking_news_section'
                ),

                'element_panels' => array(
                    'logo-title'        =>   'newsxo_site_identity_panel',
                    'pri-menus'         =>   'nav_menus',
                ),
            )
        );
        
        // $wp_customize->add_setting( 'newsxo_head_mid_upsell', array(
        //     'sanitize_callback' => 'esc_attr'
        // ) );
        // $wp_customize->add_control( new Newsxo_Pro_Upsell_Control( $wp_customize, 'newsxo_head_mid_upsell', array(
        //     'label'           => __( 'Need more Header Options?', 'newsxo' ),
        //     'section'         => 'header_mid_section',
        //     'features'        => array(
        //         __( 'Make This Section Sticky', 'newsxo' ),
        //         __( 'Add more header Elements', 'newsxo' ),
        //         __( 'Repeater Control for Social Icon', 'newsxo' ),
        //         __( 'Custom HTML 1', 'newsxo' ),
        //         __( 'Custom HTML 2', 'newsxo' ),
        //         __( 'Header Toggle Area', 'newsxo' ),
        //         __( 'Social Icon Area', 'newsxo' ),
        //         __( 'Advertisment Area', 'newsxo' ),
        //         __( 'Section background color', 'newsxo' ),
        //         __( 'And much More ...', 'newsxo' ),
        //     ),
        //     'url_pro'         => 'https://themeansar.com/themes/newsxo-pro/',
        //     'pro_button_text' => __( 'Upgrade to Pro ☆', 'newsxo' )
        // ) ) );
    
    // Sticky Header
    Newsxo_Customizer_Control::add_section(
        'sticky_header',
        array(
            'title' => esc_html__( 'Sticky Header', 'newsxo' ), 
            'panel' => 'header_option_panel',
            'priority' => 10,
        )
    );
        Newsxo_Customizer_Control::add_field( 
            array(
                'type'     => 'toggle', 
                'settings'  => 'sticky_header_toggle',
                'label' => esc_html__('Sticky Header', 'newsxo'),
                'section'  => 'sticky_header',
                'default' => true,
                'sanitize_callback' => 'newsxo_sanitize_checkbox',
            )
        );
    // Add Section.
    Newsxo_Customizer_Control::add_section(
        'header_bottom_section',
        array(
            'title' => __('Bottom Section', 'newsxo'),
            'priority' => 15,
            'panel' => 'header_option_panel',
        )
    );
        Newsxo_Customizer_Control::add_field(
            array(
                'type'     => 'newsxo-hf-repeater', 
                'settings'  => 'newsxo_header_bottom_repeater',
                'label'   => __( 'Elements', 'newsxo' ),
                'section'  => 'header_bottom_section',
                'default' => $newsxo_default['newsxo_header_bottom_repeater'],
                'sanitize_callback' => 'wp_kses_post',
                'transport' => 'postMessage',
                'fields' => array(
                    'select'   => true,
                    'column'   => true,
                    'position' => true,
                ),
                'select_choices' => array(
                    'date-time'        => __( 'Date & Time', 'newsxo' ),
                    'head-social-icon' => __( 'Social Icon', 'newsxo' ),
                    'logo-title'       => __( 'Site Identity', 'newsxo' ),
                    'pri-menus'        => __( 'Primary Menus', 'newsxo' ),
                    'right-nav'        => __( 'Right Nav', 'newsxo'),
                    'ticker'           => __( 'Breaking', 'newsxo' ),
                    'custom-html'      => __( 'Custom HTML (Pro)', 'newsxo' ),
                    'top-nav'          => __( 'Top Navigation (Pro)', 'newsxo' ),
                    'widget-1'         => __( 'Widget 1 (Pro)', 'newsxo' ),
                    'widget-2'         => __( 'Widget 2 (Pro)', 'newsxo' ),
                    'widget-3'         => __( 'Widget 3 (Pro)', 'newsxo' ),
                ),
                'disabled_choices' => array(
                    'custom-html',
                    'top-nav',
                    'widget-1',
                    'widget-2',
                    'widget-3',
                ),
                'select_label'    => __( 'Choose Element', 'newsxo' ),
                'column_label'    => __( 'Column Width (%)', 'newsxo' ),
                'position_label'  => __( 'Alignment', 'newsxo' ),
                'add_button_text' => __( 'Add Element', 'newsxo' ),
                'edit_button_text' => __( 'Edit Element Settings', 'newsxo' ),

                'element_sections' => array(
                    'date-time'         =>   'date_time_section',
                    'head-social-icon'  =>   'social_icon_options',
                    'right-nav'         =>   'right_nav_section',
                    'ticker'            =>   'breaking_news_section'
                ),

                'element_panels' => array(
                    'logo-title'        =>   'newsxo_site_identity_panel',
                    'pri-menus'         =>   'nav_menus',
                ),
            )
        );

        // $wp_customize->add_setting( 'newsxo_head_bottom_upsell', array(
        //     'sanitize_callback' => 'esc_attr'
        // ) );
        // $wp_customize->add_control( new Newsxo_Pro_Upsell_Control( $wp_customize, 'newsxo_head_bottom_upsell', array(
        //     'label'           => __( 'Need more Header Options?', 'newsxo' ),
        //     'section'         => 'header_bottom_section',
        //     'features'        => array(
        //         __( 'Make This Section Sticky', 'newsxo' ),
        //         __( 'Add more header Elements', 'newsxo' ),
        //         __( 'Repeater Control for Social Icon', 'newsxo' ),
        //         __( 'Custom HTML 1', 'newsxo' ),
        //         __( 'Custom HTML 2', 'newsxo' ),
        //         __( 'Header Toggle Area', 'newsxo' ),
        //         __( 'Social Icon Area', 'newsxo' ),
        //         __( 'Advertisment Area', 'newsxo' ),
        //         __( 'Section background color', 'newsxo' ),
        //         __( 'And much More ...', 'newsxo' ),
        //     ),
        //     'url_pro'         => 'https://themeansar.com/themes/newsxo-pro/',
        //     'pro_button_text' => __( 'Upgrade to Pro ☆', 'newsxo' )
        // ) ) );
        
    // Add Section.
    Newsxo_Customizer_Control::add_section(
        'header_extra_section',
        array(
            'title' => __('News Ticker Section', 'newsxo'),
            'priority' => 20,
            'panel' => 'header_option_panel',
        )
    );
        Newsxo_Customizer_Control::add_field(
            array(
                'type'     => 'newsxo-hf-repeater', 
                'settings'  => 'newsxo_header_extra_repeater',
                'label'   => __( 'Elements', 'newsxo' ),
                'section'  => 'header_extra_section',
                'default' => $newsxo_default['newsxo_header_extra_repeater'],
                'sanitize_callback' => 'wp_kses_post',
                'transport' => 'postMessage',
                'fields' => array(
                    'select'   => true,
                    'column'   => true,
                    'position' => true,
                ),
                'select_choices' => array(
                    'date-time'        => __( 'Date & Time', 'newsxo' ),
                    'head-social-icon' => __( 'Social Icon', 'newsxo' ),
                    'logo-title'       => __( 'Site Identity', 'newsxo' ),
                    'pri-menus'        => __( 'Primary Menus', 'newsxo' ),
                    'right-nav'        => __( 'Right Nav', 'newsxo'),
                    'ticker'           => __( 'Breaking', 'newsxo' ),
                    'custom-html'      => __( 'Custom HTML (Pro)', 'newsxo' ),
                    'top-nav'          => __( 'Top Navigation (Pro)', 'newsxo' ),
                    'widget-1'         => __( 'Widget 1 (Pro)', 'newsxo' ),
                    'widget-2'         => __( 'Widget 2 (Pro)', 'newsxo' ),
                    'widget-3'         => __( 'Widget 3 (Pro)', 'newsxo' ),
                ),
                'disabled_choices' => array(
                    'custom-html',
                    'top-nav',
                    'widget-1',
                    'widget-2',
                    'widget-3',
                ),
                'select_label'    => __( 'Choose Element', 'newsxo' ),
                'column_label'    => __( 'Column Width (%)', 'newsxo' ),
                'position_label'  => __( 'Alignment', 'newsxo' ),
                'add_button_text' => __( 'Add Element', 'newsxo' ),
                'edit_button_text' => __( 'Edit Element Settings', 'newsxo' ),

                'element_sections' => array(
                    'date-time'         =>   'date_time_section',
                    'head-social-icon'  =>   'social_icon_options',
                    'right-nav'         =>   'right_nav_section',
                    'ticker'            =>   'breaking_news_section'
                ),

                'element_panels' => array(
                    'logo-title'        =>   'newsxo_site_identity_panel',
                    'pri-menus'         =>   'nav_menus',
                ),
            )
        );
        
        // $wp_customize->add_setting( 'newsxo_head_extra_upsell', array(
        //     'sanitize_callback' => 'esc_attr'
        // ) );
        // $wp_customize->add_control( new Newsxo_Pro_Upsell_Control( $wp_customize, 'newsxo_head_extra_upsell', array(
        //     'label'           => __( 'Need more Header Options?', 'newsxo' ),
        //     'section'         => 'header_extra_section',
        //     'features'        => array(
        //         __( 'Make This Section Sticky', 'newsxo' ),
        //         __( 'Add more header Elements', 'newsxo' ),
        //         __( 'Repeater Control for Social Icon', 'newsxo' ),
        //         __( 'Custom HTML 1', 'newsxo' ),
        //         __( 'Custom HTML 2', 'newsxo' ),
        //         __( 'Header Toggle Area', 'newsxo' ),
        //         __( 'Social Icon Area', 'newsxo' ),
        //         __( 'Advertisment Area', 'newsxo' ),
        //         __( 'Section background color', 'newsxo' ),
        //         __( 'And much More ...', 'newsxo' ),
        //     ),
        //     'url_pro'         => 'https://themeansar.com/themes/newsxo-pro/',
        //     'pro_button_text' => __( 'Upgrade to Pro ☆', 'newsxo' )
        // ) ) );
    // Add Section.
    Newsxo_Customizer_Control::add_section(
        'header_element_heading',
        array(
            'title' => __('Header Element', 'newsxo'),
            'priority' => 25,
            'panel' => 'header_option_panel',
        )
    );