<?php
/**
 * Grid Carousel Section
 *
 * @package Fuzion_Blog
 */

$wp_customize->add_section(
	'fuzion_blog_grid_carousel_section',
	array(
		'panel' => 'fuzion_blog_front_page_options',
		'title' => esc_html__( 'Grid Carousel Section', 'fuzion-blog' ),
	)
);

// Grid Carousel Section - Enable Section.
$wp_customize->add_setting(
	'fuzion_blog_enable_grid_carousel_section',
	array(
		'default'           => false,
		'sanitize_callback' => 'fuzion_blog_sanitize_switch',
	)
);

$wp_customize->add_control(
	new Fuzion_Blog_Toggle_Switch_Custom_Control(
		$wp_customize,
		'fuzion_blog_enable_grid_carousel_section',
		array(
			'label'    => esc_html__( 'Enable Grid Carousel Section', 'fuzion-blog' ),
			'section'  => 'fuzion_blog_grid_carousel_section',
			'settings' => 'fuzion_blog_enable_grid_carousel_section',
		)
	)
);

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

// Grid Carousel Section - Section Title.
$wp_customize->add_setting(
	'fuzion_blog_grid_carousel_section_title',
	array(
		'default'           => __( 'Explore Asia Wonder', 'fuzion-blog' ),
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'fuzion_blog_grid_carousel_section_title',
	array(
		'label'           => esc_html__( 'Section Title', 'fuzion-blog' ),
		'section'         => 'fuzion_blog_grid_carousel_section',
		'settings'        => 'fuzion_blog_grid_carousel_section_title',
		'type'            => 'text',
		'active_callback' => 'fuzion_blog_is_grid_carousel_section_enabled',
	)
);

// Grid Carousel Section - Content Type.
$wp_customize->add_setting(
	'fuzion_blog_grid_carousel_content_type',
	array(
		'default'           => 'post',
		'sanitize_callback' => 'fuzion_blog_sanitize_select',
	)
);

$wp_customize->add_control(
	'fuzion_blog_grid_carousel_content_type',
	array(
		'label'           => esc_html__( 'Select Content Type', 'fuzion-blog' ),
		'section'         => 'fuzion_blog_grid_carousel_section',
		'settings'        => 'fuzion_blog_grid_carousel_content_type',
		'type'            => 'select',
		'active_callback' => 'fuzion_blog_is_grid_carousel_section_enabled',
		'choices'         => array(
			'post'     => esc_html__( 'Post', 'fuzion-blog' ),
			'category' => esc_html__( 'Category', 'fuzion-blog' ),
		),
	)
);

// Grid Carousel Section - Select Grid Carousel Category.
$wp_customize->add_setting(
	'fuzion_blog_grid_carousel_content_category',
	array(
		'sanitize_callback' => 'fuzion_blog_sanitize_select',
	)
);

$wp_customize->add_control(
	'fuzion_blog_grid_carousel_content_category',
	array(
		'label'           => esc_html__( 'Select Category', 'fuzion-blog' ),
		'section'         => 'fuzion_blog_grid_carousel_section',
		'settings'        => 'fuzion_blog_grid_carousel_content_category',
		'active_callback' => 'fuzion_blog_is_grid_carousel_section_and_content_type_category_enabled',
		'type'            => 'select',
		'choices'         => fuzion_blog_get_post_cat_choices(),
	)
);

for ( $i = 1; $i <= 4; $i++ ) {
	// Grid Carousel Section - Select Post.
	$wp_customize->add_setting(
		'fuzion_blog_grid_carousel_content_post_' . $i,
		array(
			'sanitize_callback' => 'absint',
		)
	);

	$wp_customize->add_control(
		'fuzion_blog_grid_carousel_content_post_' . $i,
		array(
			'label'           => sprintf( esc_html__( 'Select Post %d', 'fuzion-blog' ), $i ),
			'section'         => 'fuzion_blog_grid_carousel_section',
			'settings'        => 'fuzion_blog_grid_carousel_content_post_' . $i,
			'active_callback' => 'fuzion_blog_is_grid_carousel_section_and_content_type_post_enabled',
			'type'            => 'select',
			'choices'         => fuzion_blog_get_post_choices(),
		)
	);

}
