<?php
/**
 * bexplore General Settings panel at Theme Customizer
 *
 * @package bexplore
 * @since 1.0.0
 */

add_action('customize_register', 'bexplore_general_settings_register');

function bexplore_general_settings_register($wp_customize)
{
	/**
	 * Add General Settings Panel
	 *
	 * @since 1.0.0
	 */
	$wp_customize->add_panel(
		'bexplore_general_settings_panel',
		array(
			'priority' => 5,
			'capability' => 'edit_theme_options',
			'theme_supports' => '',
			'title' => __('Global', 'bexplore'),
		)
	);

	$wp_customize->get_section('title_tagline')->panel        = 'bexplore_general_settings_panel';
	$wp_customize->get_setting('blogname')->transport         = 'postMessage';
	$wp_customize->get_section('title_tagline')->priority     = '5';
	$wp_customize->get_section('colors')->panel               = 'bexplore_general_settings_panel';
	$wp_customize->get_section('colors')->priority            = '10';
	$wp_customize->get_setting('header_textcolor')->transport = 'postMessage';
	$wp_customize->get_section('background_image')->panel     = 'bexplore_general_settings_panel';
	$wp_customize->get_section('background_image')->priority  = '15';
	$wp_customize->get_section('static_front_page')->panel    = 'bexplore_general_settings_panel';
	$wp_customize->get_section('static_front_page')->priority = '20';

	/**
	 * Container Settings
	 *
	 * @since 1.0.0
	 */
	// Theme Container settings.
	$wp_customize->add_section(
		'bexplore_theme_container_options',
		array(
			'title' => __('Container Settings', 'bexplore'),
			'panel' => 'bexplore_general_settings_panel',
			'capability' => 'edit_theme_options',
			'description' => __('Container Width', 'bexplore'),
			'priority' => 10,
		)
	);

	$wp_customize->add_setting(
		'bexplore_container_type',
		array(
			'default' => 'container',
			'type' => 'theme_mod',
			'sanitize_callback' => 'sanitize_text_field',
			'capability' => 'edit_theme_options',
		)
	);

	$wp_customize->add_control(
		new WP_Customize_Control(
			$wp_customize,
			'bexplore_container_type',
			array(
				'type' => 'select',
				'label' => esc_html__('Container Width', 'bexplore'),
				'description' => esc_html__(
					'Choose between Bootstrap\'s container and container-fluid',
					'bexplore'
				),
				'section' => 'bexplore_theme_container_options',
				'choices' => array(
					'container' => esc_html__('Fixed width container', 'bexplore'),
					'container-fluid' => esc_html__('Full width container', 'bexplore'),
				),
				'priority' => 10,
			)
		)
	);


	/**
	 * Layout Settings
	 *
	 * @since 1.0.0
	 */
	// Theme layout settings.
	$wp_customize->add_section(
		'bexplore_theme_layout_options',
		array(
			'title' => __('Layout Settings', 'bexplore'),
			'panel' => 'bexplore_general_settings_panel',
			'description' => __('Sidebar Position', 'bexplore'),
			'priority' => 10,
		)
	);

	$wp_customize->add_setting(
		'bexplore_sidebar_position',
		array(
			'default' => 'right',
			'type' => 'theme_mod',
			'sanitize_callback' => 'sanitize_text_field',
			'capability' => 'edit_theme_options',
		)
	);

	$wp_customize->add_control(
		new WP_Customize_Control(
			$wp_customize,
			'bexplore_sidebar_position',
			array(
				'label' => __('Sidebar Positioning', 'bexplore'),
				'description' => __(
					'Set sidebar\'s default position. Can either be: right, left or none. Note: this can be overridden on individual pages.',
					'bexplore'
				),
				'section' => 'bexplore_theme_layout_options',
				'settings' => 'bexplore_sidebar_position',
				'type' => 'select',
				'sanitize_callback' => 'bexplore_theme_slug_sanitize_select',
				'choices' => array(
					'right' => __('Right sidebar', 'bexplore'),
					'left' => __('Left sidebar', 'bexplore'),
					'none' => __('No sidebar', 'bexplore'),
				),
				'priority' => 10,
			)
		)
	);

	$wp_customize->add_setting(
		'be_site_description_on_off',
		array(
			'default' => 'hide',
			'transport' => 'refresh',
			'sanitize_callback' => 'bexplore_sanitize_switch_option',
		)
	);
	$wp_customize->add_control(
		'be_site_description_on_off',
		array(
			'type' => 'select',
			'label' => esc_html__('Site Description', 'bexplore'),
			'description' => esc_html__('Show/Hide option for Site Description.', 'bexplore'),
			'section' => 'title_tagline',
			'priority' => 10,
			'choices' => array(
				'show' => esc_html__('Show', 'bexplore'),
				'hide' => esc_html__('Hide', 'bexplore'),
			),
		)
	);
	/**
	 * Google Fonts Settings
	 *
	 * @since 1.0.0
	 */
	// Google Fonts settings.
	$wp_customize->add_section( 'bexplore_gfonts_section', array(
		'title'       => __( 'Google Fonts settings', 'bexplore' ),
		'priority'       => 10,
		'panel' =>'bexplore_general_settings_panel'
	) );

	$font_choices = array(
		'Source Sans Pro' => 'Source Sans Pro',
		'Poppins' => 'Poppins',
		'Open Sans' => 'Open Sans',
		'Oswald:400,700' => 'Oswald',
		'Playfair Display' => 'Playfair Display',
		'Montserrat' => 'Montserrat',
		'Raleway' => 'Raleway',
		'Droid Sans' => 'Droid Sans',
		'Lato' => 'Lato',
		'Arvo' => 'Arvo',
		'Lora' => 'Lora',
		'Merriweather' => 'Merriweather',
		'Oxygen' => 'Oxygen',
		'PT Serif' => 'PT Serif',
		'PT Sans' => 'PT Sans',
		'PT Sans Narrow' => 'PT Sans Narrow',
		'Cabin' => 'Cabin',
		'Fjalla One' => 'Fjalla One',
		'Francois One' => 'Francois One',
		'Josefin Sans' => 'Josefin Sans',
		'Libre Baskerville' => 'Libre Baskerville',
		'Arimo' => 'Arimo',
		'Ubuntu' => 'Ubuntu',
		'Bitter' => 'Bitter',
		'Droid Serif' => 'Droid Serif',
		'Roboto' => 'Roboto',
		'Open Sans Condensed' => 'Open Sans Condensed',
		'Roboto Condensed' => 'Roboto Condensed',
		'Roboto Slab' => 'Roboto Slab',
		'Yanone Kaffeesatz' => 'Yanone Kaffeesatz',
		'Rokkitt' => 'Rokkitt',
	);

	$wp_customize->add_setting( 'bexplore_body_fonts', array(
			'default' => 'Poppins',
			'sanitize_callback' => 'sanitize_text_field'
		)
	);

	$wp_customize->add_control( 'bexplore_body_fonts', array(
			'type' => 'select',
			'description' => __( 'Select your desired font for the body.', 'bexplore' ),
			'section' => 'bexplore_gfonts_section',
			'choices' => $font_choices
		)
	);


	$wp_customize->add_setting( 'bexplore_headings_fonts', array(
			'default' => 'Montserrat',
			'sanitize_callback' => 'sanitize_text_field',
		)
	);

	$wp_customize->add_control( 'bexplore_headings_fonts', array(
			'type' => 'select',
			'description' => __('Select your desired font for the headings.', 'bexplore'),
			'section' => 'bexplore_gfonts_section',
			'default'=> 'Montserrat',
			'choices' => $font_choices
		)
	);


	/**
	 * Theme's Color Schemes
	 *
	 * @since 1.0.0
	 */
	$wp_customize->add_section(
		'bexplore_color_scheme_section',
		array(
			'title' => __('Color Scheme Settings', 'bexplore'),
			'description' => __('Set the color scheme.', 'bexplore'),
			'priority' => 10,
			'panel' => 'bexplore_general_settings_panel',
		)
	);

	// Site Background Color
	$wp_customize->add_setting(
		'be_site_background_color',
		array(
			'default' => '#ffffff',
			'transport' => 'postMessage',
			'sanitize_callback' => 'sanitize_hex_color',
		)
	);

	$wp_customize->add_control(
		new WP_Customize_Color_Control(
			$wp_customize,
			'be_site_background_color',
			array(
				'label' => __('Site Background Color', 'bexplore'),
				'section' => 'bexplore_color_scheme_section',
				'priority' => 10,
			))
	);

	// Default Text Color
	$wp_customize->add_setting(
		'be_default_text_color',
		array(
			'default' => '#404040',
			'transport' => 'postMessage',
			'sanitize_callback' => 'sanitize_hex_color',
		)
	);

	$wp_customize->add_control(
		new WP_Customize_Color_Control(
			$wp_customize,
			'be_default_text_color',
			array(
				'label' => __('Default Text Color', 'bexplore'),
				'section' => 'bexplore_color_scheme_section',
				'priority' => 10,
			))
	);

	// Site Link Color
	$wp_customize->add_setting(
		'be_site_link_color',
		array(
			'default' => '#ffffff',
			'transport' => 'postMessage',
			'sanitize_callback' => 'sanitize_hex_color',
		)
	);
	$wp_customize->add_control(
		new WP_Customize_Color_Control(
			$wp_customize,
			'be_site_link_color',
			array(
				'label' => __('Site Link Color', 'bexplore'),
				'section' => 'bexplore_color_scheme_section',
				'priority' => 10,
			))
	);

	// Site Link Hover Color
	$wp_customize->add_setting(
		'be_site_link_hr_color',
		array(
			'default' => '#ffffff',
			'transport' => 'postMessage',
			'sanitize_callback' => 'sanitize_hex_color',
		)
	);
	$wp_customize->add_control(
		new WP_Customize_Color_Control(
			$wp_customize,
			'be_site_link_hr_color',
			array(
				'label' => __('Site Link Hover Color', 'bexplore'),
				'section' => 'bexplore_color_scheme_section',
				'priority' => 10,
			))
	);

	// Heading Text Color
	$wp_customize->add_setting(
		'heading_text_color',
		array(
			'default' => '#292929',
			'transport' => 'postMessage',
			'sanitize_callback' => 'sanitize_hex_color',
		)
	);
	$wp_customize->add_control(
		new WP_Customize_Color_Control(
			$wp_customize,
			'heading_text_color',
			array(
				'label' => __('Heading Color', 'bexplore'),
				'section' => 'bexplore_color_scheme_section',
				'priority' => 10,
			))
	);

	// Button Background Color
	$wp_customize->add_setting(
		'be_btn_bg_color',
		array(
			'default' => '#ffffff',
			'transport' => 'postMessage',
			'sanitize_callback' => 'sanitize_hex_color',
		)
	);
	$wp_customize->add_control(
		new WP_Customize_Color_Control(
			$wp_customize,
			'be_btn_bg_color',
			array(
				'label' => __('Button Background Color', 'bexplore'),
				'section' => 'bexplore_color_scheme_section',
				'priority' => 10,
			))
	);

	// Button Background Hover Color
	$wp_customize->add_setting(
		'be_btn_bg_hr_color',
		array(
			'default' => '#ffffff',
			'transport' => 'postMessage',
			'sanitize_callback' => 'sanitize_hex_color',
		)
	);
	$wp_customize->add_control(
		new WP_Customize_Color_Control(
			$wp_customize,
			'be_btn_bg_hr_color',
			array(
				'label' => __('Button Background Hover Color', 'bexplore'),
				'section' => 'bexplore_color_scheme_section',
				'priority' => 10,
			))
	);

	// Button Text Color
	$wp_customize->add_setting(
		'be_btn_text_color',
		array(
			'default' => '#ffffff',
			'transport' => 'postMessage',
			'sanitize_callback' => 'sanitize_hex_color',
		)
	);
	$wp_customize->add_control(
		new WP_Customize_Color_Control(
			$wp_customize,
			'be_btn_text_color',
			array(
				'label' => __('Button Text Color', 'bexplore'),
				'section' => 'bexplore_color_scheme_section',
				'priority' => 10,
			))
	);

	// Button Text Hover Color
	$wp_customize->add_setting(
		'be_btn_text_hr_color',
		array(
			'default' => '#ffffff',
			'transport' => 'postMessage',
			'sanitize_callback' => 'sanitize_hex_color',
		)
	);
	$wp_customize->add_control(
		new WP_Customize_Color_Control(
			$wp_customize,
			'be_btn_text_hr_color',
			array(
				'label' => __('Button Text Hover Color', 'bexplore'),
				'section' => 'bexplore_color_scheme_section',
				'priority' => 10,
			))
	);

}
