<?php

/**
 * Banner Section
 *
 * @package fast_food_joint
 */

$wp_customize->add_section(
	'fast_food_joint_banner_section',
	array(
		'panel'    => 'fast_food_joint_front_page_options',
		'title'    => esc_html__( 'Banner Section', 'fast-food-joint' ),
		'priority' => 10,
	)
);

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

$wp_customize->add_control(
	new Fast_Food_Joint_Toggle_Switch_Custom_Control(
		$wp_customize,
		'fast_food_joint_enable_banner_section',
		array(
			'label'    => esc_html__( 'Enable Banner Section', 'fast-food-joint' ),
			'section'  => 'fast_food_joint_banner_section',
			'settings' => 'fast_food_joint_enable_banner_section',
		)
	)
);

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

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

$wp_customize->add_control(
	'fast_food_joint_banner_slider_content_type',
	array(
		'label'           => esc_html__( 'Select Banner Slider Content Type', 'fast-food-joint' ),
		'section'         => 'fast_food_joint_banner_section',
		'settings'        => 'fast_food_joint_banner_slider_content_type',
		'type'            => 'select',
		'active_callback' => 'fast_food_joint_is_banner_slider_section_enabled',
		'choices'         => array(
			'page' => esc_html__( 'Page', 'fast-food-joint' ),
			'post' => esc_html__( 'Post', 'fast-food-joint' ),
		),
	)
);

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

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

	$wp_customize->add_control(
		'fast_food_joint_banner_slider_content_post_' . $i,
		array(
			/* translators: %d: Post Count. */
			'label'           => sprintf( esc_html__( 'Select Post %d', 'fast-food-joint' ), $i ),
			'section'         => 'fast_food_joint_banner_section',
			'settings'        => 'fast_food_joint_banner_slider_content_post_' . $i,
			'active_callback' => 'fast_food_joint_is_banner_slider_section_and_content_type_post_enabled',
			'type'            => 'select',
			'choices'         => fast_food_joint_get_post_choices(),
		)
	);

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

	$wp_customize->add_control(
		'fast_food_joint_banner_slider_content_page_' . $i,
		array(
			/* translators: %d: Page Count. */
			'label'           => sprintf( esc_html__( 'Select Page %d', 'fast-food-joint' ), $i ),
			'section'         => 'fast_food_joint_banner_section',
			'settings'        => 'fast_food_joint_banner_slider_content_page_' . $i,
			'active_callback' => 'fast_food_joint_is_banner_slider_section_and_content_type_page_enabled',
			'type'            => 'select',
			'choices'         => fast_food_joint_get_page_choices(),
		)
	);

	// Banner Section - Button Label.
	$wp_customize->add_setting(
		'fast_food_joint_banner_button_label_' . $i,
		array(
			'default'           => 'View Offer',
			'sanitize_callback' => 'sanitize_text_field',
		)
	);

	$wp_customize->add_control(
		'fast_food_joint_banner_button_label_' . $i,
		array(
			/* translators: %d: Button Lable Count. */
			'label'           => sprintf( esc_html__( 'Button Label %d', 'fast-food-joint' ), $i ),
			'section'         => 'fast_food_joint_banner_section',
			'settings'        => 'fast_food_joint_banner_button_label_' . $i,
			'type'            => 'text',
			'active_callback' => 'fast_food_joint_is_banner_slider_section_enabled',
		)
	);

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

	$wp_customize->add_control(
		'fast_food_joint_banner_button_link_' . $i,
		array(
			/* translators: %d: Button Link Count. */
			'label'           => sprintf( esc_html__( 'Button Link %d', 'fast-food-joint' ), $i ),
			'section'         => 'fast_food_joint_banner_section',
			'settings'        => 'fast_food_joint_banner_button_link_' . $i,
			'type'            => 'url',
			'active_callback' => 'fast_food_joint_is_banner_slider_section_enabled',
		)
	);
}

// Banner Button Label Color
$wp_customize->add_setting(
	'fast_food_joint_banner_btn_color',
	array(
		'default' => '',
		'sanitize_callback' => 'sanitize_hex_color',
	)
);
$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize,'fast_food_joint_banner_btn_color',array(
			'label' => __('Banner Button Label Color','fast-food-joint'),
			'section' => 'fast_food_joint_banner_section',
			'settings' => 'fast_food_joint_banner_btn_color',
			'active_callback' => 'fast_food_joint_is_banner_slider_section_enabled',
		)
	)
);

// Banner Button Background Color
$wp_customize->add_setting('fast_food_joint_banner_btn_bg_color',array(
		'default' => '',
		'sanitize_callback' => 'sanitize_hex_color',
	)
);
$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize,'fast_food_joint_banner_btn_bg_color',array(
			'label' => __('Banner Button Background Color','fast-food-joint'),
			'section' => 'fast_food_joint_banner_section',
			'settings' => 'fast_food_joint_banner_btn_bg_color',
			'active_callback' => 'fast_food_joint_is_banner_slider_section_enabled',
		)
	)
);
// Banner Button Border Color
$wp_customize->add_setting(
	'fast_food_joint_banner_btn_border_color',array(
		'default' => '',
		'sanitize_callback' => 'sanitize_hex_color',
	)
);
$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize,'fast_food_joint_banner_btn_border_color',array(
			'label' => __('Banner Button Border Color','fast-food-joint'),
			'section' => 'fast_food_joint_banner_section',
			'settings' => 'fast_food_joint_banner_btn_border_color',
			'active_callback' => 'fast_food_joint_is_banner_slider_section_enabled',
		)
	)
);