<?php

/**
 * Banner News Settings (Slider Section)
 *
 * @package Chic Lifestyle
 */
add_action( 'customize_register', 'chic_lifestyle_customize_register_slider_section' );
function chic_lifestyle_customize_register_slider_section(  $wp_customize  ) {
    // Add the Slider Section.
    $wp_customize->add_section( 'chic_lifestyle_slider_sections', array(
        'title'       => esc_html__( 'Slider Section', 'chic-lifestyle' ),
        'description' => esc_html__( 'Slider section', 'chic-lifestyle' ),
        'panel'       => 'chic_lifestyle_homepage_panel',
        'priority'    => 1,
    ) );
    // Slider Display (Checkbox)
    $wp_customize->add_setting( 'slider_display', array(
        'default'           => true,
        'sanitize_callback' => 'chic_lifestyle_sanitize_checkbox',
    ) );
    $wp_customize->add_control( new Chic_Lifestyle_Toggle_Control($wp_customize, 'slider_display', array(
        'label'    => esc_html__( 'Show Slider Section', 'chic-lifestyle' ),
        'section'  => 'chic_lifestyle_slider_sections',
        'settings' => 'slider_display',
        'type'     => 'toggle',
    )) );
    $wp_customize->selective_refresh->add_partial( 'slider_display', array(
        'selector' => '#chic_lifestyle_slider_sections',
    ) );
    // Slider Title (Text)
    $wp_customize->add_setting( 'slider_title', array(
        'default'           => '',
        'sanitize_callback' => 'sanitize_text_field',
    ) );
    $wp_customize->add_control( 'slider_title', array(
        'label'   => esc_html__( 'Slider Title', 'chic-lifestyle' ),
        'section' => 'chic_lifestyle_slider_sections',
        'type'    => 'text',
    ) );
    // Slider category
    $wp_customize->add_setting( 'slider_category', array(
        'sanitize_callback' => 'chic_lifestyle_sanitize_category',
        'capability'        => 'edit_theme_options',
        'default'           => '',
    ) );
    $wp_customize->add_control( new Chic_Lifestyle_Customize_Dropdown_Taxonomies_Control($wp_customize, 'slider_category', array(
        'label'    => esc_html__( 'Slider Category', 'chic-lifestyle' ),
        'section'  => 'chic_lifestyle_slider_sections',
        'settings' => 'slider_category',
        'type'     => 'dropdown-taxonomies',
        'taxonomy' => 'category',
    )) );
    // Slider Number of Posts (Text)
    $wp_customize->add_setting( 'slider_number_of_posts', array(
        'sanitize_callback' => 'sanitize_text_field',
        'default'           => '3',
    ) );
    $wp_customize->add_control( 'slider_number_of_posts', array(
        'label'       => esc_html__( 'Number of posts', 'chic-lifestyle' ),
        'description' => esc_attr__( 'put -1 for unlimited', 'chic-lifestyle' ),
        'section'     => 'chic_lifestyle_slider_sections',
        'settings'    => 'slider_number_of_posts',
        'type'        => 'text',
    ) );
    // Slider Details Show/Hide (Multicheck)
    $wp_customize->add_setting( 'slider_details_show_hide', array(
        'default'           => array(
            'date',
            'categories',
            'summary',
            'readmore'
        ),
        'sanitize_callback' => 'chic_lifestyle_sanitize_array',
    ) );
    $wp_customize->add_control( new Chic_Lifestyle_Multi_Check_Control($wp_customize, 'slider_details_show_hide', array(
        'label'   => esc_html__( 'Show / Hide details', 'chic-lifestyle' ),
        'section' => 'chic_lifestyle_slider_sections',
        'choices' => array(
            'date'       => esc_html__( 'Show post date', 'chic-lifestyle' ),
            'categories' => esc_html__( 'Show Categories', 'chic-lifestyle' ),
            'summary'    => esc_html__( 'Show Summary', 'chic-lifestyle' ),
            'readmore'   => esc_html__( 'Show Read More text', 'chic-lifestyle' ),
        ),
    )) );
    $wp_customize->add_setting( 'chic_lifestyle_slider_layouts_upgrade_to_pro', array(
        'sanitize_callback' => null,
    ) );
    $wp_customize->add_control( new Chic_Lifestyle_Control_Upgrade_To_Pro($wp_customize, 'chic_lifestyle_slider_layouts_upgrade_to_pro', array(
        'section'     => 'chic_lifestyle_slider_sections',
        'settings'    => 'chic_lifestyle_slider_layouts_upgrade_to_pro',
        'title'       => __( 'Choose how your slider will look like.', 'chic-lifestyle' ),
        'items'       => array(
            'one' => array(
                'title' => __( 'Choose between three beautiful slider layouts', 'chic-lifestyle' ),
            ),
        ),
        'button_url'  => esc_url( 'https://thebootstrapthemes.com/chic-lifestyle/#free-vs-pro' ),
        'button_text' => __( 'Upgrade Now', 'chic-lifestyle' ),
    )) );
}
