<?php
/**
 * Banner Section
 *
 * @package Minimalistic Blog
 */

$wp_customize->add_section(
	'minimalistic_blog_banner_section',
	array(
		'panel' => 'minimalistic_blog_front_page_options',
		'title' => esc_html__( 'Banner Section', 'minimalistic-blog' ),
	)
);

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

$wp_customize->add_control(
	new Minimalistic_Blog_Toggle_Switch_Custom_Control(
		$wp_customize,
		'minimalistic_blog_enable_banner_section',
		array(
			'label'    => esc_html__( 'Enable Banner Section', 'minimalistic-blog' ),
			'section'  => 'minimalistic_blog_banner_section',
			'settings' => 'minimalistic_blog_enable_banner_section',
		)
	)
);

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

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

$wp_customize->add_control(
	'minimalistic_blog_banner_slider_content_type',
	array(
		'label'           => esc_html__( 'Select Content Type', 'minimalistic-blog' ),
		'section'         => 'minimalistic_blog_banner_section',
		'settings'        => 'minimalistic_blog_banner_slider_content_type',
		'type'            => 'select',
		'active_callback' => 'minimalistic_blog_is_banner_section_enabled',
		'choices'         => array(
			'post'     => esc_html__( 'Post', 'minimalistic-blog' ),
			'category' => esc_html__( 'Category', 'minimalistic-blog' ),
		),
	)
);

// Banner Section - Select Banner Category.
$wp_customize->add_setting(
	'minimalistic_blog_banner_slider_content_category',
	array(
		'sanitize_callback' => 'minimalistic_blog_sanitize_select',
	)
);

$wp_customize->add_control(
	'minimalistic_blog_banner_slider_content_category',
	array(
		'label'           => esc_html__( 'Select Category', 'minimalistic-blog' ),
		'section'         => 'minimalistic_blog_banner_section',
		'settings'        => 'minimalistic_blog_banner_slider_content_category',
		'active_callback' => 'minimalistic_blog_is_banner_slider_and_content_type_category_enabled',
		'type'            => 'select',
		'choices'         => minimalistic_blog_get_post_cat_choices(),
	)
);

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

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

	$wp_customize->add_control(
		'minimalistic_blog_banner_slider_content_post_' . $i,
		array(
			'label'           => sprintf( esc_html__( 'Select Post %d', 'minimalistic-blog' ), $i ),
			'section'         => 'minimalistic_blog_banner_section',
			'settings'        => 'minimalistic_blog_banner_slider_content_post_' . $i,
			'active_callback' => 'minimalistic_blog_is_banner_slider_and_content_type_post_enabled',
			'type'            => 'select',
			'choices'         => minimalistic_blog_get_post_choices(),
		)
	);

}
