<?php
/**
 * Theme Customizer.
 *
 * @package official_core
 */


function officialcore_customize_register( $wp_customize ) {

	// Add postMessage support for site title and description for the Theme Customizer.
	$wp_customize->get_setting( 'blogname' )->transport         = 'postMessage';
	$wp_customize->get_setting( 'blogdescription' )->transport  = 'postMessage';

	// Remove some options from customizer
	$wp_customize->remove_section('background_image');
	$wp_customize->remove_section('colors');


	/* Edit or Add in default WordPress sections
	********************************************* */

	/* Logo as Image */
	$wp_customize->add_setting( 'officialcore_title_tagline_logo', array(
	    'default' => '',
	    'sanitize_callback' => 'esc_url_raw',
	) );

	$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'officialcore_title_tagline_logo', array(
		'priority' => '0',
		'label'    => __( 'Logo as Image', 'official-core' ),
		'description'    => __( 'Choose your logo image to use as your default site logo (instead you may display your Logo as text from the optiosn below) Note: Remove the image to use the options below', 'official-core' ),
		'section'  => 'title_tagline',
		'settings' => 'officialcore_title_tagline_logo',
	) ) );

	/* Header height */
	$wp_customize->add_setting( 'officialcore_title_tagline_nav_height', array(
	    'default' => '60',
	    'sanitize_callback' => 'sanitize_text_field',
	) );

	$wp_customize->add_control( 'officialcore_title_tagline_nav_height', array(
		'type'     => 'text',
		'priority' => '0',
		'label'    => __( 'Header Height', 'official-core' ),
		'description'    => __( 'Adjust the header height based from your logo image height above', 'official-core' ),
		'section'  => 'title_tagline',
		'settings' => 'officialcore_title_tagline_nav_height',
	) );

	/* Remove "Display Header Text"  default WP option */
	$wp_customize->remove_control('display_header_text');


	/* General (section)
	********************************************* */
	/* Create section */
	$wp_customize->add_section( 'officialcore_section_general' , array(
		'title'       => __( 'General Options', 'official-core' ),
		'priority'    => 20,
		'description' => sprintf(__('General Options for OfficialCore Theme', 'official-core')),

	));

	/* Fixed Header */
	$wp_customize->add_setting( 'officialcore_general_fixed_header', array(
		'default' => 'fixed',
		'sanitize_callback' => 'sanitize_key',
	) );

	$wp_customize->add_control( 'officialcore_general_fixed_header', array(
		'type' => 'radio',
		'label' => __( 'Header Layout', 'official-core' ),
		'description' => __( 'Wheither to make header fixed on page scrolls or not', 'official-core' ),
		'section' => 'officialcore_section_general',
		'choices' => array(
			'fixed' => __( 'Fixed', 'official-core' ),
			'static' => __( 'Static', 'official-core' ),
		),
	));

	/* Parallax Footer */
	$wp_customize->add_setting( 'officialcore_general_parallax_footer', array(
		'default' => 'true',
		'sanitize_callback' => 'sanitize_key',
	) );

	$wp_customize->add_control( 'officialcore_general_parallax_footer', array(
		'type' => 'radio',
		'label' => __( 'Parallax Footer', 'official-core' ),
		'description' => __( 'A jQuery effect to reveal footer in a slide-out way', 'official-core' ),
		'section' => 'officialcore_section_general',
		'choices' => array(
			'true' => __( 'Enable', 'official-core' ),
			'false' => __( 'Disable', 'official-core' ),
		),
	));

	/* Search Link  */
	$wp_customize->add_setting( 'officialcore_general_search', array(
		'default' => 'true',
		'sanitize_callback' => 'sanitize_key',
	));

	$wp_customize->add_control( 'officialcore_general_search', array(
		'type' => 'radio',
		'label' => __( 'Enable Search (Header)', 'official-core' ),
		'description' => __( 'Display a search form with a modal box by clicking on a search icon on header', 'official-core' ),
		'section' => 'officialcore_section_general',
		'choices' => array(
			'true' => __( 'Yes', 'official-core' ),
			'false' => __( 'No', 'official-core' ),
		),
	));

	/* Go to Top link */
	$wp_customize->add_setting( 'officialcore_general_gotop', array(
		'default' => 'true',
		'sanitize_callback' => 'sanitize_key',
	));

	$wp_customize->add_control( 'officialcore_general_gotop', array(
		'type' => 'radio',
		'label' => __( 'Enable "Go to Top" Link?', 'official-core' ),
		'description' => __( 'Provide a link to offer your users the ability to easily go back to the top of the page', 'official-core' ),
		'section' => 'officialcore_section_general',
		'choices' => array(
			'true' => __( 'Yes', 'official-core' ),
			'false' => __( 'No', 'official-core' ),
		),
	));

	/* Animations effect */
	$wp_customize->add_setting( 'officialcore_general_animations', array(
		'default' =>  'true',
		'sanitize_callback' => 'sanitize_key',
	));

	$wp_customize->add_control('officialcore_general_animations', array(
		'type' => 'radio',
		'label' => __('Animations Effects', 'official-core' ),
		'description' => __('', 'official-core' ),
		'section' => 'officialcore_section_general',
		'choices' => array(
			'true' => __( 'Enable', 'official-core' ),
			'false' => __( 'Disable', 'official-core' ),
		),
	));

	/* Blog Columns */
	$wp_customize->add_setting( 'officialcore_general_blog_columns', array(
		'default' => '1',
		'sanitize_callback' => 'sanitize_key',
	) );

	$wp_customize->add_control( 'officialcore_general_blog_columns', array(
		'type' => 'select',
		'label' => __( 'Blog Columns', 'official-core' ),
		'description' => __( 'When viewing your category posts, chose the number of columns for the layout', 'official-core' ),
		'section' => 'officialcore_section_general',
		'choices' => array(
			'1' => __( '1 Column', 'official-core' ),
			'2' => __( '2 Columns', 'official-core' ),
			'3' => __( '3 Columns', 'official-core' ),
			'4' => __( '4 Columns', 'official-core' ),
		),
	));


	/* Colors (section)
	********************************************* */
	/* Create section */
	$wp_customize->add_section( 'officialcore_section_colors' , array(
		'title'       => __( 'Theme Colors', 'official-core' ),
		'priority'    => 20,
		'description' => sprintf(__('Chose your prefered colors for your website. To make this options work you need to make sure that "WP Less" plugin is installed and activated.<br> <strong>NOTE To see changes please save the settings and check your frontend.</strong>', 'official-core')),

	) );

	/* Brand Primary */
	$wp_customize->add_setting( 'officialcore_colors_primary', array(
	    'default' => '0099CC',
	    'transport'   => 'refresh',
	    'sanitize_callback' => 'sanitize_hex_color',
	) );

	$wp_customize->add_control( new WP_Customize_Color_Control ( $wp_customize,  'officialcore_colors_primary', array (
		'label'      => __( 'Brand Primary', 'official-core' ),
		'section'    => 'officialcore_section_colors',
		'settings'   => 'officialcore_colors_primary',
	) ) );

	/* Brand Secondary */
	$wp_customize->add_setting( 'officialcore_colors_secondary', array(
	    'default' => '474747',
	    'transport'   => 'refresh',
	    'sanitize_callback' => 'sanitize_hex_color',
	) );

	$wp_customize->add_control( new WP_Customize_Color_Control ( $wp_customize,  'officialcore_colors_secondary', array (
		'label'      => __( 'Brand Secondary', 'official-core' ),
		'section'    => 'officialcore_section_colors',
		'settings'   => 'officialcore_colors_secondary',
	) ) );


	/* Maintenance mode (section)
	********************************************* */
	$wp_customize->add_section( 'officialcore_section_maintenance' , array(
		'title'       => __( 'Maintenance Mode', 'official-core' ),
		'priority'    => 20,
		//'description' => sprintf(__('General Options for OfficialCore Theme', 'official-core')),
	));

	/* Enable Maintenance Mode */
	$wp_customize->add_setting( 'officialcore_maintenance_maintenance', array(
		'default' => 'false',
		'sanitize_callback' => 'sanitize_key',
	) );

	$wp_customize->add_control( 'officialcore_maintenance_maintenance', array(
		'type' => 'radio',
		'label' => __( 'Maintenance Mode', 'official-core' ),
		'description' => __( 'Enable this feature when you want your website to be offline and not accessible by visitors but only admins, or you may use it as a coming soon page', 'official-core' ),
		'section' => 'officialcore_section_maintenance',
		'choices' => array(
			'true' => __( 'Enable', 'official-core' ),
			'false' => __( 'Disable', 'official-core' ),
		),
	));

	/* Enable Countdown */
	$wp_customize->add_setting( 'officialcore_maintenance_countdown', array(
		'default' => 'true',
		'sanitize_callback' => 'sanitize_key',
	) );

	$wp_customize->add_control( 'officialcore_maintenance_countdown', array(
		'type' => 'radio',
		'label' => __( 'Countdown', 'official-core' ),
		'description' => __( 'Jquery countdown with your specified time to let your visitors know when your website will be oline.', 'official-core'),
		'section' => 'officialcore_section_maintenance',
		'choices' => array(
			'true' => __( 'Enable', 'official-core' ),
			'false' => __( 'Disable', 'official-core' ),
		),
	));

	/* Enable Countdown */
	$wp_customize->add_setting( 'officialcore_maintenance_date', array(
		'default' => '2017-01-01',
		'type' => 'theme_mod',
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'sanitize_text_field',
	) );

	$wp_customize->add_control( 'officialcore_maintenance_date', array(
		'type' => 'date',
		'label' => __( 'Countdown Time', 'official-core' ),
		'description' => sprintf(__('If you have enabled Countdown option above please specify time here e.g <strong>2016/10/10</strong>', 'official-core')),
		'section' => 'officialcore_section_maintenance',
	));

}
add_action( 'customize_register', 'officialcore_customize_register' );
