<?php
/**
 * Hero Section options
 *
 * @package Theme Palace
 * @subpackage Pushpa
 * @since Pushpa 1.0.0
 */

// Add Hero section
$wp_customize->add_section( 'pushpa_hero_banner_section', array(
	'title'             => esc_html__( 'Hero Section','pushpa' ),
	'description'       => esc_html__( 'Hero Section options.', 'pushpa' ),
	'panel'             => 'pushpa_front_page_panel',
	) );

// Hero content enable control and setting
$wp_customize->add_setting( 'pushpa_theme_options[hero_banner_section_enable]', array(
	'default'			=> 	$options['hero_banner_section_enable'],
	'sanitize_callback' => 'pushpa_sanitize_switch_control',
	) );

$wp_customize->add_control( new Pushpa_Switch_Control( $wp_customize, 'pushpa_theme_options[hero_banner_section_enable]', array(
	'label'             => esc_html__( 'Hero Section Enable', 'pushpa' ),
	'section'           => 'pushpa_hero_banner_section',
	'on_off_label' 		=> pushpa_switch_options(),
	) ) );

if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'pushpa_theme_options[hero_banner_section_enable]', array(
		'selector'            => '#pushpa_hero_banner .tooltiptext',
		'settings'            => 'pushpa_theme_options[hero_banner_section_enable]',
    ) );
}


for ( $i = 1; $i <= 3; $i++ ) :

// hero posts drop down chooser control and setting
$wp_customize->add_setting( 'pushpa_theme_options[hero_banner_content_post_' . $i . ']', array(
	'sanitize_callback' => 'pushpa_sanitize_page',
	) );

$wp_customize->add_control( new Pushpa_Dropdown_Chooser( $wp_customize, 'pushpa_theme_options[hero_banner_content_post_' . $i . ']', array(
	'label'             => sprintf( esc_html__( 'Select Post %d', 'pushpa' ), $i ),
	'section'           => 'pushpa_hero_banner_section',
	'choices'			=> pushpa_post_choices(),
	'active_callback'	=> 'pushpa_is_hero_banner_section_enable',
	) ) );
endfor;

// weekly_special title setting and control
$wp_customize->add_setting( 'pushpa_theme_options[hero_banner_btn]', array(
	'sanitize_callback' => 'sanitize_text_field',
	'default'			=> $options['hero_banner_btn'],
	'transport'			=> 'postMessage',
	) );

$wp_customize->add_control( 'pushpa_theme_options[hero_banner_btn]', array(
	'label'           	=> esc_html__( 'Button Label', 'pushpa' ),
	'section'        	=> 'pushpa_hero_banner_section',
	'active_callback' 	=> 'pushpa_is_hero_banner_section_enable',
	'type'				=> 'text',
	) );

// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
	$wp_customize->selective_refresh->add_partial( 'pushpa_theme_options[hero_banner_btn]', array(
		'selector'            => '#pushpa_hero_banner .read-more .btn',
		'settings'            => 'pushpa_theme_options[hero_banner_btn]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'pushpa_hero_banner_btn_partial',
		) );
}