<?php

/**
 * Banner Section
 *
 * @package Charity_Elite
 */

$wp_customize->add_section(
	'charity_elite_banner_section',
	array(
		'panel'    => 'charity_elite_front_page_options',
		'title'    => esc_html__( 'Banner Section', 'charity-elite' ),
		'priority' => 10,
	)
);

// Banner Section - Enable Section.
$wp_customize->add_setting(
	'charity_elite_enable_banner_section',
	array(
		'default'           => false,
		'sanitize_callback' => 'charity_elite_sanitize_switch',
	)
);

$wp_customize->add_control(
	new Charity_Elite_Toggle_Switch_Custom_Control(
		$wp_customize,
		'charity_elite_enable_banner_section',
		array(
			'label'    => esc_html__( 'Enable Banner Section', 'charity-elite' ),
			'section'  => 'charity_elite_banner_section',
			'settings' => 'charity_elite_enable_banner_section',
		)
	)
);

if ( isset( $wp_customize->selective_refresh ) ) {
	$wp_customize->selective_refresh->add_partial(
		'charity_elite_enable_banner_section',
		array(
			'selector' => '#charity_elite_banner_section .section-link',
			'settings' => 'charity_elite_enable_banner_section',
		)
	);
}

// Banner Section - Background Image.
$wp_customize->add_setting(
	'charity_elite_banner_background_image',
	array(
		'sanitize_callback' => 'charity_elite_sanitize_image',
	)
);

$wp_customize->add_control(
	new WP_Customize_Image_Control(
		$wp_customize,
		'charity_elite_banner_background_image',
		array(
			'label'           => esc_html__( 'Background Image', 'charity-elite' ),
			'section'         => 'charity_elite_banner_section',
			'settings'        => 'charity_elite_banner_background_image',
			'active_callback' => 'charity_elite_is_banner_slider_section_enabled',
		)
	)
);

// Banner Section - Banner Content Type.
$wp_customize->add_setting(
	'charity_elite_banner_slider_content_type',
	array(
		'default'           => 'post',
		'sanitize_callback' => 'charity_elite_sanitize_select',
	)
);

$wp_customize->add_control(
	'charity_elite_banner_slider_content_type',
	array(
		'label'           => esc_html__( 'Select Banner Content Type', 'charity-elite' ),
		'section'         => 'charity_elite_banner_section',
		'settings'        => 'charity_elite_banner_slider_content_type',
		'type'            => 'select',
		'active_callback' => 'charity_elite_is_banner_slider_section_enabled',
		'choices'         => array(
			'page' => esc_html__( 'Page', 'charity-elite' ),
			'post' => esc_html__( 'Post', 'charity-elite' ),
		),
	)
);


	// Banner Section - Banner Subtitle.
$wp_customize->add_setting(
	'charity_elite_banner_subtitle',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'charity_elite_banner_subtitle',
	array(
		'label'           => esc_html__( 'Subtitle', 'charity-elite' ),
		'section'         => 'charity_elite_banner_section',
		'settings'        => 'charity_elite_banner_subtitle',
		'type'            => 'text',
		'active_callback' => 'charity_elite_is_banner_slider_section_enabled',
	)
);

	// Banner Section - Select Banner Post.
$wp_customize->add_setting(
	'charity_elite_banner_slider_content_post',
	array(
		'sanitize_callback' => 'absint',
	)
);

$wp_customize->add_control(
	'charity_elite_banner_slider_content_post',
	array(
		'label'           => esc_html__( 'Select Post', 'charity-elite' ),
		'section'         => 'charity_elite_banner_section',
		'settings'        => 'charity_elite_banner_slider_content_post',
		'active_callback' => 'charity_elite_is_banner_slider_section_and_content_type_post_enabled',
		'type'            => 'select',
		'choices'         => charity_elite_get_post_choices(),
	)
);

	// Banner Section - Select Banner Page.
$wp_customize->add_setting(
	'charity_elite_banner_slider_content_page',
	array(
		'sanitize_callback' => 'absint',
	)
);

$wp_customize->add_control(
	'charity_elite_banner_slider_content_page',
	array(
		'label'           => esc_html__( 'Select Page', 'charity-elite' ),
		'section'         => 'charity_elite_banner_section',
		'settings'        => 'charity_elite_banner_slider_content_page',
		'active_callback' => 'charity_elite_is_banner_slider_section_and_content_type_page_enabled',
		'type'            => 'select',
		'choices'         => charity_elite_get_page_choices(),
	)
);

	// Banner Section - Button Label.
$wp_customize->add_setting(
	'charity_elite_banner_button_label',
	array(
		'default'           => __( 'Read More', 'charity-elite' ),
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'charity_elite_banner_button_label',
	array(
		'label'           => esc_html__( 'Button Label', 'charity-elite' ),
		'section'         => 'charity_elite_banner_section',
		'settings'        => 'charity_elite_banner_button_label',
		'type'            => 'text',
		'active_callback' => 'charity_elite_is_banner_slider_section_enabled',
	)
);

	// Banner Section - Button Link.
$wp_customize->add_setting(
	'charity_elite_banner_button_link',
	array(
		'default'           => '',
		'sanitize_callback' => 'esc_url_raw',
	)
);

$wp_customize->add_control(
	'charity_elite_banner_button_link',
	array(
		'label'           => esc_html__( 'Button Link', 'charity-elite' ),
		'section'         => 'charity_elite_banner_section',
		'settings'        => 'charity_elite_banner_button_link',
		'type'            => 'url',
		'active_callback' => 'charity_elite_is_banner_slider_section_enabled',
	)
);
