<?php 
/**
 * Home Section
 *
 * @package express-movers
 */

$express_movers_default = express_movers_get_default_theme_options();

/** Slider Info section */
$wp_customize->add_section(
    'expressmovers_featured_slider_info_section',
    array(
        'title'    => __( 'Slider Info', 'express-movers' ),      
        'priority' => 1,
        'panel'      => 'express_movers_section_panel',       	
    )
);

// Enable Section
$wp_customize->add_setting(
    'expressmovers_slider_enable_section',
    array(
        'default' 			=> true,
       'sanitize_callback' => 'express_movers_sanitize_switch',

    )
);
$wp_customize->add_control(
    new Express_Movers_Toggle_Checkbox_Custom_control(
        $wp_customize,
        'expressmovers_slider_enable_section',
        array(
            'settings'      => 'expressmovers_slider_enable_section',
            'section'       => 'expressmovers_featured_slider_info_section',
            'label'         => __( 'Enable Section', 'express-movers' ),
            'on_off_label'  => array(
                'on' => __( 'Yes', 'express-movers' ),
                'off' => __( 'No', 'express-movers' )
            ),
        )
    )
);

// /// effects
$wp_customize->add_setting('express_movers_featured_slider_onload_effects',array(
    'default' => 'Bounce In Up',
    'sanitize_callback' => 'express_movers_sanitize_choices',
));
$wp_customize->add_control('express_movers_featured_slider_onload_effects',array(
    'type' => 'select',
    'label' => __('Box Onload Transition Effects','express-movers'),
    'choices' => array (
        'wow bounceInLeft' => __('Bounce In Left','express-movers'),
        'wow bounceInRight' => __('Bounce In Right','express-movers'),
        'wow bounceInUp' => __('Bounce In Up','express-movers'),
        'wow bounceInDown' => __('Bounce In Down','express-movers'),
        'wow zoomIn' => __('Zoom In','express-movers'),
        'wow zoomOut' => __('Zoom Out','express-movers'),
        'wow fadeInDown' => __('Fade In Down','express-movers'),            
        'wow fadeInUp' => __('Fade In Up','express-movers'),
        'wow fadeInLeft' => __('Fade In Left','express-movers'),
        'wow fadeInRight' => __('Fade In Right','express-movers'),
        'flip-up' => __('Flip Up','express-movers')
    ),
    'section' => 'expressmovers_featured_slider_info_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', 'express-movers'),
    'section'  => 'expressmovers_featured_slider_info_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
    ),
));

$express_movers_slider_list = array();
$express_movers_args = array('post_type' => 'post'); // Fetch posts, not pages
$express_movers_posts = get_posts( $express_movers_args ); 
foreach($express_movers_posts as $express_movers_post) {
    $express_movers_slider_list[$express_movers_post->ID] = $express_movers_post->post_title; // Use post ID as key and title as value
}

for ( $express_movers_count = 1; $express_movers_count <= 3; $express_movers_count++ ) {
    $wp_customize->add_setting( 'select_post_slider' . $express_movers_count, array(
        'default'           => '',
        'sanitize_callback' => 'express_movers_sanitize_post_dropdown'
    ));
    $wp_customize->add_control( 'select_post_slider' . $express_movers_count, array(
        'label'   => __( 'Select A Post Page', 'express-movers' ),
        'section' => 'expressmovers_featured_slider_info_section',
        'type'    => 'select', // Use 'select' for custom post list
        'choices' => $express_movers_slider_list // Populate choices with posts
    ));
}


// Slider Badge Text
$wp_customize->add_setting('featured_slider_badge_text', array(
    'default' => __('#1 Logistics Provider 2026', 'express-movers'),
    'type' => 'theme_mod',
    'capability' => 'edit_theme_options',
    'sanitize_callback' => 'sanitize_text_field',
));
$wp_customize->add_control('featured_slider_badge_text', array(
    'label' => __('Badge Text', 'express-movers'),
    'section' => 'expressmovers_featured_slider_info_section',
    'settings' => 'featured_slider_badge_text',
    'type' => 'text',
));

// Slider Description (optional override)
$wp_customize->add_setting('featured_slider_description', array(
    'default' => '',
    'type' => 'theme_mod',
    'capability' => 'edit_theme_options',
    'sanitize_callback' => 'sanitize_text_field',
));
$wp_customize->add_control('featured_slider_description', array(
    'label' => __('Description Override (leave blank to use excerpt)', 'express-movers'),
    'section' => 'expressmovers_featured_slider_info_section',
    'settings' => 'featured_slider_description',
    'type' => 'textarea',
));

// Slider Stats
$wp_customize->add_setting('featured_slider_stat1_value', array(
    'default' => __('50K+', 'express-movers'),
    'type' => 'theme_mod',
    'capability' => 'edit_theme_options',
    'sanitize_callback' => 'sanitize_text_field',
));
$wp_customize->add_control('featured_slider_stat1_value', array(
    'label' => __('Stat 1 Value', 'express-movers'),
    'section' => 'expressmovers_featured_slider_info_section',
    'settings' => 'featured_slider_stat1_value',
    'type' => 'text',
));
$wp_customize->add_setting('featured_slider_stat1_label', array(
    'default' => __('Deliveries', 'express-movers'),
    'type' => 'theme_mod',
    'capability' => 'edit_theme_options',
    'sanitize_callback' => 'sanitize_text_field',
));
$wp_customize->add_control('featured_slider_stat1_label', array(
    'label' => __('Stat 1 Label', 'express-movers'),
    'section' => 'expressmovers_featured_slider_info_section',
    'settings' => 'featured_slider_stat1_label',
    'type' => 'text',
));

$wp_customize->add_setting('featured_slider_stat2_value', array(
    'default' => __('98%', 'express-movers'),
    'type' => 'theme_mod',
    'capability' => 'edit_theme_options',
    'sanitize_callback' => 'sanitize_text_field',
));
$wp_customize->add_control('featured_slider_stat2_value', array(
    'label' => __('Stat 2 Value', 'express-movers'),
    'section' => 'expressmovers_featured_slider_info_section',
    'settings' => 'featured_slider_stat2_value',
    'type' => 'text',
));
$wp_customize->add_setting('featured_slider_stat2_label', array(
    'default' => __('On-Time Rate', 'express-movers'),
    'type' => 'theme_mod',
    'capability' => 'edit_theme_options',
    'sanitize_callback' => 'sanitize_text_field',
));
$wp_customize->add_control('featured_slider_stat2_label', array(
    'label' => __('Stat 2 Label', 'express-movers'),
    'section' => 'expressmovers_featured_slider_info_section',
    'settings' => 'featured_slider_stat2_label',
    'type' => 'text',
));

$wp_customize->add_setting('featured_slider_stat3_value', array(
    'default' => __('120+', 'express-movers'),
    'type' => 'theme_mod',
    'capability' => 'edit_theme_options',
    'sanitize_callback' => 'sanitize_text_field',
));
$wp_customize->add_control('featured_slider_stat3_value', array(
    'label' => __('Stat 3 Value', 'express-movers'),
    'section' => 'expressmovers_featured_slider_info_section',
    'settings' => 'featured_slider_stat3_value',
    'type' => 'text',
));
$wp_customize->add_setting('featured_slider_stat3_label', array(
    'default' => __('Cities', 'express-movers'),
    'type' => 'theme_mod',
    'capability' => 'edit_theme_options',
    'sanitize_callback' => 'sanitize_text_field',
));
$wp_customize->add_control('featured_slider_stat3_label', array(
    'label' => __('Stat 3 Label', 'express-movers'),
    'section' => 'expressmovers_featured_slider_info_section',
    'settings' => 'featured_slider_stat3_label',
    'type' => 'text',
));

// Slider Features
$wp_customize->add_setting('featured_slider_feature1_text', array(
    'default' => __('Fully insured', 'express-movers'),
    'type' => 'theme_mod',
    'capability' => 'edit_theme_options',
    'sanitize_callback' => 'sanitize_text_field',
));
$wp_customize->add_control('featured_slider_feature1_text', array(
    'label' => __('Feature 1 Text', 'express-movers'),
    'section' => 'expressmovers_featured_slider_info_section',
    'settings' => 'featured_slider_feature1_text',
    'type' => 'text',
));
$wp_customize->add_setting('featured_slider_feature2_text', array(
    'default' => __('Real-time GPS', 'express-movers'),
    'type' => 'theme_mod',
    'capability' => 'edit_theme_options',
    'sanitize_callback' => 'sanitize_text_field',
));
$wp_customize->add_control('featured_slider_feature2_text', array(
    'label' => __('Feature 2 Text', 'express-movers'),
    'section' => 'expressmovers_featured_slider_info_section',
    'settings' => 'featured_slider_feature2_text',
    'type' => 'text',
));
$wp_customize->add_setting('featured_slider_feature3_text', array(
    'default' => __('24/7 support', 'express-movers'),
    'type' => 'theme_mod',
    'capability' => 'edit_theme_options',
    'sanitize_callback' => 'sanitize_text_field',
));
$wp_customize->add_control('featured_slider_feature3_text', array(
    'label' => __('Feature 3 Text', 'express-movers'),
    'section' => 'expressmovers_featured_slider_info_section',
    'settings' => 'featured_slider_feature3_text',
    'type' => 'text',
));


// Slider Button 1

$wp_customize->add_setting('express_movers_button1_text', 
    array(
    'default'           => __('Contact Us', 'express-movers'),
    'type'              => 'theme_mod',
    'capability'        => 'edit_theme_options',    
    'sanitize_callback' => 'sanitize_text_field'
    )
);
$wp_customize->add_control('express_movers_button1_text', 
    array(
    'label'       => __('Button Text', 'express-movers'),
    'section'     => 'expressmovers_featured_slider_info_section',   
    'settings'    => 'express_movers_button1_text',           
    'type'        => 'text'
    )
);
// Button URL
$wp_customize->add_setting( 'express_movers_button1_url', array(
    'default'           => 'Enter the Button URL',
    'sanitize_callback' => 'esc_url_raw',
));

$wp_customize->add_control( 'express_movers_button1_url', array(
    'label'       => __( 'Button URL', 'express-movers' ),
    'section'     => 'expressmovers_featured_slider_info_section',
    'settings'    => 'express_movers_button1_url',
    'type'        => 'url',
));

// Slider Button 2
$wp_customize->add_setting('featured_slider_button2_text', array(
    'default' => __('Our Services', 'express-movers'),
    'type' => 'theme_mod',
    'capability' => 'edit_theme_options',
    'sanitize_callback' => 'sanitize_text_field',
));
$wp_customize->add_control('featured_slider_button2_text', array(
    'label' => __('2nd Button Text', 'express-movers'),
    'section' => 'expressmovers_featured_slider_info_section',
    'settings' => 'featured_slider_button2_text',
    'type' => 'text',
));
$wp_customize->add_setting('featured_slider_button2_url', array(
    'default' => '',
    'type' => 'theme_mod',
    'capability' => 'edit_theme_options',
    'sanitize_callback' => 'esc_url_raw',
));
$wp_customize->add_control('featured_slider_button2_url', array(
    'label' => __('2nd Button URL (leave blank to use slide permalink)', 'express-movers'),
    'section' => 'expressmovers_featured_slider_info_section',
    'settings' => 'featured_slider_button2_url',
    'type' => 'url',
));
