<?php
/**
 * Exbico Theme Customizer
 *
 * @package Roland
 */

/**
 * Add postMessage support for site title and description for the Theme Customizer.
 *
 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
 */
function roland_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' => 'roland_customize_partial_blogname',
		) );
		$wp_customize->selective_refresh->add_partial( 'blogdescription', array(
			'selector'        => '.site-description',
			'render_callback' => 'roland_customize_partial_blogdescription',
		) );
	}
}
add_action( 'customize_register', 'roland_customize_register' );

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

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

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


// Load customizer required panels

// Sanitize
require trailingslashit( get_template_directory() ) . '/includes/sanitize.php'; 

// Pro Version
require_once trailingslashit( get_template_directory() ) . '/includes/upgrade-to-pro/control.php';

//  Roland Theme Settings Customizer
add_action( 'customize_register', 'roland_register_customizer_settings' );
function roland_register_customizer_settings( $wp_customize ) {
$wp_customize->add_panel( 'roland_theme_settings', array(
	'priority'               => 1,
	'capability'             => 'edit_theme_options',
	'title'                  => __( 'Roland: Theme Settings', 'roland' ),
	'description'            => __( 'Theme All Settings', 'roland' ),
) );  

// Load Options
require_once trailingslashit( get_template_directory() ) . '/includes/roland-customizer/settings/customize-global.php';
require_once trailingslashit( get_template_directory() ) . '/includes/roland-customizer/settings/customize-footer.php';
require_once trailingslashit( get_template_directory() ) . '/includes/roland-customizer/settings/customize-breadcrumb.php';
}


//  Roland Theme Settings Customizer Front
add_action( 'customize_register', 'roland_register_customizer_front' );
function roland_register_customizer_front( $wp_customize ) {
$wp_customize->add_panel( 'roland_front_option', array(
	'priority'               => 2,
	'capability'             => 'edit_theme_options',
	'title'                  => __( 'Roland: Front Page', 'roland' ),
	'description'            => __( 'Roland sections & theme options', 'roland' ),
) );  

// Load Options
require trailingslashit( get_template_directory() ) . '/includes/roland-customizer/front/customize-hero-slider.php';
require trailingslashit( get_template_directory() ) . '/includes/roland-customizer/front/customize-about-us.php';
require trailingslashit( get_template_directory() ) . '/includes/roland-customizer/front/customize-services.php';
require trailingslashit( get_template_directory() ) . '/includes/roland-customizer/front/customize-achivement.php';
require trailingslashit( get_template_directory() ) . '/includes/roland-customizer/front/customize-doctor.php';
require trailingslashit( get_template_directory() ) . '/includes/roland-customizer/front/customize-blog.php';


// Upgrade to Pro
$wp_customize->register_section_type( 'roland_Customize_Section_Upsell' );
// Register sections.
$wp_customize->add_section(
	new roland_Customize_Section_Upsell(
		$wp_customize,
		'theme_upsell',
		array(
			'title'    => esc_html__( 'Now Available Roland Pro ', 'roland' ),
			'pro_text' => esc_html__( 'Buy Now', 'roland' ),
			'pro_url'  => 'https://pencilwp.com/product/roland-pro/',
			'priority' => 1,
		)
	)
);
// Roland Customizer Scripts
function roland_customizer_control_scripts() {
	wp_enqueue_script( 'roland-customize-controls', get_template_directory_uri() . '/includes/upgrade-to-pro/customize-controls.js', array( 'customize-controls' ) );
	wp_enqueue_style( 'roland-customize-controls', get_template_directory_uri() . '/includes/upgrade-to-pro/customize-controls.css' );
}
add_action( 'customize_controls_enqueue_scripts', 'roland_customizer_control_scripts', 0 );

}