<?php 
/**
 * Home Section
 *
 * @package voltmaster-electrician
 */

$voltmaster_electrician_default = voltmaster_electrician_get_default_theme_options();

/** Slider Info section */
$wp_customize->add_section(
    'voltmasterelectrician_featured_slider_info_section',
    array(
        'title'    => __( 'Slider Info', 'voltmaster-electrician' ),      
        'priority' => 1,
        'panel'      => 'voltmaster_electrician_section_panel',       	
    )
);


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

$voltmaster_electrician_slider_list = array();
$voltmaster_electrician_args = array('post_type' => 'post'); // Fetch posts, not pages
$voltmaster_electrician_posts = get_posts( $voltmaster_electrician_args ); 
foreach($voltmaster_electrician_posts as $voltmaster_electrician_post) {
    $voltmaster_electrician_slider_list[$voltmaster_electrician_post->ID] = $voltmaster_electrician_post->post_title; // Use post ID as key and title as value
}

for ( $voltmaster_electrician_count = 1; $voltmaster_electrician_count <= 3; $voltmaster_electrician_count++ ) {
    $wp_customize->add_setting( 'select_post_slider' . $voltmaster_electrician_count, array(
        'default'           => '',
        'sanitize_callback' => 'voltmaster_electrician_sanitize_post_dropdown'
    ));
    $wp_customize->add_control( 'select_post_slider' . $voltmaster_electrician_count, array(
        'label'   => __( 'Select A Post Page', 'voltmaster-electrician' ),
        'section' => 'voltmasterelectrician_featured_slider_info_section',
        'type'    => 'select', // Use 'select' for custom post list
        'choices' => $voltmaster_electrician_slider_list // Populate choices with posts
    ));
}

$wp_customize->add_setting('theme_options[featured_slider_section_heading]', 
	array(
	'default'           => $voltmaster_electrician_default['featured_slider_section_heading'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',	
	'sanitize_callback' => 'sanitize_text_field'
	)
);
$wp_customize->add_control('theme_options[featured_slider_section_heading]', 
	array(
	'label'       => __('Heading', 'voltmaster-electrician'),
	'section'     => 'voltmasterelectrician_featured_slider_info_section',   
	'settings'    => 'theme_options[featured_slider_section_heading]',		
	'type'        => 'text'
	)
);


  // Star rating (1–5)
    $wp_customize->add_setting('voltmaster-electrician_rating_stars', array(
        'default' => 5,
        'sanitize_callback' => 'absint',
    ));

    $wp_customize->add_control('voltmaster-electrician_rating_stars', array(
        'label' => __('Star Rating (1–5)', 'voltmaster-electrician'),
        'section' => 'voltmasterelectrician_featured_slider_info_section',
        'type' => 'number',
        'input_attrs' => array(
            'min' => 1,
            'max' => 5,
        ),
    ));

    // Rating text
    $wp_customize->add_setting('voltmaster-electrician_rating_text', array(
        'default' => '5.0 Rating (150+ Reviews)',
        'sanitize_callback' => 'sanitize_text_field',
    ));

    $wp_customize->add_control('voltmaster-electrician_rating_text', array(
        'label' => __('Rating Text', 'voltmaster-electrician'),
        'section' => 'voltmasterelectrician_featured_slider_info_section',
        'type' => 'text',
    ));
////////// Button

$wp_customize->add_setting('voltmaster_electrician_button1_text', 
    array(
    'default'           => __('Call Now: (555) 123-4567', 'voltmaster-electrician'),
    'type'              => 'theme_mod',
    'capability'        => 'edit_theme_options',    
    'sanitize_callback' => 'sanitize_text_field'
    )
);
$wp_customize->add_control('voltmaster_electrician_button1_text', 
    array(
    'label'       => __('1 Button Text', 'voltmaster-electrician'),
    'section'     => 'voltmasterelectrician_featured_slider_info_section',   
    'settings'    => 'voltmaster_electrician_button1_text',           
    'type'        => 'text'
    )
);
// Button URL
$wp_customize->add_setting( 'voltmaster_electrician_button1_url', array(
    'default'           => 'Enter the Button URL',
    'sanitize_callback' => 'esc_url_raw',
));

$wp_customize->add_control( 'voltmaster_electrician_button1_url', array(
    'label'       => __( '1 Button URL', 'voltmaster-electrician' ),
    'section'     => 'voltmasterelectrician_featured_slider_info_section',
    'settings'    => 'voltmaster_electrician_button1_url',
    'type'        => 'url',
));



$wp_customize->add_setting('voltmaster_electrician_button2_text', 
    array(
    'default'           => __('Get Free Quote', 'voltmaster-electrician'),
    'type'              => 'theme_mod',
    'capability'        => 'edit_theme_options',    
    'sanitize_callback' => 'sanitize_text_field'
    )
);
$wp_customize->add_control('voltmaster_electrician_button2_text', 
    array(
    'label'       => __('2 Button Text', 'voltmaster-electrician'),
    'section'     => 'voltmasterelectrician_featured_slider_info_section',   
    'settings'    => 'voltmaster_electrician_button2_text',           
    'type'        => 'text'
    )
);
// Button URL
$wp_customize->add_setting( 'voltmaster_electrician_button2_url', array(
    'default'           => 'Enter the Button URL',
    'sanitize_callback' => 'esc_url_raw',
));

$wp_customize->add_control( 'voltmaster_electrician_button2_url', array(
    'label'       => __( '2 Button URL', 'voltmaster-electrician' ),
    'section'     => 'voltmasterelectrician_featured_slider_info_section',
    'settings'    => 'voltmaster_electrician_button2_url',
    'type'        => 'url',
));

$wp_customize->add_setting('voltmaster_electrician_ratingstar_color', array(
    'default' => '#fac100',
    'transport' => 'refresh',
    'sanitize_callback' => 'sanitize_hex_color',
));

$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'voltmaster_electrician_ratingstar_color', array(
    'section' => 'voltmasterelectrician_featured_slider_info_section',
    'label' => esc_html__('Rating Star Color', 'voltmaster-electrician'),
)));

$wp_customize->add_setting('voltmaster_electrician_callnow_btn_bgcolor', array(
    'default' => '#fac100',
    'transport' => 'refresh',
    'sanitize_callback' => 'sanitize_hex_color',
));

$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'voltmaster_electrician_callnow_btn_bgcolor', array(
    'section' => 'voltmasterelectrician_featured_slider_info_section',
    'label' => esc_html__('Call Now Button BG Color', 'voltmaster-electrician'),
)));

$wp_customize->add_setting('voltmaster_electrician_callnow_btn_textcolor', array(
    'default' => '#000',
    'transport' => 'refresh',
    'sanitize_callback' => 'sanitize_hex_color',
));

$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'voltmaster_electrician_callnow_btn_textcolor', array(
    'section' => 'voltmasterelectrician_featured_slider_info_section',
    'label' => esc_html__('Call Now Button Text Color', 'voltmaster-electrician'),
)));

$wp_customize->add_setting('voltmaster_electrician_getfree_btn_textcolor', array(
    'default' => '#101828',
    'transport' => 'refresh',
    'sanitize_callback' => 'sanitize_hex_color',
));

$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'voltmaster_electrician_getfree_btn_textcolor', array(
    'section' => 'voltmasterelectrician_featured_slider_info_section',
    'label' => esc_html__('Get Free Quote Button Text Color', 'voltmaster-electrician'),
)));

$wp_customize->add_setting('voltmaster_electrician_heading_textcolor', array(
    'default' => '#fff',
    'transport' => 'refresh',
    'sanitize_callback' => 'sanitize_hex_color',
));

$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'voltmaster_electrician_heading_textcolor', array(
    'section' => 'voltmasterelectrician_featured_slider_info_section',
    'label' => esc_html__('Heading Text Color', 'voltmaster-electrician'),
)));

$wp_customize->add_setting('voltmaster_electrician_subheading_textcolor', array(
    'default' => '#fff',
    'transport' => 'refresh',
    'sanitize_callback' => 'sanitize_hex_color',
));

$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'voltmaster_electrician_subheading_textcolor', array(
    'section' => 'voltmasterelectrician_featured_slider_info_section',
    'label' => esc_html__('SubHeading Text Color', 'voltmaster-electrician'),
)));


