<?php
// Add Home Page Banner Section.
$default = united_blog_get_default_theme_options();

$wp_customize->add_section(
	'home_banner_options',
	array(
		'title' => __( 'Slider Banner Sections', 'united-blog' ),
		'panel' => 'front_page_panel',
		'priority'   => 5,
		
	)
);

// Enable Banner Section.
$wp_customize->add_setting('enable_banner',
    array(
        'default'           => $default['enable_banner'],
        'capability'        => 'edit_theme_options',
        'sanitize_callback' => 'united_blog_sanitize_checkbox',
    )
);
$wp_customize->add_control('enable_banner',
    array(
		'label'    => __( 'Enable Slider Banner', 'united-blog' ),
        'section'  => 'home_banner_options',
        'type'     => 'checkbox',
    )
);

// Banner section background.
$wp_customize->add_setting(
	'banner_section_bg_color',
	array(
		'default'           => $default['banner_section_bg_color'],
		'sanitize_callback' => 'sanitize_hex_color',
	)
);
$wp_customize->add_control(
	new WP_Customize_Color_Control(
		$wp_customize,
		'banner_section_bg_color',
		array(
			'label'           => __( 'Banner Section Background', 'united-blog' ),
			'section'         => 'home_banner_options',
			'type'            => 'color',
		)
	)
);

// Banner Layout.
$wp_customize->add_setting(
	'banner_layout',
	array(
		'default'           => $default['banner_layout'],
		'sanitize_callback' => 'united_blog_sanitize_select',
	)
);
$wp_customize->add_control(
	'banner_layout',
	array(
		'label'           => __( 'Banner Layout', 'united-blog' ),
		'description'     => __( 'If you want to show pinned posts on the side, use "Boxed" layout in here.', 'united-blog' ),
		'section'         => 'home_banner_options',
		'type'            => 'select',
		'choices'         => array(
			'full-width' => __( 'FullWidth', 'united-blog' ),
			'boxed'      => __( 'Boxed', 'united-blog' ),
		),
	)
);

// Banner Display as slider/carousel.
$wp_customize->add_setting(
	'banner_display_as',
	array(
		'default'           => $default['banner_display_as'],
		'sanitize_callback' => 'united_blog_sanitize_select',
	)
);
$wp_customize->add_control(
	'banner_display_as',
	array(
		'label'           => __( 'Banner Display As', 'united-blog' ),
		'section'         => 'home_banner_options',
		'type'            => 'select',
		'choices'         => array(
			'slider'   => __( 'Slider', 'united-blog' ),
			'carousel' => __( 'Carousel', 'united-blog' ),
		),
	)
);

$wp_customize->add_setting(
	'select_banner_style',
	array(
		'default'           => $default['select_banner_style'],
		'sanitize_callback' => 'united_blog_sanitize_select',
	)
);
$wp_customize->add_control(
	'select_banner_style',
	array(
		'label'           => __( 'Select Banner Style', 'united-blog' ),
		'section'         => 'home_banner_options',
		'type'            => 'select',
		'choices'         => array(
			'banner-style-1' => __( 'Banner Style - 1', 'united-blog' ),
			'banner-style-2'      => __( 'Banner Style - 2', 'united-blog' ),
		),
	)
);

// Banner Carousel gap.
$wp_customize->add_setting(
	'banner_carousel_item_gap',
	array(
		'default'           => $default['banner_carousel_item_gap'],
		'sanitize_callback' => 'united_blog_sanitize_select',
	)
);
$wp_customize->add_control(
	'banner_carousel_item_gap',
	array(
		'label'           => __( 'Carousel Item Gap', 'united-blog' ),
		'section'         => 'home_banner_options',
		'type'            => 'number',
		'input_attrs'     => array(
			'min'   => 0,
			'max'   => 100,
			'step'  => 1,
			'style' => 'width: 150px;',
		),
		'active_callback' => 'united_blog_banner_display_as',
	)
);

// Banner Content from ids or category.
$wp_customize->add_setting(
	'select_slider_from',
	array(
		'default'           => $default['select_slider_from'],
		'sanitize_callback' => 'united_blog_sanitize_select',
	)
);
$wp_customize->add_control(
	'select_slider_from',
	array(
		'label'           => __( 'Get Banner Content From', 'united-blog' ),
		'section'         => 'home_banner_options',
		'type'            => 'select',
		'choices'         => array(
			'from-category' => __( 'Category', 'united-blog' ),
			'from-page' => __( 'Post ID\'s', 'united-blog' ),
		),
	)
);

// Banner Post Category.
$wp_customize->add_setting(
	'banner_cat',
	array(
		'default'           => $default['banner_cat'],
		'sanitize_callback' => 'absint',
	)
);
$wp_customize->add_control(
	new united_blog_Dropdown_Taxonomies_Control(
		$wp_customize,
		'banner_cat',
		array(
			'label'           => __( 'Choose Category', 'united-blog' ),
			'description'     => __( 'Leave Empty if you don\'t want the posts to be category specific', 'united-blog' ),
			'section'         => 'home_banner_options',
			'active_callback' => 'united_blog_is_select_cat_slider',
		)
	)
);

// Banner Post IDs.
$wp_customize->add_setting(
	'banner_post_ids',
	array(
		'default'           => $default['banner_post_ids'],
		'sanitize_callback' => 'sanitize_text_field',
	)
);
$wp_customize->add_control(
	'banner_post_ids',
	array(
		'label'           => __( 'Post ID\'s', 'united-blog' ),
		'description'     => __( 'Comma ( , ) separated posts ids. Ex: 1, 2, 3', 'united-blog' ),
		'section'         => 'home_banner_options',
		'type'            => 'text',
		'active_callback' => 'united_blog_is_select_page_slider',

	)
);

// No of posts.
$wp_customize->add_setting(
	'no_of_banner_posts',
	array(
		'default'           => $default['no_of_banner_posts'],
		'sanitize_callback' => 'absint',
	)
);
$wp_customize->add_control(
	'no_of_banner_posts',
	array(
		'label'           => __( 'Number of Posts', 'united-blog' ),
		'section'         => 'home_banner_options',
		'type'            => 'number',
	)
);

$wp_customize->add_setting(
    'banner_section_title_limit',
    array(
        'default'           => $default['banner_section_title_limit'],
        'sanitize_callback' => 'united_blog_sanitize_select',
    )
);
$wp_customize->add_control(
    'banner_section_title_limit',
    array(
        'label'           => __( 'Title Limit', 'united-blog' ),
        'section'         => 'home_banner_options',
        'type'            => 'select',
        'choices'         => united_blog_get_title_line_clamp(),
    )
);

// Posts Orderby.
$wp_customize->add_setting(
	'banner_posts_orderby',
	array(
		'default'           => $default['banner_posts_orderby'],
		'sanitize_callback' => 'united_blog_sanitize_select',
	)
);
$wp_customize->add_control(
	'banner_posts_orderby',
	array(
		'label'           => __( 'Orderby', 'united-blog' ),
		'section'         => 'home_banner_options',
		'type'            => 'select',
		'choices'         => array(
			'date'  => __( 'Date', 'united-blog' ),
			'id'    => __( 'ID', 'united-blog' ),
			'title' => __( 'Title', 'united-blog' ),
			'rand'  => __( 'Random', 'united-blog' ),
		),
	)
);

// Posts Order.
$wp_customize->add_setting(
	'banner_posts_order',
	array(
		'default'           => $default['banner_posts_order'],
		'sanitize_callback' => 'united_blog_sanitize_select',
	)
);
$wp_customize->add_control(
	'banner_posts_order',
	array(
		'label'           => __( 'Order', 'united-blog' ),
		'section'         => 'home_banner_options',
		'type'            => 'select',
		'choices'         => array(
			'asc'  => __( 'ASC', 'united-blog' ),
			'desc' => __( 'DESC', 'united-blog' ),
		),
	)
);

// Enable Banner Autoplay.
$wp_customize->add_setting('enable_banner_autoplay',
    array(
        'default'           => $default['enable_banner_autoplay'],
        'capability'        => 'edit_theme_options',
        'sanitize_callback' => 'united_blog_sanitize_checkbox',
    )
);
$wp_customize->add_control('enable_banner_autoplay',
    array(
		'label'           => __( 'Enable Banner Autoplay', 'united-blog' ),
        'section'  => 'home_banner_options',
        'type'     => 'checkbox',
    )
);

// Enable Banner Arrows.
$wp_customize->add_setting('enable_banner_arrows',
    array(
        'default'           => $default['enable_banner_arrows'],
        'capability'        => 'edit_theme_options',
        'sanitize_callback' => 'united_blog_sanitize_checkbox',
    )
);
$wp_customize->add_control('enable_banner_arrows',
    array(
		'label'           => __( 'Enable Banner Arrows', 'united-blog' ),
        'section'  => 'home_banner_options',
        'type'     => 'checkbox',
    )
);

// Enable Banner Dots.
$wp_customize->add_setting('enable_banner_dots',
    array(
        'default'           => $default['enable_banner_dots'],
        'capability'        => 'edit_theme_options',
        'sanitize_callback' => 'united_blog_sanitize_checkbox',
    )
);
$wp_customize->add_control('enable_banner_dots',
    array(
		'label'           => __( 'Enable Banner Dots', 'united-blog' ),
        'section'  => 'home_banner_options',
        'type'     => 'checkbox',
    )
);


// Enable Banner Overlay.
$wp_customize->add_setting('enable_banner_overlay',
    array(
        'default'           => $default['enable_banner_overlay'],
        'capability'        => 'edit_theme_options',
        'sanitize_callback' => 'united_blog_sanitize_checkbox',
    )
);
$wp_customize->add_control('enable_banner_overlay',
    array(
		'label'           => __( 'Show Banner Overlay', 'united-blog' ),
        'section'  => 'home_banner_options',
        'type'     => 'checkbox',
    )
);

// Banner overlay color.
$wp_customize->add_setting(
	'banner_overlay_color',
	array(
		'default'           => $default['banner_overlay_color'],
		'sanitize_callback' => 'sanitize_hex_color',
	)
);
$wp_customize->add_control(
	new WP_Customize_Color_Control(
		$wp_customize,
		'banner_overlay_color',
		array(
			'label'           => __( 'Overlay Color', 'united-blog' ),
			'section'         => 'home_banner_options',
			'type'            => 'color',
		)
	)
);

// Banner Overlay Opacity.
$wp_customize->add_setting(
	'banner_overlay_opacity',
	array(
		'default'           => $default['banner_overlay_opacity'],
		'sanitize_callback' => 'united_blog_sanitize_float',
	)
);
$wp_customize->add_control(
	'banner_overlay_opacity',
	array(
		'label'           => __( 'Overlay Opacity', 'united-blog' ),
		'section'         => 'home_banner_options',
		'type'            => 'number',
		'input_attrs'     => array(
			'min'   => 0,
			'max'   => 1,
			'step'  => 0.1,
			'style' => 'width: 150px;',
		),
	)
);


// Show Banner desc.
$wp_customize->add_setting('enable_banner_desc',
    array(
        'default'           => $default['enable_banner_desc'],
        'capability'        => 'edit_theme_options',
        'sanitize_callback' => 'united_blog_sanitize_checkbox',
    )
);
$wp_customize->add_control('enable_banner_desc',
    array(
		'label'           => __( 'Show Banner Description', 'united-blog' ),
        'section'  => 'home_banner_options',
        'type'     => 'checkbox',
    )
);

// Banner desc length.
$wp_customize->add_setting(
	'banner_desc_length',
	array(
		'default'           => $default['banner_desc_length'],
		'sanitize_callback' => 'absint',
	)
);
$wp_customize->add_control(
	'banner_desc_length',
	array(
		'label'           => __( 'Banner Description Length', 'united-blog' ),
		'section'         => 'home_banner_options',
		'type'            => 'number',
	)
);

// Show Banner read more.
$wp_customize->add_setting('enable_banner_read_more_btn',
    array(
        'default'           => $default['enable_banner_read_more_btn'],
        'capability'        => 'edit_theme_options',
        'sanitize_callback' => 'united_blog_sanitize_checkbox',
    )
);
$wp_customize->add_control('enable_banner_read_more_btn',
    array(
			'label'           => __( 'Show Banner Read More', 'united-blog' ),
        'section'  => 'home_banner_options',
        'type'     => 'checkbox',
    )
);
// Read More Text.
$wp_customize->add_setting(
	'banner_read_more_btn_text',
	array(
		'default'           => $default['banner_read_more_btn_text'],
		'sanitize_callback' => 'sanitize_text_field',
	)
);
$wp_customize->add_control(
	'banner_read_more_btn_text',
	array(
		'label'           => __( 'Banner Read More Text', 'united-blog' ),
		'description'     => __( 'Leave empty if you want to use the default text "Read more".', 'united-blog' ),
		'section'         => 'home_banner_options',
		'type'            => 'text',
	)
);

$wp_customize->add_setting(
    'banner_read_more_icon',
    array(
        'default'           => $default['banner_read_more_icon'],
        'sanitize_callback' => 'united_blog_sanitize_radio', 
    )
);

$wp_customize->add_control(
    new united_blog_Radio_Icon_Control(
        $wp_customize,
        'banner_read_more_icon',
        array(
            'label'   => __( 'Read More Icon', 'united-blog' ),
            'section' => 'home_banner_options', 
            'choices' => united_blog_customizer_read_more_icons(),
        )
    )
);


// Show Featured Category.
$wp_customize->add_setting('show_banner_category',
    array(
        'default'           => $default['show_banner_category'],
        'capability'        => 'edit_theme_options',
        'sanitize_callback' => 'united_blog_sanitize_checkbox',
    )
);
$wp_customize->add_control('show_banner_category',
    array(
        'label'    => esc_html__('Show Categories', 'united-blog'),
        'section'  => 'home_banner_options',
        'type'     => 'checkbox',
    )
);

// Categories Display Style.
$wp_customize->add_setting(
    'banner_category_color_display',
    array(
        'default'           => $default['banner_category_color_display'],
        'sanitize_callback' => 'united_blog_sanitize_select',
    )
);
$wp_customize->add_control(
    'banner_category_color_display',
    array(
        'label'           => __( 'Categories Display Style', 'united-blog' ),
        'section'         => 'home_banner_options',
        'type'            => 'select',
        'choices'         => united_blog_get_category_display_styles(),
    )
);

// No of Featured Categories.
$wp_customize->add_setting(
    'banner_category_limit',
    array(
        'default'           => $default['banner_category_limit'],
        'sanitize_callback' => 'absint',
    )
);
$wp_customize->add_control(
    'banner_category_limit',
    array(
        'label'           => __( 'Number of Categories To Display', 'united-blog' ),
        'section'         => 'home_banner_options',
        'type'            => 'number',
    )
);

/* Bannner Posts Meta */
$wp_customize->add_setting(
    'banner_post_meta',
    array(
        'default'           => $default['banner_post_meta'],
        'sanitize_callback' => 'united_blog_sanitize_checkbox_multiple',
    )
);
$wp_customize->add_control(
    new United_Blog_Checkbox_Multiple(
        $wp_customize,
        'banner_post_meta',
        array(
            'label'           => __( 'Bannner Post Meta', 'united-blog' ),
            'section'         => 'home_banner_options',
            'choices'         => united_blog_get_post_meta(),
        )
    )
);

// Show Post Meta Icon.
$wp_customize->add_setting('show_banner_post_meta_icon',
    array(
        'default'           => $default['show_banner_post_meta_icon'],
        'capability'        => 'edit_theme_options',
        'sanitize_callback' => 'united_blog_sanitize_checkbox',
    )
);
$wp_customize->add_control('show_banner_post_meta_icon',
    array(
        'label'    => esc_html__('Show Post Meta Icon', 'united-blog'),
            'description'     => __( 'Some Icons may show up regardless to provide better info.', 'united-blog' ),
        'section'  => 'home_banner_options',
        'type'     => 'checkbox',
    )
);

// Banner Date Format
$wp_customize->add_setting(
    'banner_posts_date_format',
    array(
        'default'           => $default['banner_posts_date_format'],
        'sanitize_callback' => 'united_blog_sanitize_select',
    )
);
$wp_customize->add_control(
    'banner_posts_date_format',
    array(
        'label'           => __( 'Select Date Format', 'united-blog' ),
        'description'     => __( 'Make sure to enable Date post meta from above for this to work.', 'united-blog' ),
        'section'         => 'home_banner_options',
        'type'            => 'select',
        'choices'         => array(
            'format_1' => __( 'Times Ago', 'united-blog' ),
            'format_2' => __( 'Default Format', 'united-blog' ),
        ),
    )
);


// Setting - slider_text_color.
$wp_customize->add_setting(
	'slider_text_color',
	array(
		'default'           => $default['slider_text_color'],
		'sanitize_callback' => 'sanitize_hex_color',
	)
);
$wp_customize->add_control(
	new WP_Customize_Color_Control(
		$wp_customize,
		'slider_text_color',
		array(
			'label'           => __( 'Slider Text Color', 'united-blog' ),
			'section'         => 'home_banner_options',
			'type'            => 'color',
		)
	)
);

// Setting - slider_text_link_color.
$wp_customize->add_setting(
	'slider_text_link_color',
	array(
		'default'           => $default['slider_text_link_color'],
		'sanitize_callback' => 'sanitize_hex_color',
	)
);
$wp_customize->add_control(
	new WP_Customize_Color_Control(
		$wp_customize,
		'slider_text_link_color',
		array(
			'label'           => __( 'Slider Link Color', 'united-blog' ),
			'section'         => 'home_banner_options',
			'type'            => 'color',
		)
	)
);
