<?php
/**
 * Register Title Content section, settings and controls for Theme Customizer
 *
 */
if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly.
}
// Add Title/Logo Settings
add_action( 'customize_register', 'pmthemes_customize_register_title_settings' );
function pmthemes_customize_register_title_settings( $wp_customize ) {
    // Get Default Fonts from settings
    $theme_def = pmthemes_default_options();
    // Add Upload logo image setting
    $wp_customize->add_setting( 'pmthemes_theme_options[header_logo]', array(
            'default'           => '',
            'type'           	=> 'option',
            'transport'         => 'refresh',
            'sanitize_callback' => 'esc_url'
        )
    );
    $wp_customize->add_control( new WP_Customize_Image_Control(
            $wp_customize, 'pmthemes_control_header_logo', array(
                'label'    => __( 'Logo Image', 'pmthemes' ),
                'section'  => 'title_tagline',
                'settings' => 'pmthemes_theme_options[header_logo]',
                'priority' => 2,
            )
        )
    );
    // Add Header Tagline option
    $wp_customize->add_setting( 'pmthemes_theme_options[header_tagline]', array(
            'default'           => $theme_def['header_tagline'],
            'type'           	=> 'option',
            'transport'         => 'refresh',
            'sanitize_callback' => 'pmthemes_sanitize_checkbox'
        )
    );
    $wp_customize->add_control( 'pmthemes_control_header_tagline', array(
            'label'    => __( 'Display tagline below site title', 'pmthemes' ),
            'section'  => 'title_tagline',
            'settings' => 'pmthemes_theme_options[header_tagline]',
            'type'     => 'checkbox',
            'priority' => 10,
        )
    );
    // Title Font Size
    $wp_customize->add_setting( 'pmthemes_theme_options[title_font_size]' , array(
            'default'           => '50',
            'type'           	=> 'option',
            'transport'         => 'postMessage',
            'sanitize_callback' => 'pmthemes_sanitize_number'
        )
    );
    $wp_customize->add_control( new WP_Customize_Range( $wp_customize, 'pmthemes_control_title_font_size', array(
            'label'    => __( 'Title Font Size', 'pmthemes' ),
            'section'  => 'title_tagline',
            'settings' => 'pmthemes_theme_options[title_font_size]',
            'active_callback' => 'pmthemes_check_header_logo',
            'priority' => 17,
            'min' => 25,
            'max' => 150,
            'step' => 1,
            'unit' => 'px',
        ) )
    );
    // Font Size if Mobile
    $wp_customize->add_setting( 'pmthemes_theme_options[title_font_size_mobile]' , array(
            'default'           => '30',
            'type'           	=> 'option',
            'transport'         => 'postMessage',
            'sanitize_callback' => 'pmthemes_sanitize_number'
        )
    );
    $wp_customize->add_control( new WP_Customize_Range( $wp_customize, 'pmthemes_control_title_font_size_mobile', array(
            'label'    => __( 'Font Size if Mobile', 'pmthemes' ),
            'section'  => 'title_tagline',
            'settings' => 'pmthemes_theme_options[title_font_size_mobile]',
            'active_callback' => 'pmthemes_check_header_logo',
            'priority' => 18,
            'min' => 15,
            'max' => 50,
            'step' => 1,
            'unit' => 'px',
        ) )
    );
    // Title Font Spacing
    $wp_customize->add_setting( 'pmthemes_theme_options[title_font_space]', array(
            'default'           => '3',
            'type'           	=> 'option',
            'transport'         => 'postMessage',
            'sanitize_callback' => 'pmthemes_sanitize_number'
        )
    );
    $wp_customize->add_control( new WP_Customize_Range( $wp_customize, 'pmthemes_control_title_font_space', array(
            'label'    => __( 'Title Font Spacing', 'pmthemes' ),
            'section'  => 'title_tagline',
            'settings' => 'pmthemes_theme_options[title_font_space]',
            'active_callback' => 'pmthemes_check_header_logo',
            'priority' => 19,
            'min' => 0,
            'max' => 15,
            'step' => 1,
            'unit' => 'px',
        ))
    );
    // Description Font Size
    $wp_customize->add_setting( 'pmthemes_theme_options[title_describe_size]' , array(
            'default'           => '12',
            'type'           	=> 'option',
            'transport'         => 'postMessage',
            'sanitize_callback' => 'pmthemes_sanitize_number'
        )
    );
    $wp_customize->add_control( new WP_Customize_Range( $wp_customize, 'pmthemes_control_title_describe_size', array(
            'label'    => __( 'Tagline Font Size', 'pmthemes' ),
            'section'  => 'title_tagline',
            'settings' => 'pmthemes_theme_options[title_describe_size]',
            'active_callback' => 'pmthemes_site_tagline_active',
            'priority' => 20,
            'min' => 10,
            'max' => 75,
            'step' => 1,
            'unit' => 'px',
        ) )
    );
    // Logo & Banner Balance
    $wp_customize->add_setting( 'pmthemes_theme_options[logo_title_width]', array(
            'default'           => $theme_def['logo_title_width'],
            'type'           	=> 'option',
            'transport'         => 'postMessage',
            'sanitize_callback' => 'pmthemes_sanitize_number'
        )
    );
    $wp_customize->add_control( new WP_Customize_Range( $wp_customize, 'pmthemes_control_logo_title_width', array(
            'label'    => __( 'Logo & Banner Balance', 'pmthemes' ),
            'section'  => 'title_tagline',
            'settings' => 'pmthemes_theme_options[logo_title_width]',
            'priority' => 21,
            'min' => 5,
            'max' => 90,
            'step' => 0.5,
            'unit' => '%',
        ))
    );
}