<?php
/**
 * Site Identity Settings
 * 
 * @package travel-tour
 */

add_action( 'customize_register', 'travel_tour_change_site_identity_panel' );

function travel_tour_change_site_identity_panel( $wp_customize)  {

    $wp_customize->get_section( 'title_tagline' )->priority = 3;
    $wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
    $wp_customize->get_control( 'blogname' )->priority = 4;
    $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
    $wp_customize->get_control( 'blogdescription' )->priority = 7;

    $wp_customize->get_section( 'static_front_page' )->priority = 20;

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

    $wp_customize->get_section( 'title_tagline' )->panel = 'travel_tour_general_panel';

    $wp_customize->add_setting( 'travel_tour_logo_size', array(
        'default'           => 60,
        'sanitize_callback' => 'absint',
        'transport' => 'postMessage',
    ) );

    $wp_customize->add_control( new Travel_Tour_Slider_Control(
        $wp_customize, 'travel_tour_logo_size', array(
            'section' => 'title_tagline',
            'settings' => 'travel_tour_logo_size',
            'label'   => esc_html__( 'Logo Size', 'travel-tour' ),
            'choices'     => array(
                'min'   => 40,
                'max'   => 100,
                'step'  => 1,
            )
        )
    ) );

    $wp_customize->add_setting( 'travel_tour_site_identity_font_family', array(
        'transport' => 'postMessage',
        'sanitize_callback' => 'travel_tour_sanitize_google_fonts',
        'default'     => 'Montserrat',
    ) );

    $wp_customize->add_control( 'travel_tour_site_identity_font_family', array(
        'label'       =>  esc_html__( 'Site Identity Font Family', 'travel-tour' ),
        'section'     => 'title_tagline',
        'type'        => 'select',
        'choices'     => travel_tour_google_fonts(),
    ) );
}

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

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