<?php 
/**
 * Home Section
 *
 * @package eco-solar-energy
 */
    $wp_customize->add_section( 'eco_solar_energy_home_section' , array(
        'title'      => esc_html__( 'Home Section', 'eco-solar-energy' ),
        'capability' => 'edit_theme_options',
        'panel' => 'eco_solar_energy_section_panel' 
    ) );

// ///////// Toggle switch
$wp_customize->add_setting( 'eco_solar_energy_home_display' , array(
        'default'   => true,
        'sanitize_callback' => 'eco_solar_energy_sanitize_switch',
) );

$wp_customize->add_control( new eco_solar_energy_Toggle_Switch_Custom_Control( $wp_customize, 'eco_solar_energy_home_display_control', array(
        'label'      => esc_html__( 'Display Home section', 'eco-solar-energy' ),
        'section'    => 'eco_solar_energy_home_section',
        'settings'   => 'eco_solar_energy_home_display',
) ) );

// /// effects
$wp_customize->add_setting('eco_solar_energy_featured_slider_onload_effects',array(
    'default' => 'Bounce In Up',
    'sanitize_callback' => 'eco_solar_energy_sanitize_choices',
));
$wp_customize->add_control('eco_solar_energy_featured_slider_onload_effects',array(
    'type' => 'select',
    'label' => __('Box Onload Transition Effects','eco-solar-energy'),
    'choices' => array (
        'wow bounceInLeft' => __('Bounce In Left','eco-solar-energy'),
        'wow bounceInRight' => __('Bounce In Right','eco-solar-energy'),
        'wow bounceInUp' => __('Bounce In Up','eco-solar-energy'),
        'wow bounceInDown' => __('Bounce In Down','eco-solar-energy'),
        'wow zoomIn' => __('Zoom In','eco-solar-energy'),
        'wow zoomOut' => __('Zoom Out','eco-solar-energy'),
        'wow fadeInDown' => __('Fade In Down','eco-solar-energy'),            
        'wow fadeInUp' => __('Fade In Up','eco-solar-energy'),
        'wow fadeInLeft' => __('Fade In Left','eco-solar-energy'),
        'wow fadeInRight' => __('Fade In Right','eco-solar-energy'),
        'flip-up' => __('Flip Up','eco-solar-energy')
    ),
    'section' => 'eco_solar_energy_home_section',
)); 

// Items
// Number of Slider Items
$wp_customize->add_setting('number_of_featured_slider_items', array(
        'default'           => 3, // Set default number of items
        'sanitize_callback' => 'absint', // Ensure it's a valid integer
    ));
    
    $wp_customize->add_control('number_of_featured_slider_items', array(
        'label'    => __('Number Of Slider To Show', 'eco-solar-energy'),
        'section'  => 'eco_solar_energy_home_section', // The section where this control will appear
        'type'     => 'number',
        'input_attrs' => array(
            'min' => 1, // Minimum value
            'max' => 10, // Maximum value
            'step' => 1, // Increment step
        ),
    ));
    
    $eco_solar_energy_slider_list = array();
    $args = array('post_type' => 'post'); // Fetch posts, not pages
    $eco_solar_energy_posts = get_posts( $args ); 
    foreach($eco_solar_energy_posts as $eco_solar_energy_post) {
        $eco_solar_energy_slider_list[$eco_solar_energy_post->ID] = $eco_solar_energy_post->post_title; // Use post ID as key and title as value
    }
    
    for ( $count = 1; $count <= 4; $count++ ) {
        $wp_customize->add_setting( 'select_post_slider' . $count, array(
            'default'           => '',
            'sanitize_callback' => 'sanitize_post_dropdown'
        ));
        $wp_customize->add_control( 'select_post_slider' . $count, array(
            'label'   => __( 'Select A Post Page', 'eco-solar-energy' ),
            'section' => 'eco_solar_energy_home_section',
            'type'    => 'select', // Use 'select' for custom post list
            'choices' => $eco_solar_energy_slider_list // Populate choices with posts
        ));
    }

    $wp_customize->add_setting('eco_solar_energy_headinghomr', 
    array(
    'default'           => __('The Power of Nature at Your Fingertips', 'eco-solar-energy'),
    'type'              => 'theme_mod',
    'capability'        => 'edit_theme_options',    
    'sanitize_callback' => 'sanitize_text_field'
    )
);

$wp_customize->add_control('eco_solar_energy_headinghomr', 
    array(
    'label'       => __('Heading Text', 'eco-solar-energy'),
    'section'     => 'eco_solar_energy_home_section',   
    'settings'    => 'eco_solar_energy_headinghomr',           
    'type'        => 'text'
    )
);
    $wp_customize->add_setting('eco_solar_energy_button1_text', 
    array(
    'default'           => __('Explore More', 'eco-solar-energy'),
    'type'              => 'theme_mod',
    'capability'        => 'edit_theme_options',    
    'sanitize_callback' => 'sanitize_text_field'
    )
);

$wp_customize->add_control('eco_solar_energy_button1_text', 
    array(
    'label'       => __('Explore More Button Text', 'eco-solar-energy'),
    'section'     => 'eco_solar_energy_home_section',   
    'settings'    => 'eco_solar_energy_button1_text',           
    'type'        => 'text'
    )
);
// //////////   Image 
$wp_customize->add_setting('eco_solar_energy_slider_image2', array(
    'sanitize_callback' => 'eco_solar_energy_sanitise_custom_url',       
    'capability' => 'edit_theme_options',        
    'type' => 'theme_mod',
));

$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'eco_solar_energy_slider_image2', array(       
    'label'      => esc_html__('Bottom Image', 'eco-solar-energy'),       
    'section'    => 'eco_solar_energy_home_section',       
    'settings'   => 'eco_solar_energy_slider_image2',
)));
$wp_customize->add_setting('eco_solar_energy_slider_buttontext1_color', array(
        'default'   => '#fff',
        'transport' => 'refresh',
        'sanitize_callback' => 'sanitize_hex_color',
        ));
      
        $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'eco_solar_energy_slider_buttontext1_color', array(
        'section' => 'eco_solar_energy_home_section',
        'description' => __('View Project Button Color', 'eco-solar-energy'),
        )));

$wp_customize->add_setting('eco_solar_energy_slider_buttonbackground1_color', array(
        'default'   => '#7ECF29',
        'transport' => 'refresh',
        'sanitize_callback' => 'sanitize_hex_color',
        ));
              
        $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'eco_solar_energy_slider_buttonbackground1_color', array(
        'section' => 'eco_solar_energy_home_section',
        'description' => __('View Project Button Background Color', 'eco-solar-energy'),
        )));