<?php
/**
 * Banner Section
 *
 * @package cleaning_services_agent
 */

$wp_customize->add_section(
	'cleaning_services_agent_banner_section',
	array(
		'panel'    => 'cleaning_services_agent_front_page_options',
		'title'    => esc_html__( 'Banner Section', 'cleaning-services-agent' ),
		'priority' => 10,
	)
);

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

$wp_customize->add_control(
	new Cleaning_Services_Agent_Toggle_Switch_Custom_Control(
		$wp_customize,
		'cleaning_services_agent_enable_banner_section',
		array(
			'label'    => esc_html__( 'Enable Banner Section', 'cleaning-services-agent' ),
			'section'  => 'cleaning_services_agent_banner_section',
			'settings' => 'cleaning_services_agent_enable_banner_section',
		)
	)
);

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

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

$wp_customize->add_control(
	'cleaning_services_agent_banner_slider_content_type',
	array(
		'label'           => esc_html__( 'Select Banner Slider Content Type', 'cleaning-services-agent' ),
		'section'         => 'cleaning_services_agent_banner_section',
		'settings'        => 'cleaning_services_agent_banner_slider_content_type',
		'type'            => 'select',
		'active_callback' => 'cleaning_services_agent_is_banner_slider_section_enabled',
		'choices'         => array(
			'page' => esc_html__( 'Page', 'cleaning-services-agent' ),
			'post' => esc_html__( 'Post', 'cleaning-services-agent' ),
		),
	)
);

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

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

	$wp_customize->add_control(
		'cleaning_services_agent_banner_slider_content_post_' . $cleaning_services_agent_i,
		array(
			/* translators: %d: Select Post Count. */
			'label'           => sprintf( esc_html__( 'Select Post %d', 'cleaning-services-agent' ), $cleaning_services_agent_i ),
			'section'         => 'cleaning_services_agent_banner_section',
			'settings'        => 'cleaning_services_agent_banner_slider_content_post_' . $cleaning_services_agent_i,
			'active_callback' => 'cleaning_services_agent_is_banner_slider_section_and_content_type_post_enabled',
			'type'            => 'select',
			'choices'         => cleaning_services_agent_get_post_choices(),
		)
	);

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

	$wp_customize->add_control(
		'cleaning_services_agent_banner_slider_content_page_' . $cleaning_services_agent_i,
		array(
			/* translators: %d: Select Page Count. */
			'label'           => sprintf( esc_html__( 'Select Page %d', 'cleaning-services-agent' ), $cleaning_services_agent_i ),
			'section'         => 'cleaning_services_agent_banner_section',
			'settings'        => 'cleaning_services_agent_banner_slider_content_page_' . $cleaning_services_agent_i,
			'active_callback' => 'cleaning_services_agent_is_banner_slider_section_and_content_type_page_enabled',
			'type'            => 'select',
			'choices'         => cleaning_services_agent_get_page_choices(),
		)
	);

}

