<?php
/**
 * Register Header Content section, settings and controls for Theme Customizer
 *
 */
if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly.
}
// Add Header Settings
add_action( 'customize_register', 'pmthemes_customize_register_header_settings' );
function pmthemes_customize_register_header_settings( $wp_customize ) {
    // Get Default Fonts from settings
    $theme_def = pmthemes_default_options();
    // Add Header Section
    $wp_customize->add_section( 'pmthemes_section_header', array(
            'title'    => __( 'Header Settings', 'pmthemes' ),
            'priority' => 2,
            'panel' => 'pmthemes_options_panel'
        )
    );
	// Enable Facebook Open Graph Meta
    $wp_customize->add_setting( 'pmthemes_theme_options[fb_meta_graph]', array(
            'default'           => $theme_def['fb_meta_graph'],
            'type'           	=> 'option',
            'transport'         => 'refresh',
            'sanitize_callback' => 'pmthemes_sanitize_checkbox'
        )
    );
    $wp_customize->add_control( 'pmthemes_control_fb_meta_graph', array(
            'label'    => __( 'Enable FB Open Graph Meta', 'pmthemes' ),
            'section'  => 'pmthemes_section_header',
            'settings' => 'pmthemes_theme_options[fb_meta_graph]',
            'type'     => 'checkbox',
            'priority' => 1,
        )
    );
    // Default FB Image URL
    $wp_customize->add_setting( 'pmthemes_theme_options[default_fb_image]', array(
            'default'           => $theme_def['default_fb_image'],
            'type'           	=> 'option',
            'transport'         => 'postMessage',
            'sanitize_callback' => 'pmthemes_sanitize_read_text'
        )
    );
    $wp_customize->add_control( 'pmthemes_control_default_fb_image', array(
            'label'    => __( 'Default FB Image URL', 'pmthemes' ),
            'section'  => 'pmthemes_section_header',
            'settings' => 'pmthemes_theme_options[default_fb_image]',
            'active_callback' =>'pmthemes_fb_meta_graph_active',
            'type'     => 'text',
            'priority' => 2,
        )
    );
	// FB APP ID
	$wp_customize->add_setting( 'pmthemes_theme_options[fb_app_id]', array(
        'default'           => $theme_def['fb_app_id'],
		'type'           	=> 'option',
        'transport'         => 'postMessage',
        'sanitize_callback' => 'pmthemes_sanitize_read_text'
		)
	);
    $wp_customize->add_control( 'pmthemes_control_fb_app_id', array(
        'label'    => __( 'FB APP ID', 'pmthemes' ),
        'section'  => 'pmthemes_section_header',
        'settings' => 'pmthemes_theme_options[fb_app_id]',
        'type'     => 'text',
		'priority' => 4,
		)
	);
    // Header Tracking Code
    $wp_customize->add_setting( 'pmthemes_theme_options[header_code]', array(
            'default'           => $theme_def['header_code'],
            'type'           	=> 'option',
            'transport'         => 'postMessage',
            'sanitize_callback' => 'pmthemes_sanitize_header_code'
        )
    );
    $wp_customize->add_control( 'pmthemes_control_header_code', array(
            'label'    => __( 'Header Code', 'pmthemes' ),
            'section'  => 'pmthemes_section_header',
            'settings' => 'pmthemes_theme_options[header_code]',
            'type'     => 'textarea',
            'description' => 'For Google Verification Code, etc.',
            'priority' => 5,
        )
    );
    // Header Adjustments Control Title
    $wp_customize->add_setting( 'pmthemes_theme_options[hddr_adjust]', array(
            'default'           => '',
            'type'           	=> 'option',
            'transport'         => 'refresh',
            'sanitize_callback' => 'esc_attr'
        )
    );
    $wp_customize->add_control( new Pmthemes_Customize_Header_Control(
            $wp_customize, 'pmthemes_control_hddr_adjust', array(
                'label' => __( 'Header Adjustments', 'pmthemes' ),
                'section' => 'pmthemes_section_header',
                'settings' => 'pmthemes_theme_options[hddr_adjust]',
                'priority' => 6,
            )
        )
    );
    // Enable Header Adjustments
    $wp_customize->add_setting( 'pmthemes_theme_options[header_adjust]', array(
            'default'           => $theme_def['header_adjust'],
            'type'           	=> 'option',
            'transport'         => 'refresh',
            'sanitize_callback' => 'pmthemes_sanitize_checkbox'
        )
    );
    $wp_customize->add_control( 'pmthemes_control_header_adjust', array(
            'label'    => __( 'Show Header Adjustments', 'pmthemes' ),
            'section'  => 'pmthemes_section_header',
            'settings' => 'pmthemes_theme_options[header_adjust]',
            'type'     => 'checkbox',
            'priority' => 7,
        )
    );
    // Header Padding Controls
    // Header top
    $wp_customize->add_setting( 'pmthemes_theme_options[header_padding_top]', array(
            'default' 			=> $theme_def['header_padding_top'],
            'type' 				=> 'option',
            'transport' 		=> 'postMessage',
            'sanitize_callback' => 'pmthemes_sanitize_decimal_int',
        )
    );
    // Header right
    $wp_customize->add_setting( 'pmthemes_theme_options[header_padding_right]', array(
            'default' 			=> $theme_def['header_padding_right'],
            'type' 				=> 'option',
            'transport' 		=> 'postMessage',
            'sanitize_callback' => 'pmthemes_sanitize_decimal_int',
        )
    );
    // Header bottom
    $wp_customize->add_setting( 'pmthemes_theme_options[header_padding_bottom]', array(
            'default' 			=> $theme_def['header_padding_bottom'],
            'type' 				=> 'option',
            'transport' 		=> 'postMessage',
            'sanitize_callback' => 'pmthemes_sanitize_decimal_int',
        )
    );
    // Header left
    $wp_customize->add_setting( 'pmthemes_theme_options[header_padding_left]', array(
            'default' 			=> $theme_def['header_padding_left'],
            'type' 				=> 'option',
            'transport' 		=> 'postMessage',
            'sanitize_callback' => 'pmthemes_sanitize_decimal_int',
        )
    );
    // Header controls
    $wp_customize->add_control(new Pmthemes_Spacing_Control($wp_customize, 'header_spacing', array(
                'type' => 'pmthemes-spacing',
                'label'       => esc_html__( 'Header Padding (em)', 'pmthemes' ),
                'section'     => 'pmthemes_section_header',
                'description' => 'Default for all is 1.0',
                'settings'    => array(
                    'top'     => 'pmthemes_theme_options[header_padding_top]',
                    'right'   => 'pmthemes_theme_options[header_padding_right]',
                    'bottom'  => 'pmthemes_theme_options[header_padding_bottom]',
                    'left'    => 'pmthemes_theme_options[header_padding_left]',
                ),
                'active_callback' => 'pmthemes_header_adjust_active',
                'element' => 'header',
                'priority' => 8,
            )
        )
    );
    // Show Top Bar
    $wp_customize->add_setting( 'pmthemes_theme_options[topbar_show]', array(
            'default'           => $theme_def['topbar_show'],
            'type'           	=> 'option',
            'transport'         => 'refresh',
            'sanitize_callback' => 'pmthemes_sanitize_checkbox'
        )
    );
    $wp_customize->add_control( 'pmthemes_control_topbar_show', array(
            'label'    => __( 'Show Top Bar', 'pmthemes' ),
            'section'  => 'pmthemes_section_header',
            'settings' => 'pmthemes_theme_options[topbar_show]',
            'type'     => 'checkbox',
            'priority' => 11,
        )
    );
    // Top Bar Location
    $wp_customize->add_setting( 'pmthemes_theme_options[top_bar_loc]', array(
            'default'           => $theme_def['top_bar_loc'],
            'type'           	=> 'option',
            'transport'         => 'refresh',
            'sanitize_callback' => 'pmthemes_sanitize_top_bar_loc'
        )
    );
    $wp_customize->add_control( 'pmthemes_control_top_bar_loc', array(
            'label'    => __( 'Top Bar Location', 'pmthemes' ),
            'section'  => 'pmthemes_section_header',
            'settings' => 'pmthemes_theme_options[top_bar_loc]',
            'active_callback' =>'pmthemes_top_bar_active',
            'priority' => 12,
            'type'     => 'select',
            'choices'  => array(
                'top-bar-most' => __( 'Header Topmost', 'pmthemes' ),
                'top-bar-under' => __( 'Header Under', 'pmthemes'),
            )
        )
    );
    // Topbar Date
    $wp_customize->add_setting( 'pmthemes_theme_options[topbar_date]', array(
            'default'           => $theme_def['topbar_date'],
            'type'           	=> 'option',
            'transport'         => 'refresh',
            'sanitize_callback' => 'pmthemes_sanitize_checkbox'
        )
    );
    $wp_customize->add_control( 'pmthemes_control_topbar_date', array(
            'label'    => __( 'Show Date on Top Bar', 'pmthemes' ),
            'section'  => 'pmthemes_section_header',
            'settings' => 'pmthemes_theme_options[topbar_date]',
            'active_callback' =>'pmthemes_top_bar_active',
            'type'     => 'checkbox',
            'priority' => 13,
        )
    );
    // Topbar Social Icons
    $wp_customize->add_setting( 'pmthemes_theme_options[topbar_icons]', array(
            'default'           => $theme_def['topbar_icons'],
            'type'           	=> 'option',
            'transport'         => 'refresh',
            'sanitize_callback' => 'pmthemes_sanitize_checkbox'
        )
    );
    $wp_customize->add_control( 'pmthemes_control_topbar_icons', array(
            'label'    => __( 'Show Social Icons on Top Bar', 'pmthemes' ),
            'section'  => 'pmthemes_section_header',
            'settings' => 'pmthemes_theme_options[topbar_icons]',
            'active_callback' =>'pmthemes_top_bar_active',
            'type'     => 'checkbox',
            'priority' => 14,
        )
    );

    // Disable that Emoji
    $wp_customize->add_setting( 'pmthemes_theme_options[wp_emoji]', array(
            'default'           => $theme_def['wp_emoji'],
            'type'           	=> 'option',
            'transport'         => 'postMessage',
            'sanitize_callback' => 'pmthemes_sanitize_checkbox'
        )
    );
    $wp_customize->add_control( 'pmthemes_control_wp_emoji', array(
            'label'    => __( 'Disable Emoji', 'pmthemes' ),
            'section'  => 'pmthemes_section_header',
            'settings' => 'pmthemes_theme_options[wp_emoji]',
            'type'     => 'checkbox',
            'priority' => 15,
        )
    );

}