<?php
/**
 * buzz-agency Theme Customizer
 *
 * @package Buzz_Agency
 */

/**
 * Add postMessage support for site title and description for the Theme Customizer.
 *
 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
 */
function buzz_agency_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';

	if ( isset( $wp_customize->selective_refresh ) ) {
		$wp_customize->selective_refresh->add_partial( 'blogname', array(
			'selector'        => '.site-title a',
			'render_callback' => 'buzz_agency_customize_partial_blogname',
		) );
		$wp_customize->selective_refresh->add_partial( 'blogdescription', array(
			'selector'        => '.site-description',
			'render_callback' => 'buzz_agency_customize_partial_blogdescription',
		) );
	}

	require get_template_directory().'/inc/customizer/control.php';	
	require get_template_directory().'/inc/customizer/repeater-controller/repeater-class.php';
    
}
add_action( 'customize_register', 'buzz_agency_customize_register' );

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

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

/**
 * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
 */

function buzz_agency_customize_backend_scripts() {

	wp_enqueue_script( 'buzz-agency-repeater-script', get_template_directory_uri() . '/inc/customizer/repeater-controller/repeater-script.js',array( 'jquery','jquery-ui-sortable'));

	// Load fontawesome
	wp_enqueue_style( 'font-awesome', get_template_directory_uri().'/assets/css/font-awesome.css', array(), '4.7.0' );	

	wp_enqueue_script( 'buzz-agency-customizer-scripts', get_template_directory_uri() . '/inc/js/admin.js', array( 'jquery', 'customize-controls' ), '20160714', true );

	wp_enqueue_style( 'buzz-agency-customizer-style', get_template_directory_uri() . '/inc/css/admin.css' );

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

/**
 * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
 */

function buzz_agency_customize_preview_js() {
	wp_enqueue_script( 'buzz-agency-customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20151215', true );
}
add_action( 'customize_preview_init', 'buzz_agency_customize_preview_js' );
