<?php

function pliska_customize_fonts( $wp_customize ) {
	$wp_customize->add_section(
		'font_section',
		array(
			'title'       => __( 'Fonts', 'pliska' ),
			'description' => __( 'Choose between 1000+ google fonts', 'pliska' ),
		)
	);
	$wp_customize->add_setting(
		'headings_fontfamily',
		array(
			'default'           => 'Rubik',
			'sanitize_callback' => 'sanitize_text_field',
		)
	);
	$wp_customize->add_control(
		'headings_fontfamily',
		array(
			'label'       => __( 'Headings Font Family', 'pliska' ),
			'section'     => 'font_section',
			'type'        => 'select',
			'choices'     => pliska_font_family(),
			'description' => esc_html__( 'Choose font for the headlines.', 'pliska' ),
		)
	);
	$wp_customize->add_setting(
		'body_fontfamily',
		array(
			'default'           => 'IBM Plex Sans',
			'sanitize_callback' => 'sanitize_text_field',
		)
	);
	$wp_customize->add_control(
		'body_fontfamily',
		array(
			'label'       => __( 'Body Font Family', 'pliska' ),
			'section'     => 'font_section',
			'type'        => 'select',
			'choices'     => pliska_font_family(),
			'description' => esc_html__( 'Choose font for the text.', 'pliska' ),
		)
	);
	/* Regulate body size */
	$wp_customize->add_setting(
		'body_font_size',
		array(
			'default'           => '16',
			'sanitize_callback' => 'absint',
		)
	);
	$wp_customize->add_control(
		'body_font_size',
		array(
			'label'       => __( 'Body Font Size', 'pliska' ),
			'section'     => 'font_section',
			'type'        => 'number',
			'input_attrs' => array(
				'min'  => 8,
				'max'  => 30,
				'step' => 1,
			),
			'description' => esc_html__( 'Change the size of the text. Enter a number in pixels between 8 and 30. Default is 16.', 'pliska' ),
		)
	);
	return;
	$wp_customize->add_setting(
		'site_title_font_size',
		array(
			'default'           => '28',
			'sanitize_callback' => 'absint',
		)
	);
	$wp_customize->add_control(
		'site_title_font_size',
		array(
			'label'       => __( 'Site Title Font size', 'pliska' ),
			'section'     => 'font_section',
			'type'        => 'number',
			'input_attrs' => array(
				'min'  => 20,
				'max'  => 36,
				'step' => 1,
			),
			'description' => esc_html__( 'Change the size of the Site Title. Enter a number in pixels between 20 and 36. Default is 28.', 'pliska' ),
		)
	);
	$wp_customize->add_setting(
		'heading_one_font_size',
		array(
			'default'           => '36',
			'sanitize_callback' => 'absint',
		)
	);
	$wp_customize->add_control(
		'heading_one_font_size',
		array(
			'label'       => __( 'Heading One Font Size', 'pliska' ),
			'section'     => 'font_section',
			'type'        => 'number',
			'input_attrs' => array(
				'min'  => 24,
				'max'  => 48,
				'step' => 1,
			),
			'description' => esc_html__( 'Change the size of the page title. Enter a number in pixels between 24 and 48. Default is 36.', 'pliska' ),
		)
	);
	$wp_customize->add_setting(
		'heading_two_font_size',
		array(
			'default'           => '24',
			'sanitize_callback' => 'absint',
		)
	);
	$wp_customize->add_control(
		'heading_two_font_size',
		array(
			'label'       => __( 'Heading Two Font Size', 'pliska' ),
			'section'     => 'font_section',
			'type'        => 'number',
			'input_attrs' => array(
				'min'  => 20,
				'max'  => 32,
				'step' => 1,
			),
			'description' => esc_html__( 'Change the size of Heading Two. This includes section titles such as the post headings on the post archives, widget titles and others. Enter a number in pixels between 20 and 32. Default is 24.', 'pliska' ),
		)
	);
}

add_action( 'customize_register', 'pliska_customize_fonts', 40 );
/**
 * Display custom font CSS.
 */
function pliska_business_fonts_css_container() {    ?>
<style type="text/css">
h1,
h2,
h3,
h4,
h5,
h6 {
	font-family: 
	<?php
	echo esc_attr( get_theme_mod( 'headings_fontfamily', 'Rubik' ) );
	?>
	;
}

body {
	font-family: 
	<?php
	echo esc_attr( get_theme_mod( 'body_fontfamily', 'IBM Plex Sans' ) );
	?>
	;
	font-size: 
	<?php
	echo esc_attr( get_theme_mod( 'body_font_size', '16' ) );
	?>
	px;
}

	<?php
	return;
	?>
	
@media (min-width:40em){
	#header-page-title h1 {
		font-size: 
		<?php
		echo esc_attr( get_theme_mod( 'heading_one_font_size', '36' ) );
		?>
	px;
	}
	.site-title a { 
		font-size: 
		<?php
		echo esc_attr( get_theme_mod( 'site_title_font_size', '28' ) );
		?>
	px;
	}
	h2 {
		font-size: 
		<?php
		echo esc_attr( get_theme_mod( 'heading_two_font_size', '24' ) );
		?>
	px;
	}
}
</style>
	<?php
}

add_action( 'wp_head', 'pliska_business_fonts_css_container' );
