<?php
/**
 * This contains customize function for regular and google fonts
 *
 * @package Postmagthemes
 * @subpackage Postmag
 */
function postmag_customize_fonts( $wp_customize ) {

	$wp_customize->add_panel( 'postmag_font_panel', array(
		'priority'	=> 21,
		'title'		=> __('Font setting', 'postmag' ),
	) );

	$wp_customize->add_section( 'site_brand_section', array(
		'title'     => __( 'Site Title Setting', 'postmag' ),
		'priority'  => 10,
		'panel'  	=> 'postmag_font_panel',
	) );
	
	$wp_customize->add_setting( 'brand_font_name', array(
		'default'   => 'impact',
		'transport' => 'refresh',
		'sanitize_callback' => 'sanitize_text_field',
	) );
	
	$wp_customize->add_control( 'brand_font_name', array(
		'label' 	=> __( 'Font name (Standard + Google)', 'postmag' ),
		'section' 	=> 'site_brand_section',
		'settings' 	=> 'brand_font_name',
		'type'		=> 'select',
		'choices' 	=> postmag_get_fonts(),
	) );
	
	$wp_customize->add_setting( 'brand_font_size', array(
		'default'   => '7',
		'transport'	=> 'refresh',
		'sanitize_callback' => 'postmag_sanitize_positive_integer_sitetitle',
	) );

	$wp_customize->add_control( 'brand_font_size', array(
		'label'       => __( 'Font Size', 'postmag' ),
		'section'     => 'site_brand_section',
		'settings'    => 'brand_font_size',
		'description' => __( 'Measurement is in Vmin. range( 5 to 8 )', 'postmag' ),
		'type' 		  => 'number',
		'input_attrs' => array(
			'min'		=> 4,
			'max' 	  	=> 8,
			'step'    	=> 0.2,
			
		),
	) );

	$wp_customize->add_setting( 'brand_font_style', array(
		'default'     => 'normal',
		'transport'   => 'refresh',
		'sanitize_callback' => 'postmag_sanitize_select',
	) );

	$wp_customize->add_control( 'brand_font_style', array(
		'label'		=> __( 'Font Style', 'postmag' ),
		'section'   => 'site_brand_section',
		'settings'  => 'brand_font_style',
		'type' 		=> 'select',
		'choices' 	=> array(
			'normal'	=> __( 'Normal', 'postmag' ),
			'italic'  	=> __( 'Italic', 'postmag' ),
		),
	) );

	$wp_customize->add_setting( 'brand_weight', array(
		'default'     => 'normal',
		'transport'   => 'refresh',
		'sanitize_callback' => 'postmag_sanitize_select',
	) );

	$wp_customize->add_control( 'brand_weight', array(
		'label'     => __( 'Font Weight', 'postmag' ),
		'section'   => 'site_brand_section',
		'settings'  => 'brand_weight',
		'type' 		=> 'select',
		'choices'	=> array(
			'normal'	=> __( 'Normal', 'postmag' ),
			'700' 		=> __( 'Bold', 'postmag' ),
		),
	) );

	// SECOND SECTION
	$wp_customize->add_section( 'menu_section', array(
		'title'     => __( 'Menu & Category Setting', 'postmag' ),
		'priority'  => 10,
		'panel'		=> 'postmag_font_panel',
	) );

	$wp_customize->add_setting( 'menu_font_name', array(
		'default'   => 'verdana',
		'transport' => 'refresh',
		'sanitize_callback' => 'sanitize_text_field',
	) );

	$wp_customize->add_control( 'menu_font_name', array(
		'label' 	=> __( 'Font name (Standard + Google)', 'postmag' ),
		'section'	=> 'menu_section',
		'settings'	=> 'menu_font_name',
		'type' 		=> 'select',
		'choices'	=> postmag_get_fonts(),
	) );
	
	$wp_customize->add_setting( 'menu_font_size', array(
		'default'   => '2.2',
		'transport' => 'refresh',
		'sanitize_callback' => 'postmag_sanitize_positive_integer',
	) );

	$wp_customize->add_control( 'menu_font_size', array(
		'label'       => __( 'Font Size', 'postmag' ),
		'section'     => 'menu_section',
		'settings'    => 'menu_font_size',
		'description' => __( 'Measurement is in Vmin. rang( 2 to 5)', 'postmag' ),
		'type' 		  => 'number',
		'input_attrs' => array(
			'min' 	  	=> 2,
			'max' 	  	=> 5,
			'step'    	=> 0.2,
		),
	) );

	$wp_customize->add_setting( 'menu_font_style', array(
		'default'     => 'normal',
		'transport'   => 'refresh',
		'sanitize_callback' => 'postmag_sanitize_select',
	) );

	$wp_customize->add_control( 'menu_font_style', array(
		'label'       => __( 'Font Style', 'postmag' ),
		'section'     => 'menu_section',
		'settings'    => 'menu_font_style',
		'type' 		  => 'select',
		'choices' 	  => array(
			'normal'  	=> __( 'Normal', 'postmag' ),
			'italic'  	=> __( 'Italic', 'postmag' ),
		),
	) );

	$wp_customize->add_setting( 'menu_weight', array(
		'default'     => 'normal',
		'transport'   => 'refresh',
		'sanitize_callback' => 'postmag_sanitize_select',
	) );

	$wp_customize->add_control('menu_weight', array(
		'label'       => __( 'Font Weight', 'postmag' ),
		'section'     => 'menu_section',
		'settings'    => 'menu_weight',
		'type' 		  => 'select',
		'choices'	  => array(
			'normal' 	=> __( 'Normal', 'postmag' ),
			'700' 	  	=> __( 'Bold', 'postmag' ),
		),
	) );
	// THIRD SECTION
	$wp_customize->add_section( 'date_tagline_section', array(
		'title'		=> __( 'Date & Tagline Setting', 'postmag' ),
		'priority'  => 10,
		'panel'  	=> 'postmag_font_panel',
	) );

	$wp_customize->add_setting( 'date_tagline_font_name', array(
		'default'   => 'verdana',
		'transport' => 'refresh',
		'sanitize_callback' => 'sanitize_text_field',
	) );

	$wp_customize->add_control( 'date_tagline_font_name', array(
		'label' 	=> __( 'Font name (Standard + Google)', 'postmag' ),
		'section'	=> 'date_tagline_section',
		'settings'	=> 'date_tagline_font_name',
		'type' 		=> 'select',
		'choices'	=> postmag_get_fonts(),
	) );

	$wp_customize->add_setting( 'date_tagline_font_size', array(
		'default'     => '2',
		'transport'   => 'refresh',
		'sanitize_callback' => 'postmag_sanitize_positive_integer',
	) );

	$wp_customize->add_control( 'date_tagline_font_size', array(
		'label'       => __( 'Font Size', 'postmag' ),
		'section'     => 'date_tagline_section',
		'settings'    => 'date_tagline_font_size',
		'description' => __( 'Measurement is in Vmin.rang( 2 to 5)', 'postmag' ),
		'type' 		  => 'number',
		'input_attrs' => array(
			'min' 	  	=> 2,
			'max'     	=> 5,
			'step' 	 	=> 0.2,
		),
	) );

	$wp_customize->add_setting( 'date_tagline_font_style', array(
		'default'     => 'normal',
		'transport'   => 'refresh',
		'sanitize_callback' => 'postmag_sanitize_select',
	) );
	$wp_customize->add_control( 'date_tagline_font_style', array(
		'label'     => __( 'Font Style', 'postmag' ),
		'section'   => 'date_tagline_section',
		'settings'  => 'date_tagline_font_style',
		'type' 		=> 'select',
		'choices' 	=> array(
			'normal'	=> __( 'Normal', 'postmag' ),
			'italic' 	=> __( 'Italic', 'postmag' ),
		),
	) );

	$wp_customize->add_setting( 'date_tagline_weight', array(
		'default'   => 'normal',
		'transport' => 'refresh',
		'sanitize_callback' => 'postmag_sanitize_select',
	) );

	$wp_customize->add_control( 'date_tagline_weight', array(
		'label'     =>  __( 'Font Weight', 'postmag'),
		'section'   => 'date_tagline_section',
		'settings'  => 'date_tagline_weight',
		'type' 		=> 'select',
		'choices' 	=> array(
			'normal'	=> __( 'Normal', 'postmag' ),
			'700' 		=> __( 'Bold', 'postmag' ),
		),
	) );
	// THIRD SECTION

	$wp_customize->add_section( 'post_title_section', array(
		'title'     => __( 'Post Title Setting', 'postmag' ),
		'priority'  => 20,
		'panel'  	=> 'postmag_font_panel',
	) );

	$wp_customize->add_setting( 'title_font_name', array(
		'default'   => 'open sans',
		'transport' => 'refresh',
		'sanitize_callback' => 'sanitize_text_field',
	) );

	$wp_customize->add_control( 'title_font_name', array(
		'label' 	=> __( 'Font name (Standard + Google)', 'postmag' ),
		'section' 	=> 'post_title_section',
		'settings' 	=> 'title_font_name',
		'type' 		=> 'select',
		'choices' 	=> postmag_get_fonts(),
	) );
	
	$wp_customize->add_setting( 'title_font_size', array(
		'default'     => '2.6',
		'transport'   => 'refresh',
		'sanitize_callback' => 'postmag_sanitize_positive_integer',
	) );

	$wp_customize->add_control( 'title_font_size', array(
		'label'       => __( 'Font Size', 'postmag' ),
		'section'     => 'post_title_section',
		'settings'    => 'title_font_size',
		'description' => __( 'Measurement is in Vmin.rang( 2 to 5)', 'postmag' ),
		'type' 		  => 'number',
		'input_attrs' => array(
			'min' 	  	=> 2,
			'max' 	  	=> 5,
			'step'   	=> 0.2,
		),
	) );

	$wp_customize->add_setting( 'title_font_style', array(
		'default'     => 'normal',
		'transport'   => 'refresh',
		'sanitize_callback' => 'postmag_sanitize_select',
	) );

	$wp_customize->add_control( 'title_font_style', array(
		'label'      => __( 'Font Style', 'postmag' ),
		'section'    => 'post_title_section',
		'settings'   => 'title_font_style',
		'type' 		 => 'select',
		'choices' 	 => array(
			'normal' 	=> __( 'Normal', 'postmag' ),
			'italic' 	=> __( 'Italic', 'postmag' ),
		),
	) );

	$wp_customize->add_setting( 'title_weight', array(
		'default'     => 'normal',
		'transport'   => 'refresh',
		'sanitize_callback' => 'postmag_sanitize_select',
	) );
	$wp_customize->add_control( 'title_weight', array(
		'label'       => __( 'Font Weight', 'postmag' ),
		'section'     => 'post_title_section',
		'settings'    => 'title_weight',
		'type' 		  => 'select',
		'choices' 	  => array(
			'normal'  	=> __( 'Normal', 'postmag' ),
			'700'   	=> __( 'Bold', 'postmag' ),
		),
	) );
					
	// THIRD SECTION

	$wp_customize->add_section( 'post_paragraph_section', array(
		'title'     => __( 'Post Paragraph Setting', 'postmag' ),
		'priority'  => 22,
		'panel'  	=> 'postmag_font_panel',
	) );

	$wp_customize->add_setting( 'paragraph_font_name', array(
		'default'   => 'verdana',
		'transport' => 'refresh',
		'sanitize_callback' => 'sanitize_text_field',
	) );

	$wp_customize->add_control( 'paragraph_font_name', array(
		'label' 	=> __( 'Font name (Standard + Google)', 'postmag' ),
		'section'	=> 'post_paragraph_section',
		'settings' 	=> 'paragraph_font_name',
		'type' 		=> 'select',
		'choices' 	=> postmag_get_fonts(),	
	) );

	$wp_customize->add_setting( 'paragraph_font_size', array(
		'default'   => '2',
		'transport' => 'refresh',
		'sanitize_callback' => 'postmag_sanitize_positive_integer',
	) );

	$wp_customize->add_control( 'paragraph_font_size', array(
		'label'       => __( 'Font Size', 'postmag' ),
		'section'     => 'post_paragraph_section',
		'settings'    => 'paragraph_font_size',
		'description' => __( 'Measurement is in Vmin.rang( 2 to 5)', 'postmag' ),
		'type' 		  => 'number',
		'input_attrs' => array(
			'min' 	 	=> 2,
			'max'     	=> 5,
			'step'    	=> 0.2,
		),
	) );

	$wp_customize->add_setting( 'paragraph_font_style', array(
		'default'     => 'normal',
		'transport'   => 'refresh',
		'sanitize_callback' => 'postmag_sanitize_select',
	) );

	$wp_customize->add_control( 'paragraph_font_style', array(
		'label'       => __( 'Font Style', 'postmag' ),
		'section'     => 'post_paragraph_section',
		'settings'    => 'paragraph_font_style',
		'type' 		  => 'select',
		'choices' => array(
			'normal'  	=> __( 'Normal', 'postmag' ),
			'italic' 	=> __( 'Italic', 'postmag' ),
		),
	) );

	$wp_customize->add_setting( 'paragraph_weight', array(
		'default'     => 'normal',
		'transport'   => 'refresh',
		'sanitize_callback' => 'postmag_sanitize_select',
	) );

	$wp_customize->add_control( 'paragraph_weight', array(
		'label'       => __( 'Font Weight', 'postmag' ),
		'section'     => 'post_paragraph_section',
		'settings'    => 'paragraph_weight',
		'type' 		  => 'select',
		'choices' 	  => array(
			'normal'  	=> __( 'Normal', 'postmag' ),
			'700'    	=> __( 'Bold', 'postmag' ),
		),
	) );
}
add_action( 'customize_register', 'postmag_customize_fonts' );