<?php
/**
* Slider options
*
* @package GridRead WordPress Theme
* @copyright Copyright (C) 2025 ThemesDNA
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or later
* @author ThemesDNA <themesdna@gmail.com>
*/

function gridread_slider_options($wp_customize) {

    $wp_customize->add_section( 'gridread_section_slider', array( 'title' => esc_html__( 'Slider Options', 'gridread' ), 'panel' => 'gridread_main_options_panel', 'priority' => 145 ) );

    $wp_customize->add_setting( 'gridread_options[enable_slider]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridread_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridread_enable_slider_control', array( 'label' => esc_html__( 'Enable Slider', 'gridread' ), 'section' => 'gridread_section_slider', 'settings' => 'gridread_options[enable_slider]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridread_options[show_slider_heading]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridread_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridread_show_slider_heading_control', array( 'label' => esc_html__( 'Show Slider Heading', 'gridread' ), 'section' => 'gridread_section_slider', 'settings' => 'gridread_options[show_slider_heading]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridread_options[slider_heading]', array( 'default' => esc_html__( 'Featured Posts', 'gridread' ), 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', ) );

    $wp_customize->add_control( 'gridread_slider_heading_control', array( 'label' => esc_html__( 'Slider Heading', 'gridread' ), 'section' => 'gridread_section_slider', 'settings' => 'gridread_options[slider_heading]', 'type' => 'text', ) );

    $wp_customize->add_setting( 'gridread_options[slider_display]', array( 'default' => 'front-page', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridread_sanitize_slider_display' ) );

    $wp_customize->add_control( 'gridread_slider_display_control', array( 'label' => esc_html__( 'Slider Display Location', 'gridread' ), 'description' => esc_html__('Select the slider display location.', 'gridread'), 'section' => 'gridread_section_slider', 'settings' => 'gridread_options[slider_display]', 'type' => 'select', 'choices' => array( 'front-page' => esc_html__('Home Page', 'gridread'), 'front-page-static' => esc_html__('Static Home Page', 'gridread'), 'blog-posts-index' => esc_html__( 'Blog Posts Index Page', 'gridread' ), 'everywhere' => esc_html__('Everywhere', 'gridread') ) ) );

    $wp_customize->add_setting( 'gridread_options[slider_length]', array( 'default' => 10, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridread_sanitize_positive_integer' ) );

    $wp_customize->add_control( 'gridread_slider_length_control', array( 'label' => esc_html__( 'Number of Posts on Slider', 'gridread' ), 'description' => esc_html__('Enter the number of posts you need to display in the slider area. Default is 10 posts.', 'gridread'), 'section' => 'gridread_section_slider', 'settings' => 'gridread_options[slider_length]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridread_options[slider_post_type]', array( 'default' => 'recentposts', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridread_sanitize_slider_post_type' ) );

    $wp_customize->add_control( 'gridread_slider_post_type_control', array( 'label' => esc_html__( 'Slider Posts Type', 'gridread' ), 'description' => esc_html__('Select a post type to display in slider.', 'gridread'), 'section' => 'gridread_section_slider', 'settings' => 'gridread_options[slider_post_type]', 'type' => 'select', 'choices' => array( 'recentposts' => esc_html__( 'Recent Posts', 'gridread' ), 'catposts' => esc_html__( 'Category Posts', 'gridread' ), 'tagposts' => esc_html__( 'Tag Posts', 'gridread' ) ) ) );

    $wp_customize->add_setting( 'gridread_options[slider_cat]', array( 'default' => 0, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'absint' ) );

    $wp_customize->add_control( new GridRead_Customize_Category_Control( $wp_customize, 'gridread_slider_cat_control', array( 'label' => esc_html__( 'Slider Posts Category', 'gridread' ), 'section' => 'gridread_section_slider', 'settings' => 'gridread_options[slider_cat]', 'description' => esc_html__( 'Select a category if "Slider Posts Type" option is Category Posts', 'gridread' ) ) ) );

    $wp_customize->add_setting( 'gridread_options[slider_tag]', array( 'default' => 0, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'absint' ) );

    $wp_customize->add_control( new GridRead_Customize_Category_Control( $wp_customize, 'gridread_slider_tag_control', array( 'label' => esc_html__( 'Slider Posts Tag', 'gridread' ), 'section' => 'gridread_section_slider', 'settings' => 'gridread_options[slider_tag]', 'description' => esc_html__( 'Select a tag if "Slider Posts Type" option is Tag Posts', 'gridread' ), 'dropdown_args' => array( 'taxonomy' => 'post_tag', ), ) ) );

    $wp_customize->add_setting( 'gridread_options[slider_post_orderby]', array( 'default' => 'date', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridread_sanitize_slider_post_orderby' ) );

    $wp_customize->add_control( 'gridread_slider_post_orderby_control', array( 'label' => esc_html__( 'Slider Posts Orderby', 'gridread' ), 'description' => esc_html__('Select a posts orderby value for slider.', 'gridread'), 'section' => 'gridread_section_slider', 'settings' => 'gridread_options[slider_post_orderby]', 'type' => 'select', 'choices' => array( 'date' => esc_html__( 'Published Date', 'gridread' ), 'modified' => esc_html__( 'Modified Date', 'gridread' ), 'comment_count' => esc_html__( 'Number of Comments', 'gridread' ) ) ) );

    $wp_customize->add_setting( 'gridread_options[slider_post_order]', array( 'default' => 'DESC', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridread_sanitize_slider_post_order' ) );

    $wp_customize->add_control( 'gridread_slider_post_order_control', array( 'label' => esc_html__( 'Slider Posts Order', 'gridread' ), 'description' => esc_html__('Select a posts order value for slider.', 'gridread'), 'section' => 'gridread_section_slider', 'settings' => 'gridread_options[slider_post_order]', 'type' => 'select', 'choices' => array( 'ASC' => esc_html__( 'Ascending order', 'gridread' ), 'DESC' => esc_html__( 'Descending order', 'gridread' ) ) ) );

    $wp_customize->add_setting( 'gridread_options[remove_thumbnail_slider_link]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridread_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridread_remove_thumbnail_slider_link_control', array( 'label' => esc_html__( 'Remove Links from Slider Featured Images', 'gridread' ), 'section' => 'gridread_section_slider', 'settings' => 'gridread_options[remove_thumbnail_slider_link]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridread_options[show_slide_cats]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridread_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridread_show_slide_cats_control', array( 'label' => esc_html__( 'Show Post Categories on Slider', 'gridread' ), 'section' => 'gridread_section_slider', 'settings' => 'gridread_options[show_slide_cats]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridread_options[hide_thumbnail_slider_data]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridread_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridread_hide_thumbnail_slider_data_control', array( 'label' => esc_html__( 'Hide Post Thumbnail Overlay Data (Post Title, Post Categories, Post Meta) from Slider', 'gridread' ), 'section' => 'gridread_section_slider', 'settings' => 'gridread_options[hide_thumbnail_slider_data]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridread_options[hide_post_title_slider]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridread_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridread_hide_post_title_slider_control', array( 'label' => esc_html__( 'Hide Post Titles from Slider', 'gridread' ), 'section' => 'gridread_section_slider', 'settings' => 'gridread_options[hide_post_title_slider]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridread_options[remove_post_title_slider_link]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridread_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridread_remove_post_title_slider_link_control', array( 'label' => esc_html__( 'Remove Links from Slider Post Titles', 'gridread' ), 'section' => 'gridread_section_slider', 'settings' => 'gridread_options[remove_post_title_slider_link]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridread_options[show_slide_author]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridread_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridread_show_slide_author_control', array( 'label' => esc_html__( 'Show Post Authors on Slider', 'gridread' ), 'section' => 'gridread_section_slider', 'settings' => 'gridread_options[show_slide_author]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridread_options[slider_dateformat]', array( 'default' => 'F j, Y', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', ) );

    $wp_customize->add_control( 'gridread_slider_dateformat_control', array( 'label' => esc_html__( 'Slider Date Format', 'gridread' ), 'description' => esc_html__('Default value: F j, Y', 'gridread'), 'section' => 'gridread_section_slider', 'settings' => 'gridread_options[slider_dateformat]', 'type' => 'text', ) );

    $wp_customize->add_setting( 'gridread_options[hide_slide_date]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridread_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridread_hide_slide_date_control', array( 'label' => esc_html__( 'Hide Posted Dates from Slider', 'gridread' ), 'section' => 'gridread_section_slider', 'settings' => 'gridread_options[hide_slide_date]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridread_options[show_slide_comments]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridread_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridread_show_slide_comments_control', array( 'label' => esc_html__( 'Show Post Comments on Slider', 'gridread' ), 'section' => 'gridread_section_slider', 'settings' => 'gridread_options[show_slide_comments]', 'type' => 'checkbox', ) );


    $wp_customize->add_setting( 'gridread_options[slider_autoplay]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridread_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridread_slider_autoplay_control', array( 'label' => esc_html__( 'Enable Autoplay for Slider', 'gridread' ), 'section' => 'gridread_section_slider', 'settings' => 'gridread_options[slider_autoplay]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridread_options[slider_autoplayhoverpause]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridread_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridread_slider_autoplayhoverpause_control', array( 'label' => esc_html__( 'Enable "Pause on Mouse Hover" Feature for Slider', 'gridread' ), 'description' => esc_html__('When you enable this feature, slides will pause on mouse hover. This option has no effect until you check the option "Enable Autoplay for Slider".', 'gridread'), 'section' => 'gridread_section_slider', 'settings' => 'gridread_options[slider_autoplayhoverpause]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridread_options[slider_autoplaytimeout]', array( 'default' => 1000, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridread_sanitize_positive_integer' ) );

    $wp_customize->add_control( 'gridread_slider_autoplaytimeout_control', array( 'label' => esc_html__( 'Slider "Autoplay Interval Timeout"', 'gridread' ), 'description' => esc_html__('Enter the slider autoplay interval timeout in milliseconds. Default is 1000. This option has no effect until you check the option "Enable Autoplay for Slider".', 'gridread'), 'section' => 'gridread_section_slider', 'settings' => 'gridread_options[slider_autoplaytimeout]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridread_options[slider_autoplayspeed]', array( 'default' => 200, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridread_sanitize_positive_integer' ) );

    $wp_customize->add_control( 'gridread_slider_autoplayspeed_control', array( 'label' => esc_html__( 'Slider "Autoplay Speed"', 'gridread' ), 'description' => esc_html__('Enter the slider autoplay speed in milliseconds. Default is 200. This option has no effect until you check the option "Enable Autoplay for Slider".', 'gridread'), 'section' => 'gridread_section_slider', 'settings' => 'gridread_options[slider_autoplayspeed]', 'type' => 'text' ) );

    $wp_customize->add_setting( 'gridread_options[slider_loop]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridread_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridread_slider_loop_control', array( 'label' => esc_html__( 'Enable "Loop" Feature for Slider', 'gridread' ), 'description' => esc_html__('When you enable this feature, it will duplicate last and first slide items to get loop illusion.', 'gridread'), 'section' => 'gridread_section_slider', 'settings' => 'gridread_options[slider_loop]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridread_options[show_dots_pagination]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridread_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridread_show_dots_pagination_control', array( 'label' => esc_html__( 'Show Dots Navigation(Pagination) on Slider', 'gridread' ), 'section' => 'gridread_section_slider', 'settings' => 'gridread_options[show_dots_pagination]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridread_options[hide_next_prev_navigation]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridread_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridread_hide_next_prev_navigation_control', array( 'label' => esc_html__( 'Hide next/prev Buttons(Navigation) from Slider', 'gridread' ), 'section' => 'gridread_section_slider', 'settings' => 'gridread_options[hide_next_prev_navigation]', 'type' => 'checkbox', ) );

    $wp_customize->add_setting( 'gridread_options[disable_autoheight]', array( 'default' => false, 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'gridread_sanitize_checkbox', ) );

    $wp_customize->add_control( 'gridread_disable_autoheight_control', array( 'label' => esc_html__( 'Disable "Auto Height" Feature from Slider', 'gridread' ), 'section' => 'gridread_section_slider', 'settings' => 'gridread_options[disable_autoheight]', 'type' => 'checkbox', ) );

}