<?php
/**
 * Theme Options related to slider.
 *
 * @package Trainify
 */

// Slider Type Section.
$wp_customize->add_section(
	'trainify_banner_slider',
	array(
		'title'      => esc_html__( 'Banner Slider', 'trainify' ),
		'priority'   => 10,
		'capability' => 'edit_theme_options',
		'panel'      => 'trainify_homepage_panel',
	)
);

// Setting banner_slider_type.
$wp_customize->add_setting( 
	'banner_slider_post_type',
	array(
		'default'           => 'page',
		'capability'        => 'edit_theme_options',
		'sanitize_callback' => 'sanitize_trainify_posttype_values',
	)
);

$wp_customize->add_control( 
	'banner_slider_post_type',
	array(
		'label'           => esc_html__( 'Select Slider Type', 'trainify' ),
		'section'         => 'trainify_banner_slider',
		'type'            => 'select',
		'priority'        => 10,
		'choices'         => trainify_framework_posttypes(),
		//'choices'         => array( 'page'=> esc_html__('Page', 'trainify') ),
		'description'	  => esc_html__( 'After changing slider type value may slider could not appear on frontend. So please publish it once and refresh(customizer) it. After that you can manage banner slider items and publish it.', 'trainify' ),
	)
);

/**
 * Repeater field for social media icons
 *
 * @since 1.0.0
 */
$wp_customize->add_setting(
	'banner_slider_items', 
	array(
		'sanitize_callback' => 'trainify_framework_sanitize_repeater_data',
		'default' => json_encode(
			array(
				array(
					'post_type_item' => '',
					'description_alignment' => 'center',
					'primary_button_label'	=> esc_html__('Primary Button', 'trainify' ),
					'primary_button_url'	=> '#',
					'primary_button_target'	=> '_self',
					'secondary_button_label'	=> esc_html__('Secondary Button', 'trainify' ),
					'secondary_button_url'	=> '#',
					'secondary_button_target'	=> '_self',
				)
			)
		)
	)
);

$wp_customize->add_control(
	new TrainifyFramework_Customizer_Repeater_Control(
		$wp_customize, 
		'banner_slider_items', 
		array(
			'label' => esc_html__('Banner Slider Items', 'trainify'),
			'section' => 'trainify_banner_slider',
			'settings' => 'banner_slider_items',
			'priority' => 20,
			'add_row_label' => esc_html__('Add Slide', 'trainify'),
			'wraper_item_label' => esc_html__('Banner Slide Item', 'trainify'),
		), 
		array(
			'post_type_item' => array(
				'type' => 'select',
				'label' => esc_html__( 'Choose Post type item', 'trainify'),
				'description' => esc_html__('Choose slider post type item.', 'trainify'),
				'options' => trainify_get_post(
					array(
						'post_type' => get_theme_mod( 'banner_slider_post_type', 'page' )
					)
				),
			),
			'description_alignment' => array(
				'type' => 'select',
				'label' => esc_html__('Description Alignment', 'trainify'),
				'description' => esc_html__('Choose banner description alignment.', 'trainify'),
				'options' => array(
					'left'   => esc_html__( 'Left', 'trainify' ),
					'center' => esc_html__( 'Center', 'trainify' ),
					'right'  => esc_html__( 'Right', 'trainify' ),
				),
			),
			'primary_button_label' => array(
				'type' => 'text',
				'label' => esc_html__('Primary Button Label', 'trainify'),
				'description' => esc_html__('Please enter primary button label.', 'trainify'),
			),
			'primary_button_url' => array(
				'type' => 'text',
				'label' => esc_html__('Primary Button URL', 'trainify'),
				'description' => esc_html__('Please enter primary button url.', 'trainify'),
			),
			'primary_button_target' => array(
				'type' => 'select',
				'label' => esc_html__('Primary Button Target', 'trainify'),
				'description' => esc_html__('Please choose primary button target.', 'trainify'),
				'options' => array(
					''  => esc_html__( 'Disabled', 'trainify' ),
					'_self'   => esc_html__( 'Open with same tab', 'trainify' ),
					'_blank' => esc_html__( 'Open with New Tab', 'trainify' ),
				),
			),
			'secondary_button_label' => array(
				'type' => 'text',
				'label' => esc_html__('Secondary Button Label', 'trainify'),
				'description' => esc_html__('Please enter secondary button label.', 'trainify'),
			),
			'secondary_button_url' => array(
				'type' => 'text',
				'label' => esc_html__('Secondary Button URL', 'trainify'),
				'description' => esc_html__('Please enter secondary button url.', 'trainify'),
			),
			'secondary_button_target' => array(
				'type' => 'select',
				'label' => esc_html__('Secondary Button Target', 'trainify'),
				'description' => esc_html__('Please choose secondary button target.', 'trainify'),
				'options' => array(
					''  => esc_html__( 'Disabled', 'trainify' ),
					'_self'   => esc_html__( 'Open with same tab', 'trainify' ),
					'_blank' => esc_html__( 'Open with New Tab', 'trainify' ),
				),
			),
		)
	)
);

// Setting banner_slider_read_more_text.
$wp_customize->add_setting( 
	'banner_slider_readmore_text',
	array(
		'default'           => esc_html__( 'Read More...', 'trainify' ),
		'capability'        => 'edit_theme_options',
		'sanitize_callback' => 'sanitize_text_field',
	)
);
$wp_customize->add_control( 
	'banner_slider_readmore_text',
	array(
		'label'           => esc_html__( 'Read More Text', 'trainify' ),
		'section'         => 'trainify_banner_slider',
		'type'            => 'text',
		'priority'        => 30,
	)
);


// Setting banner_slider_transition_effect.
$wp_customize->add_setting( 
	'banner_slider_transition_effect',
	array(
		'default'           => 'fade',
		'capability'        => 'edit_theme_options',
		'sanitize_callback' => 'sanitize_trainify_transition_effect',
	)
);
$wp_customize->add_control( 
	'banner_slider_transition_effect',
	array(
		'label'    => esc_html__( 'Transition Effect', 'trainify' ),
		'section'  => 'trainify_banner_slider',
		'type'     => 'select',
		'priority' => 40,
		'choices'  => array(
			'fade'       => esc_html__( 'Fade', 'trainify' ),
			'slide'    => esc_html__( 'Slide', 'trainify' ),
		),
	)
);

// Setting banner_slider_transition_delay.
$wp_customize->add_setting( 
	'banner_slider_transition_delay',
	array(
		'default'           => 5,
		'capability'        => 'edit_theme_options',
		'sanitize_callback' => 'absint',
	)
);
$wp_customize->add_control( 
	'banner_slider_transition_delay',
	array(
		'label'       => esc_html__( 'Transition Delay', 'trainify' ),
		'description' => esc_html__( 'in seconds (default = 5)', 'trainify' ),
		'section'     => 'trainify_banner_slider',
		'type'        => 'number',
		'priority'    => 50,
		'input_attrs' => array( 'min' => 1, 'max' => 10, 'step' => 1 ),
	)
);
// Setting banner_slider_transition_duration.
$wp_customize->add_setting( 
	'banner_slider_transition_duration',
	array(
		'default'           => 2,
		'capability'        => 'edit_theme_options',
		'sanitize_callback' => 'absint',
	)
);
$wp_customize->add_control( 
	'banner_slider_transition_duration',
	array(
		'label'       => esc_html__( 'Transition Duration', 'trainify' ),
		'description' => esc_html__( 'in seconds (default = 2)', 'trainify' ),
		'section'     => 'trainify_banner_slider',
		'type'        => 'number',
		'priority'    => 60,
		'input_attrs' => array( 'min' => 1, 'max' => 10, 'step' => 1 ),
	)
);
// Setting banner_slider_enable_description.
$wp_customize->add_setting( 
	'banner_slider_enable_description',
	array(
		'default'           => 1,
		'capability'        => 'edit_theme_options',
		'sanitize_callback' => 'absint',
	)
);
$wp_customize->add_control( 
	'banner_slider_enable_description',
	array(
		'label'    => esc_html__( 'Enable Description', 'trainify' ),
		'section'  => 'trainify_banner_slider',
		'type'     => 'checkbox',
		'priority' => 70,
	)
);

// Setting banner_slider_arrow_layout.
$wp_customize->add_setting( 
	'banner_slider_arrow_layout',
	array(
		'default'           => 'disable',
		'capability'        => 'edit_theme_options',
		'sanitize_callback' => 'sanitize_text_field',
	)
);
$wp_customize->add_control( 
	'banner_slider_arrow_layout',
	array(
		'label'    => esc_html__( 'Arrow layout', 'trainify' ),
		'section'  => 'trainify_banner_slider',
		'type'     => 'select',
		'priority' => 80,
		'choices'	=> array(
			'disable' => esc_html__( 'Disable', 'trainify' ),
			'default' => esc_html__( 'Default', 'trainify' ),
		),
	)
);

// Setting banner_slider_enable_autoplay.
$wp_customize->add_setting( 
	'banner_slider_enable_autoplay',
	array(
		'default'           => 1,
		'capability'        => 'edit_theme_options',
		'sanitize_callback' => 'absint',
	)
);
$wp_customize->add_control( 
	'banner_slider_enable_autoplay',
	array(
		'label'    => esc_html__( 'Enable Autoplay', 'trainify' ),
		'section'  => 'trainify_banner_slider',
		'type'     => 'checkbox',
		'priority' => 90,
	)
);

// Setting banner_slider_enable_overlay.
$wp_customize->add_setting( 
	'banner_slider_enable_overlay',
	array(
		'default'           => 1,
		'capability'        => 'edit_theme_options',
		'sanitize_callback' => 'absint',
	)
);
$wp_customize->add_control( 
	'banner_slider_enable_overlay',
	array(
		'label'    => esc_html__( 'Enable Overlay', 'trainify' ),
		'section'  => 'trainify_banner_slider',
		'type'     => 'checkbox',
		'priority' => 100,
	)
);

// Setting banner_slider_thumbnail_size.
$wp_customize->add_setting( 
	'banner_slider_thumbnail_size',
	array(
		'default'           => 'full',
		'capability'        => 'edit_theme_options',
		'sanitize_callback' => 'sanitize_trainify_thumbnail_size',
	)
);
$wp_customize->add_control( 
	'banner_slider_thumbnail_size',
	array(
		'label'    => esc_html__( 'Thumbnail Size', 'trainify' ),
		'section'  => 'trainify_banner_slider',
		'type'     => 'select',
		'priority' => 110,
		'choices'  => trainify_framework_get_image_sizes(), 
	)
);

// Setting banner_slider_description_length.
$wp_customize->add_setting( 
	'banner_slider_description_length',
	array(
		'default'           => '150',
		'capability'        => 'edit_theme_options',
		'sanitize_callback' => 'absint',
	)
);
$wp_customize->add_control( 
	'banner_slider_description_length',
	array(
		'label'    => esc_html__( 'Description Length', 'trainify' ),
		'section'  => 'trainify_banner_slider',
		'type'     => 'number',
		'priority' => 120,
	)
);


