<?php
/**
 * Matrimony Theme Customizer
 *
 * @package Matrimony
 */
/**
 * Add postMessage support for site title and description for the Theme Customizer.
 *
 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
 */
function matrimony_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';
	/****************  Add Default Sections to General Panel ************/
	$wp_customize->get_section('title_tagline')->panel = 'matrimony_default_setups'; //priority 20
	$wp_customize->get_section('colors')->panel = 'matrimony_default_setups'; //priority 40
	$wp_customize->get_section('background_image')->panel = 'matrimony_default_setups'; //priority 80
	$wp_customize->get_section('static_front_page')->panel = 'matrimony_default_setups'; //priority 120
	$wp_customize->get_section( 'header_image' )->panel = 'matrimony_general_panel';
	$wp_customize->get_section( 'header_image' )->title = esc_html__( 'Breadcrumb Image', 'matrimony' );
	$wp_customize->get_section( 'header_image' )->priority = 3;
	
	$wp_customize->add_panel('matrimony_default_setups',
		array(
			'priority' => 10,
			'capability' => 'edit_theme_options',
			'theme_supports' => '',
			'title' => esc_html__('Default/Basic Sections','matrimony'),
	));
	
	if ( isset( $wp_customize->selective_refresh ) ) {
		$wp_customize->selective_refresh->add_partial( 'blogname', array(
			'selector'        => '.site-title a',
			'render_callback' => 'matrimony_customize_partial_blogname',
		) );
		$wp_customize->selective_refresh->add_partial( 'blogdescription', array(
			'selector'        => '.site-description',
			'render_callback' => 'matrimony_customize_partial_blogdescription',
		) );
	}
	require get_template_directory().'/inc/customizer/customizer-control.php';	

	// Load Customize Sanitize.
	require trailingslashit( get_template_directory() ) . '/inc/customizer/sanitizer.php';

	/**
	 * Load  Custom Customizer Header Options.
	 */
	require get_template_directory() . '/inc/customizer/customizer-header-options.php';

	/**
	 * Load  Custom Customizer Header Options.
	 */
	require get_template_directory() . '/inc/customizer/customizer-footer-options.php';	
	/**
	 * Load  Custom Customizer Front Page Options.
	 */
	require get_template_directory() . '/inc/customizer/customizer-options.php';	

	/**
	 * Load  Custom Customizer Front Page Options.
	 */
	require get_template_directory() . '/inc/customizer/customizer-front-page-options.php';	



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

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

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

/**
 * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
 */
function matrimony_customize_backend_scripts() {

	wp_enqueue_script( 'matrimony-customizer-scripts', get_template_directory_uri() . '/inc/customizer/js/admin.js', array( 'jquery', 'customize-controls' ), '20160714', true );
	wp_enqueue_style( 'matrimony-customizer-style', get_template_directory_uri() . '/inc/customizer/css/admin.css' );

}
add_action( 'customize_controls_enqueue_scripts', 'matrimony_customize_backend_scripts', 10 );

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