<?php
/**
 * Oginer Theme Customizer
 *
 * @package Oginer
 */

/**
 * Add postMessage support for site title and description for the Theme Customizer.
 *
 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
 */
function oginer_customize_register( $wp_customize ) {
	$wp_customize->get_setting( 'blogname' )->transport         = 'postMessage';
	$wp_customize->get_setting( 'blogdescription' )->transport  = 'postMessage';
	$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
	
	$link_icon_fa = 'https://fontawesome.com/v4.7.0/icons/';

	if ( isset( $wp_customize->selective_refresh ) ) {
		$wp_customize->selective_refresh->add_partial( 'blogname', array(
			'selector'        => '.site-title a',
			'render_callback' => 'oginer_customize_partial_blogname',
		) );
		$wp_customize->selective_refresh->add_partial( 'blogdescription', array(
			'selector'        => '.site-description',
			'render_callback' => 'oginer_customize_partial_blogdescription',
		) );
	}
	
	//Home Page Options
	$wp_customize->add_panel( 'oginer_homepage_options' , array(
		'title'       => __( 'Home Page Options', 'oginer' ),
		'priority'    => 41,
		'description' => '',
	) );
	
	//Home Section ON/OFF
	$wp_customize->add_section( 'oginer_homepage_section_show' , array(
		'title'       => __( 'Home Section ON/OFF', 'oginer' ),		
		'description' => __( 'Select which sections you want to display on the home page.', 'oginer' ),
		'panel' => 'oginer_homepage_options',
		'priority' => 10
	));

	//aboutus
	$all_section = array( 
		'about', 
		'cta',
		'testimonial',
		'features',
		'cta-2',
		'screen',
		'counter',
		'content',
		'downloads',
		'blog',
		'contact'
	);
	
	foreach ( $all_section as $i ) :
		$wp_customize->add_setting( 'oginer_show_' . $i, array (
			'default' => 1,
			'sanitize_callback' => 'oginer_sanitize_checkbox',
		));

		$wp_customize->add_control( 'oginer_show_' . $i, array(
			'label' => __( 'Show Section ', 'oginer' ) . ucfirst( $i ),
			'section' => 'oginer_homepage_section_show',
			'settings' => 'oginer_show_' . $i,
			'type' => 'checkbox',
		));	
	endforeach;
	
	// Home Bannner
	$wp_customize->add_setting( 'oginer_show_banner', array (
		'default' => '',
		'sanitize_callback' => 'oginer_sanitize_checkbox',
	));

	$wp_customize->add_control( 'oginer_show_banner', array(
		'label' => __( 'Show Section Banner', 'oginer' ),
		'section' => 'oginer_homepage_section_show',
		'settings' => 'oginer_show_banner',
		'type' => 'checkbox',
		'priority' => 1
	));	
	// oginer_section
	$wp_customize->add_section( 'oginer_homepage_banner', array(
		'title' => __( 'Home Page Promo Banner', 'oginer' ),
		'panel' => 'oginer_homepage_options',
		'priority' => 42
	));
	
	$wp_customize->add_setting( 'oginer_banner_title_top', array(
		'default' => __( 'Fully Responsive Template', 'oginer' ),
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_banner_title_top', array(
		'label' => __( 'Banner Title Top', 'oginer' ),
		'section' => 'oginer_homepage_banner',
		'settings' => 'oginer_banner_title_top',
		'type' => 'text',
	));	
	
	$wp_customize->add_setting( 'oginer_banner_title', array(
		'default' => __( 'This is a free responsive landing page made with the Bootstrap framework.', 'oginer' ),
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_banner_title', array(
		'label' => __( 'Banner Title', 'oginer' ),
		'section' => 'oginer_homepage_banner',
		'settings' => 'oginer_banner_title',
		'type' => 'text',
	));
	
	$wp_customize->add_setting( 'oginer_banner_description', array(
		'default' => '',
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_banner_description', array(
		'label' => __( 'Banner Description', 'oginer'),
		'section' => 'oginer_homepage_banner',
		'settings' => 'oginer_banner_description',
		'type' => 'textarea',
	));
	
	$wp_customize->add_setting( 'oginer_banner_url_title', array(
		'default' => __( 'Learn more', 'oginer' ),
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_banner_url_title', array(
		'label' => __( 'Banner Button Title', 'oginer' ),
		'section' => 'oginer_homepage_banner',
		'settings' => 'oginer_banner_url_title',
		'type' => 'text',
	));	
	
	$wp_customize->add_setting( 'oginer_banner_url', array(
		'default' => '#',
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_banner_url', array(
		'label' => __( 'Banner Button Link', 'oginer' ),
		'section' => 'oginer_homepage_banner',
		'settings' => 'oginer_banner_url',
		'type' => 'text',
	));	
	
	$wp_customize->add_setting( 'oginer_banner_url_title_2', array(
		'default' => __( 'PURCHASES NOW', 'oginer' ),
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_banner_url_title_2', array(
		'label' => __( 'Banner Button Title 2', 'oginer' ),
		'section' => 'oginer_homepage_banner',
		'settings' => 'oginer_banner_url_title_2',
		'type' => 'text',
	));	
	
	$wp_customize->add_setting( 'oginer_banner_url_2', array(
		'default' => '#',
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_banner_url_2', array(
		'label' => __( 'Banner Button Link 2', 'oginer' ),
		'section' => 'oginer_homepage_banner',
		'settings' => 'oginer_banner_url_2',
		'type' => 'text',
	));
	
	$wp_customize->add_setting( 'oginer_banner_phone', array(
		'default'	=> get_template_directory_uri().'/img/header-imgapp.png',
		'sanitize_callback' => 'esc_url_raw', 
    ));
 
    $wp_customize->add_control( new WP_Customize_Image_Control($wp_customize,
		'oginer_banner_phone', 
		array(
        	'label'    => __( 'Image', 'oginer' ),
        	'description'    => __( 'Recommended size 430 x 570', 'oginer' ),
        	'section'  => 'oginer_homepage_banner',
        	'settings' => 'oginer_banner_phone',
		)
		)
	);
	
	$wp_customize->add_setting('oginer_banner_text_position', array(
		'description' => __( 'Select Text Position' , 'oginer' ),
		'default' => 'center',
		'sanitize_callback' => 'oginer_sanitize_banner_text_position',
	));
	
	$wp_customize->add_control('oginer_banner_text_position', array(
		'label'      => __( 'Display Text', 'oginer' ),
		'section'    => 'oginer_homepage_banner',
		'settings'   => 'oginer_banner_text_position',
		'type'       => 'select',
		'choices'    => array(
			'text-image'	=> __('Text Left + Image Right', 'oginer'),
			'text'			=> __('Text Center', 'oginer'),
			'center' 		=> __('Text + Image Center', 'oginer'),
		),
	));

	$wp_customize->add_setting('oginer_banner_bg_position', array(
		'default' => 'center',
		'sanitize_callback' => 'oginer_sanitize_banner_bg_position',
	));
	
	$wp_customize->add_control('oginer_banner_bg_position', array(
		'label'      => __( 'Background Position', 'oginer' ),
		'section'    => 'oginer_homepage_banner',
		'settings'   => 'oginer_banner_bg_position',
		'type'       => 'select',
		'choices'    => array(
			'top'		=> __('Top', 'oginer'),
			'center'	=> __('Center', 'oginer'),
			'bottom' 	=> __('Bottom', 'oginer'),
		),
	));
	
	// Home About Us
	// oginer_section
	$wp_customize->add_section( 'oginer_homepage_about', array(
		'title' => __( 'Home Page About', 'oginer' ),
		'panel' => 'oginer_homepage_options',
		'priority' => 42
	));
	
	$wp_customize->add_setting( 'oginer_about_id', array(
		'default' => 'about-us',
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_about_id', array(
		'label' => __( 'About ID Section', 'oginer' ),
		'section' => 'oginer_homepage_about',
		'settings' => 'oginer_about_id',
		'type' => 'text',
	));	
	
	$wp_customize->add_setting( 'oginer_about_page', array(
		'default'           => '',
		'sanitize_callback' => 'oginer_sanitize_dropdown_pages'
	));
	
	$wp_customize->add_control( 'oginer_about_page', array(
		'label' => __( 'Select About Page', 'oginer' ),
		'section' => 'oginer_homepage_about',
		'settings' => 'oginer_about_page',
		'type'     => 'dropdown-pages'
	));
	
	$wp_customize->add_setting( 'oginer_about_url_title', array(
		'default' => __( 'Read more', 'oginer' ),
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_about_url_title', array(
		'label' => __( 'About Button Title', 'oginer' ),
		'section' => 'oginer_homepage_about',
		'settings' => 'oginer_about_url_title',
		'type' => 'text',
	));	
	
	$wp_customize->add_setting( 'oginer_about_url', array(
		'default' => '#',
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_about_url', array(
		'label' => __( 'About Button Link', 'oginer' ),
		'section' => 'oginer_homepage_about',
		'settings' => 'oginer_about_url',
		'type' => 'text',
	));
	
	// Home CTA
	// oginer_section
	$wp_customize->add_section( 'oginer_cta' , array(
    	'title'      => __( 'Home Page Call to Action', 'oginer' ),
		'panel' => 'oginer_homepage_options',
		'priority'   => 42,
	));
	
	$wp_customize->add_setting( 'oginer_cta_id', array(
		'default' => 'cta',
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_cta_id', array(
		'label' => __( 'CTA ID Section', 'oginer' ),
		'section' => 'oginer_cta',
		'settings' => 'oginer_cta_id',
		'type' => 'text',
	));	
	
	$wp_customize->add_setting( 'oginer_cta_page', array(
		'default' => '',
		'sanitize_callback' => 'oginer_sanitize_dropdown_pages',
	));
	
	$wp_customize->add_control( 'oginer_cta_page', array(
		'label' => __( 'Select CTA Page', 'oginer' ),
		'section' => 'oginer_cta',
		'settings' => 'oginer_cta_page',
		'type' => 'dropdown-pages',
	));
	
	$wp_customize->add_setting( 'oginer_cta_url_title', array(
		'default' => __( 'More info', 'oginer' ),
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_cta_url_title', array(
		'label' => __( 'CTA Button Title', 'oginer' ),
		'section' => 'oginer_cta',
		'settings' => 'oginer_cta_url_title',
		'type' => 'text',
	));	
	
	$wp_customize->add_setting( 'oginer_cta_url', array(
		'default' => '#',
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_cta_url', array(
		'label' => __( 'CTA Button Link', 'oginer' ),
		'section' => 'oginer_cta',
		'settings' => 'oginer_cta_url',
		'type' => 'text',
	));	
	
	// Home testimonial
	// oginer_section
	$wp_customize->add_section( 'oginer_homepage_testimonial', array(
		'title' => __( 'Home Page Testimonial', 'oginer' ),
		'panel' => 'oginer_homepage_options',
		'priority' => 42
	));
	
	$wp_customize->add_setting( 'oginer_testimonial_id', array(
		'default' => 'testimonial',
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_testimonial_id', array(
		'label' => __( 'Testimonial ID Section', 'oginer' ),
		'section' => 'oginer_homepage_testimonial',
		'settings' => 'oginer_testimonial_id',
		'type' => 'text',
	));
	
	$wp_customize->add_setting( 'oginer_testimonial_bg', array(
		'default' => '', //get_template_directory_uri().'inc/images/',
		'sanitize_callback' => 'esc_url_raw',
 
    ));
 
    $wp_customize->add_control( new WP_Customize_Image_Control($wp_customize,
		'oginer_testimonial_bg', 
		array(
        	'label'    => __( 'Background Image', 'oginer' ),
        	//'description'    => __( 'Recommended size 430 x 570', 'oginer' ),
        	'section'  => 'oginer_homepage_testimonial',
        	'settings' => 'oginer_testimonial_bg',
		)
		)
	);

	for ( $i = 1; $i <= 3; $i++ ) {
		$wp_customize->add_setting( 'oginer_testimonial_page_' . $i, array(
			'default'           => '',
			'sanitize_callback' => 'oginer_sanitize_dropdown_pages'
		) );

		$wp_customize->add_control( 'oginer_testimonial_page_' . $i, array(
			'label'    => __( 'Select Page Testimonial', 'oginer' ) . ' ' .$i,
			'section'  => 'oginer_homepage_testimonial',
			'type'     => 'dropdown-pages'
		) );
	}
	
	// Home features
	// oginer_section	
	$wp_customize->add_section( 'oginer_features' , array(
    	'title'      => __( 'Home Page Features', 'oginer' ),
		'panel' => 'oginer_homepage_options',
		'priority'   => 42,
	));
	
	$wp_customize->add_setting( 'oginer_features_id', array(
		'default' => 'features',
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_features_id', array(
		'label' => __( 'Features ID Section', 'oginer' ),
		'section' => 'oginer_features',
		'settings' => 'oginer_features_id',
		'type' => 'text',
	));
	
	$wp_customize->add_setting( 'oginer_features_page', array(
		'default' =>'',
		'sanitize_callback' => 'oginer_sanitize_dropdown_pages',
	));
	
	$wp_customize->add_control( 'oginer_features_page', array(
		'label' => __( 'Select Features Page', 'oginer' ),
		'description' => __( 'Title - description section.', 'oginer' ),
		'section' => 'oginer_features',
		'settings' => 'oginer_features_page',
		'type' => 'dropdown-pages',
	));
	
	// page
	for ( $i = 1; $i <= 6; $i++ ) {
		$wp_customize->add_setting( 'oginer_features_icon' . $i, array(
			'default' => 'fa-flag-o',
			'sanitize_callback' => 'sanitize_text_field',
		));
		
		$wp_customize->add_control( 'oginer_features_icon' . $i, array(
			'label' => __( 'Featured Icon', 'oginer' ) . ' ' . $i,
			'description' => sprintf( __( 'Use font awesome icon: Eg: %1$s. %2$s See more here %3$s', 'oginer' ), 'fa-desktop','<a href="'.esc_url( $link_icon_fa ).'" target="_blank">','</a>' ),
			'section' => 'oginer_features',
			'settings' => 'oginer_features_icon' . $i,
			'type' => 'text',
		));	

		$wp_customize->add_setting( 'oginer_features_page_' . $i, array(
			'default'           => '',
			'sanitize_callback' => 'oginer_sanitize_dropdown_pages'
		) );

		$wp_customize->add_control( 'oginer_features_page_' . $i, array(
			'label'    => __( 'Select Page Featured', 'oginer' ) . ' ' .$i,
			'section'  => 'oginer_features',
			'type'     => 'dropdown-pages'
		) );
	}
	
	// Home CTA 2
	// oginer_section
	$wp_customize->add_section( 'oginer_cta2' , array(
    	'title'      => __( 'Home Page Call to Action 2', 'oginer' ),
		'panel' => 'oginer_homepage_options',
		'priority'   => 42,
	));
	
	$wp_customize->add_setting( 'oginer_cta2_id', array(
		'default' => 'cta2',
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_cta2_id', array(
		'label' => __( 'CTA 2 ID Section', 'oginer' ),
		'section' => 'oginer_cta2',
		'settings' => 'oginer_cta2_id',
		'type' => 'text',
	));
	
	$wp_customize->add_setting( 'oginer_cta2_description', array(
		'default' => '',
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_cta2_description', array(
		'label' => __( 'CTA Description', 'oginer'),
		'section' => 'oginer_cta2',
		'settings' => 'oginer_cta2_description',
		'type' => 'textarea',
	));
	
	$wp_customize->add_setting( 'oginer_cta2_url_title', array(
		'default' => __( 'More info', 'oginer' ),
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_cta2_url_title', array(
		'label' => __( 'CTA Button Title', 'oginer' ),
		'section' => 'oginer_cta2',
		'settings' => 'oginer_cta2_url_title',
		'type' => 'text',
	));	
	
	$wp_customize->add_setting( 'oginer_cta2_url', array(
		'default' => '#',
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_cta2_url', array(
		'label' => __( 'CTA Button Link', 'oginer' ),
		'section' => 'oginer_cta2',
		'settings' => 'oginer_cta2_url',
		'type' => 'text',
	));	
	
	// Home SCREENS 
	// oginer_section
	$wp_customize->add_section( 'oginer_screens' , array(
    	'title'      => __( 'Home Page Screens', 'oginer' ),
		'panel' => 'oginer_homepage_options',
		'priority'   => 42,
	));
	
	$wp_customize->add_setting( 'oginer_screen_id', array(
		'default' => 'screenviews',
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_screen_id', array(
		'label' => __( 'Screens ID Section', 'oginer' ),
		'section' => 'oginer_screens',
		'settings' => 'oginer_screen_id',
		'type' => 'text',
	));
	
	$wp_customize->add_setting( 'oginer_screen_page', array(
		'default' => '',
		'sanitize_callback' => 'oginer_sanitize_dropdown_pages',
	));
	
	$wp_customize->add_control( 'oginer_screen_page', array(
		'label' => __( 'Select Screens Page', 'oginer' ),
		'section' => 'oginer_screens',
		'settings' => 'oginer_screen_page',
		'type' => 'dropdown-pages',
	));

	for ( $i = 1; $i <= 6; $i++ ) {
		//image
		$wp_customize->add_setting( 'oginer_screen_img_' . $i, array(
			'default'	=> get_template_directory_uri().'/img/screen'.$i.'.jpg',
			'sanitize_callback' => 'esc_url_raw', 
		));
	 
		$wp_customize->add_control( new WP_Customize_Image_Control($wp_customize,
			'oginer_screen_img_' . $i, 
			array(
				'label'    => __( 'Image', 'oginer' ) . ' ' .$i,
				'description'    => __( 'Recommended size 360 x 460', 'oginer' ),
				'section'  => 'oginer_screens',
				'settings' => 'oginer_screen_img_' . $i,
			)
			)
		);
	}
	
	// Home Counter
	// oginer_section
	$wp_customize->add_section( 'oginer_homepage_counter', array(
		'title' => __( 'Home Page Counter', 'oginer' ),
		'description' => __( 'You need to add Counter Box in Widget Area.', 'oginer' ),
		'panel' => 'oginer_homepage_options',
		'priority' => 42
	));
	
	$wp_customize->add_setting( 'oginer_counter_id', array(
		'default' => 'counter',
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_counter_id', array(
		'label' => __( 'Counter ID Section', 'oginer' ),
		'section' => 'oginer_homepage_counter',
		'settings' => 'oginer_counter_id',
		'type' => 'text',
	));	
	
	$wp_customize->add_setting( 'oginer_counter_bg', array(
		'default' => '', //get_template_directory_uri().'inc/images/',
		'sanitize_callback' => 'esc_url_raw', 
    ));
 
    $wp_customize->add_control( new WP_Customize_Image_Control($wp_customize,
		'oginer_counter_bg', 
		array(
        	'label'    => __( 'Background Image', 'oginer' ),
        	//'description'    => __( 'Recommended size 430 x 570', 'oginer' ),
        	'section'  => 'oginer_homepage_counter',
        	'settings' => 'oginer_counter_bg',
		)
		)
	);
	
	// Home Countent
	// oginer_section
	$wp_customize->add_section( 'oginer_homepage_content', array(
		'title' => __( 'Home Page Countent', 'oginer' ),
		'panel' => 'oginer_homepage_options',
		'priority' => 42
	));
	
	$wp_customize->add_setting( 'oginer_content_id', array(
		'default' => 'countent',
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_content_id', array(
		'label' => __( 'Countent ID Section', 'oginer' ),
		'section' => 'oginer_homepage_content',
		'settings' => 'oginer_content_id',
		'type' => 'text',
	));	
	
	$wp_customize->add_setting( 'oginer_content_page', array(
		'default' => '',
		'sanitize_callback' => 'oginer_sanitize_dropdown_pages',
	));
	
	$wp_customize->add_control( 'oginer_content_page', array(
		'label' => __( 'Select Countent Page', 'oginer' ),
		'description' => __( 'Title - description section.', 'oginer' ),
		'section' => 'oginer_homepage_content',
		'settings' => 'oginer_content_page',
		'type' => 'dropdown-pages',
	));
	
	$wp_customize->add_setting( 'oginer_content_url_title', array(
		'default' => __( 'Read more', 'oginer' ),
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_content_url_title', array(
		'label' => __( 'Countent Button Title', 'oginer' ),
		'section' => 'oginer_homepage_content',
		'settings' => 'oginer_content_url_title',
		'type' => 'text',
	));	
	
	$wp_customize->add_setting( 'oginer_content_url', array(
		'default' => '#',
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_content_url', array(
		'label' => __( 'Countent Button Link', 'oginer' ),
		'section' => 'oginer_homepage_content',
		'settings' => 'oginer_content_url',
		'type' => 'text',
	));	
	
	// Home Downloads
	// oginer_section
	$wp_customize->add_section( 'oginer_homepage_downloads', array(
		'title' => __( 'Home Page Downloads', 'oginer' ),
		'description' => __( 'You need to add downloads links in Widget Area.', 'oginer' ),
		'panel' => 'oginer_homepage_options',
		'priority' => 42
	));
	
	$wp_customize->add_setting( 'oginer_downloads_id', array(
		'default' => 'downloads',
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_downloads_id', array(
		'label' => __( 'Downloads ID Section', 'oginer' ),
		'section' => 'oginer_homepage_downloads',
		'settings' => 'oginer_downloads_id',
		'type' => 'text',
	));
	
	$wp_customize->add_setting( 'oginer_downloads_page', array(
		'default' => '',
		'sanitize_callback' => 'oginer_sanitize_dropdown_pages',
	));
	
	$wp_customize->add_control( 'oginer_downloads_page', array(
		'label' => __( 'Select Page Downloads', 'oginer' ),
		'description' => __( 'Title - Description, link add in section wipage', 'oginer' ),
		'section' => 'oginer_homepage_downloads',
		'settings' => 'oginer_downloads_page',
		'type' => 'dropdown-pages',
	));
	
	// Home Latest Blog Posts
	// oginer_section	
	$wp_customize->add_section( 'oginer_homepage_blog', array(
		'title' => __( 'Home Page Blog', 'oginer' ),
		'panel' => 'oginer_homepage_options',
		'priority' => 42
	));
	
	$wp_customize->add_setting( 'oginer_blog_id', array(
		'default' => 'blog',
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_blog_id', array(
		'label' => __( 'Blog ID Section', 'oginer' ),
		'section' => 'oginer_homepage_blog',
		'settings' => 'oginer_blog_id',
		'type' => 'text',
	));
	
	$wp_customize->add_setting( 'oginer_blog_page', array(
		'default' => '',
		'sanitize_callback' => 'oginer_sanitize_dropdown_pages',
	));
	
	$wp_customize->add_control( 'oginer_blog_page', array(
		'label' => __( 'Select Blog Page', 'oginer' ),
		'description' => __( 'Title - description section', 'oginer' ),
		'section' => 'oginer_homepage_blog',
		'settings' => 'oginer_blog_page',
		'type' => 'dropdown-pages',
	));
	
	$wp_customize->add_setting( 'oginer_blog_number', array(
		'default' => 3,
		'sanitize_callback' => 'absint',
	));
	
	$wp_customize->add_control( 'oginer_blog_number', array(
		'label' => __( 'Number of Posts', 'oginer'),
		'description' => __( 'Default = 3', 'oginer'),
		'section' => 'oginer_homepage_blog',
		'settings' => 'oginer_blog_number',
		'type' => 'text',
	));
	
	// Home Contact
	// oginer_section
	$wp_customize->add_section( 'oginer_homepage_contact', array(
		'title' => __( 'Home Page Contact', 'oginer' ),
		'panel' => 'oginer_homepage_options',
		'priority' => 42
	));
	
	$wp_customize->add_setting( 'oginer_contact_id', array(
		'default' => 'contact',
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_contact_id', array(
		'label' => __( 'Contact ID Section', 'oginer' ),
		'section' => 'oginer_homepage_contact',
		'settings' => 'oginer_contact_id',
		'type' => 'text',
	));
	
	$wp_customize->add_setting( 'oginer_contact_page', array(
		'default' => '',
		'sanitize_callback' => 'oginer_sanitize_dropdown_pages',
	));
	
	$wp_customize->add_control( 'oginer_contact_page', array(
		'label' => __( 'Contact Title', 'oginer' ),
		'description' => __( 'Title - description section.', 'oginer' ),
		'section' => 'oginer_homepage_contact',
		'settings' => 'oginer_contact_page',
		'type' => 'dropdown-pages',
	));
	
	$wp_customize->add_setting( 'oginer_contact_cf7', array(
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_contact_cf7', array(
	    'label' =>  __( 'Enter Contact Form 7 Shortcode', 'oginer' ),
		'description' => sprintf( __( 'Recommended %1$s Contact Form 7 %2$s plugin', 'oginer' ), '<a href="'.esc_url('https://wordpress.org/plugins/contact-form-7/').'" target="_blank">','</a>' ),
		'section' => 'oginer_homepage_contact',
		'settings' => 'oginer_contact_cf7',
		'type' => 'text'
	));	
	
	$wp_customize->add_setting( 'oginer_contact_adress', array(
		'default' => '',
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_contact_adress', array(
		'label' => __( 'Contact Address', 'oginer' ),
		'section' => 'oginer_homepage_contact',
		'settings' => 'oginer_contact_adress',
		'type' => 'text',
	));
	
	$wp_customize->add_setting( 'oginer_contact_phone', array(
		'default' => '',
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_contact_phone', array(
		'label' => __( 'Contact Phone Number', 'oginer' ),
		'section' => 'oginer_homepage_contact',
		'settings' => 'oginer_contact_phone',
		'type' => 'text',
	));
	
	$wp_customize->add_setting( 'oginer_contact_email', array(
		'default' => '',
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_contact_email', array(
		'label' => __( 'Contact Email', 'oginer' ),
		'section' => 'oginer_homepage_contact',
		'settings' => 'oginer_contact_email',
		'type' => 'text',
	));	
	
	$wp_customize->add_setting( 'oginer_contact_more_icon', array(
		'default' => 'fa-clock-o',
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_contact_more_icon', array(
		'label' => __( 'Contact More Info Icon', 'oginer' ),
		'description' => sprintf( __( 'Use font awesome icon: Eg: %1$s. %2$s See more here %3$s', 'oginer' ), 'fa-desktop','<a href="'.esc_url( $link_icon_fa ).'" target="_blank">','</a>' ),
		'section' => 'oginer_homepage_contact',
		'settings' => 'oginer_contact_more_icon',
		'type' => 'text',
	));
	
	$wp_customize->add_setting( 'oginer_contact_more_text', array(
		'default' => __( 'Mon - Sat: 9:00 - 18:00', 'oginer' ),
		'sanitize_callback' => 'sanitize_text_field',
	));
	
	$wp_customize->add_control( 'oginer_contact_more_text', array(
		'label' => __( 'Contact More Info Text', 'oginer' ),
		'section' => 'oginer_homepage_contact',
		'settings' => 'oginer_contact_more_text',
		'type' => 'text',
	));
	
	//Show Social Icons
	$wp_customize->add_setting( 'oginer_show_footer_icon', array (
		'default' => 1,
		'sanitize_callback' => 'oginer_sanitize_checkbox',
	));
	
	$wp_customize->add_control( 'oginer_show_footer_icon' , array(
		'label' => __( 'Show Social Icons' , 'oginer' ),
		'section' => 'oginer_homepage_contact',
		'settings' => 'oginer_show_footer_icon' ,
		'type' => 'checkbox',
	));		

	// Social Icons
	$wp_customize->add_section('oginer_social', array(
        'title'    => __( 'Social Links', 'oginer' ),
        'priority' => 80,
    ));
	
    $wp_customize->add_setting('oginer_icon_facebook', array(
        'default'        => '',
		'sanitize_callback' => 'esc_url_raw',
    ));
 
    $wp_customize->add_control('oginer_icon_facebook', array(
        'label'      => __('Facebook', 'oginer'),
        'section'    => 'oginer_social',
        'settings'   => 'oginer_icon_facebook',
    ));
	
	$wp_customize->add_setting('oginer_icon_twitter', array(
        'default'        => '',
		'sanitize_callback' => 'esc_url_raw',
	));
	   
	$wp_customize->add_control('oginer_icon_twitter', array(
        'label'      => __('Twitter', 'oginer'),
        'section'    => 'oginer_social',
        'settings'   => 'oginer_icon_twitter',
    ));	
	
	$wp_customize->add_setting('oginer_icon_google', array(
        'default'        => '',
		'sanitize_callback' => 'esc_url_raw',
	));
	   
	$wp_customize->add_control('oginer_icon_google', array(
        'label'      => __('Google+', 'oginer'),
        'section'    => 'oginer_social',
        'settings'   => 'oginer_icon_google',
    ));
	
	$wp_customize->add_setting('oginer_icon_youtube', array(
        'default'        => '',
		'sanitize_callback' => 'esc_url_raw',
	));
	   
	$wp_customize->add_control('oginer_icon_youtube', array(
        'label'      => __('Youtube', 'oginer'),
        'section'    => 'oginer_social',
        'settings'   => 'oginer_icon_youtube',
    ));
	
	$wp_customize->add_setting('oginer_icon_linkedin', array(
        'default'        => '',
		'sanitize_callback' => 'esc_url_raw',
	));
	   
	$wp_customize->add_control('oginer_icon_linkedin', array(
        'label'      => __('LinkedIn', 'oginer'),
        'section'    => 'oginer_social',
        'settings'   => 'oginer_icon_linkedin',
    ));
	
	$wp_customize->add_setting('oginer_icon_instagram', array(
        'default'        => '',
		'sanitize_callback' => 'esc_url_raw',
	));
	   
	$wp_customize->add_control('oginer_icon_instagram', array(
        'label'      => __('Instagram', 'oginer'),
        'section'    => 'oginer_social',
        'settings'   => 'oginer_icon_instagram',
    ));
	
	$wp_customize->add_setting('oginer_icon_flickr', array(
        'default'        => '',
		'sanitize_callback' => 'esc_url_raw',
	));
	   
	$wp_customize->add_control('oginer_icon_flickr', array(
        'label'      => __('Flickr', 'oginer'),
        'section'    => 'oginer_social',
        'settings'   => 'oginer_icon_flickr',
    ));
	
	$wp_customize->add_setting('oginer_icon_pinterest', array(
        'default'        => '',
		'sanitize_callback' => 'esc_url_raw',
	));
	   
	$wp_customize->add_control('oginer_icon_pinterest', array(
        'label'      => __('Pinterest', 'oginer'),
        'section'    => 'oginer_social',
        'settings'   => 'oginer_icon_pinterest',
    ));
	
	$wp_customize->add_setting('oginer_icon_vimeo', array(
        'default'        => '',
		'sanitize_callback' => 'esc_url_raw',
	));
	   
	$wp_customize->add_control('oginer_icon_vimeo', array(
        'label'      => __('Vimeo', 'oginer'),
        'section'    => 'oginer_social',
        'settings'   => 'oginer_icon_vimeo',
    ));
	
	$wp_customize->add_setting('oginer_icon_tumblr', array(
        'default'        => '',
		'sanitize_callback' => 'esc_url_raw',
	));
	   
	$wp_customize->add_control('oginer_icon_tumblr', array(
        'label'      => __('Tumblr', 'oginer'),
        'section'    => 'oginer_social',
        'settings'   => 'oginer_icon_tumblr',
    ));
	
	$wp_customize->add_setting('oginer_icon_dribbble', array(
        'default'        => '',
		'sanitize_callback' => 'esc_url_raw',
	));
	   
	$wp_customize->add_control('oginer_icon_dribbble', array(
        'label'      => __('Dribbble', 'oginer'),
        'section'    => 'oginer_social',
        'settings'   => 'oginer_icon_dribbble',
    ));
	
	//end icon free
	
	$wp_customize->add_setting('oginer_icon_rss', array(
        'default'        => '',
		'sanitize_callback' => 'esc_url_raw',
	));
	   
	$wp_customize->add_control('oginer_icon_rss', array(
        'label'      => __('RSS', 'oginer'),
        'section'    => 'oginer_social',
        'settings'   => 'oginer_icon_rss',
    ));

	// Footer Options
	$wp_customize->add_section( 'oginer_footer', array(
        'title'    => __( 'Footer Options', 'oginer' ),
        'priority' => 90,
    ));
	
	$wp_customize->add_setting( 'oginer_footer_text', array(
		'default' => __( 'Copyright 2017 All rights reserved.', 'oginer' ),
		'sanitize_callback' => 'sanitize_text_field',		
	));

	$wp_customize->add_control( 'oginer_footer_text', array(
		'label' => __( 'Enter your text in footer.', 'oginer' ),
		'section' => 'oginer_footer',
		'settings' => 'oginer_footer_text',
		'type' => 'textarea',
	));
	/*	*/
}
add_action( 'customize_register', 'oginer_customize_register' );

/**
 * Sanitize checkbox
 */
if (!function_exists( 'oginer_sanitize_checkbox' ) ) :
	function oginer_sanitize_checkbox( $input ) {
		if ( $input == 1 ) {
			return 1;
		} else {
			return '';
		}
	}
endif;

function oginer_sanitize_banner_text_position( $input ) {
    $valid = array(
        'text-image'	=> __('Text Left + Image Right', 'oginer'),
		'text'			=> __('Text Center', 'oginer'),
		'center' 		=> __('Text + Image Center', 'oginer'),
    );
 
    if ( array_key_exists( $input, $valid ) ) {
        return $input;
    } else {
        return '';
    }
}

function oginer_sanitize_banner_bg_position( $input ) {
    $valid = array(
        'top'		=> __('Top', 'oginer'),
		'center'	=> __('Center', 'oginer'),
		'bottom' 	=> __('Bottom', 'oginer'),
    );
 
    if ( array_key_exists( $input, $valid ) ) {
        return $input;
    } else {
        return '';
    }
}

function oginer_sanitize_dropdown_pages( $page_id, $setting ) {
  // Ensure $input is an absolute integer.
  $page_id = absint( $page_id );

  // If $page_id is an ID of a published page, return it; otherwise, return the default.
  return ( 'publish' == get_post_status( $page_id ) ? $page_id : $setting->default );
}

/**
 * Render the site title for the selective refresh partial.
 *
 * @return void
 */
function oginer_customize_partial_blogname() {
	bloginfo( 'name' );
}

/**
 * Render the site tagline for the selective refresh partial.
 *
 * @return void
 */
function oginer_customize_partial_blogdescription() {
	bloginfo( 'description' );
}

/**
 * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
 */
function oginer_customize_preview_js() {
	wp_enqueue_script( 'oginer-customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20151215', true );
}
add_action( 'customize_preview_init', 'oginer_customize_preview_js' );

function oginer_custom_css() {
	$banner_text_position = get_theme_mod( 'oginer_banner_text_position' );
	$banner_bg_position = get_theme_mod( 'oginer_banner_bg_position' );

    ?>
		<style type="text/css">
			
			<?php if ( get_header_image() ) : ?>
			.header {
				background-image: url('<?php header_image(); ?>');
			}
			<?php endif; ?>
			<?php if ( $banner_text_position == 'text' ) {
				?>
				.header-overlay {
					padding-bottom: 200px;
				}
				<?php
			} else if ( $banner_text_position == 'center' ) {
				?>
				.header .button-box {
					padding-bottom: 40px;
				}
				<?php				
			}?>
			<?php if ( $banner_bg_position != '' ) {
				?>
				.header {
					background-position-y: <?php echo $banner_bg_position; ?>;
				}
				<?php
			} ?>

		</style>
    <?php
}
add_action( 'wp_head', 'oginer_custom_css');