<?php 
/**
 * Home Section
 *
 * @package computer-repair-solutions
 */

$computer_repair_solutions_default = computer_repair_solutions_get_default_theme_options();

/** Slider Info section */
$wp_customize->add_section(
    'computer_repair_solutions_featured_slider_info_section',
    array(
        'title'    => __( 'Slider Info', 'computer-repair-solutions' ),      
        'priority' => 1,
        'panel'      => 'computer_repair_solutions_section_panel',       	
    )
);


// /// effects
$wp_customize->add_setting('computer_repair_solutions_featured_slider_onload_effects',array(
    'default' => 'Bounce In Up',
    'type' => 'theme_mod',
    'sanitize_callback' => 'computer_repair_solutions_sanitize_choices',
));
$wp_customize->add_control('computer_repair_solutions_featured_slider_onload_effects',array(
    'type' => 'select',
    'label' => __('Box Onload Transition Effects','computer-repair-solutions'),
    'choices' => array (
        'wow bounceInLeft' => __('Bounce In Left','computer-repair-solutions'),
        'wow bounceInRight' => __('Bounce In Right','computer-repair-solutions'),
        'wow bounceInUp' => __('Bounce In Up','computer-repair-solutions'),
        'wow bounceInDown' => __('Bounce In Down','computer-repair-solutions'),
        'wow zoomIn' => __('Zoom In','computer-repair-solutions'),
        'wow zoomOut' => __('Zoom Out','computer-repair-solutions'),
        'wow fadeInDown' => __('Fade In Down','computer-repair-solutions'),            
        'wow fadeInUp' => __('Fade In Up','computer-repair-solutions'),
        'wow fadeInLeft' => __('Fade In Left','computer-repair-solutions'),
        'wow fadeInRight' => __('Fade In Right','computer-repair-solutions'),
        'flip-up' => __('Flip Up','computer-repair-solutions')
    ),
    'section' => 'computer_repair_solutions_featured_slider_info_section',
)); 

// Items
// Number of Slider Items
$wp_customize->add_setting('number_of_featured_slider_items', array(
    'default'           => 3, 
    'type' => 'theme_mod',
    'sanitize_callback' => 'absint', 
));

$wp_customize->add_control('number_of_featured_slider_items', array(
    'label'    => __('Number Of Slider To Show', 'computer-repair-solutions'),
    'section'  => 'computer_repair_solutions_featured_slider_info_section', // The section where this control will appear
    'type'     => 'number',
    'input_attrs' => array(
        'min' => 1,
        'max' => 10,
        'step' => 1,
    ),
));

$computer_repair_solutions_slider_list = array();
$computer_repair_solutions_args = array('post_type' => 'post'); // Fetch posts, not pages
$computer_repair_solutions_posts = get_posts( $computer_repair_solutions_args ); 
foreach($computer_repair_solutions_posts as $computer_repair_solutions_post) {
    $computer_repair_solutions_slider_list[$computer_repair_solutions_post->ID] = $computer_repair_solutions_post->post_title; // Use post ID as key and title as value
}

for ( $computer_repair_solutions_count = 1; $computer_repair_solutions_count <= 3; $computer_repair_solutions_count++ ) {
    $wp_customize->add_setting( 'select_post_slider' . $computer_repair_solutions_count, array(
        'default'           => '',
        'sanitize_callback' => 'computer_repair_solutions_sanitize_post_dropdown'
    ));
    $wp_customize->add_control( 'select_post_slider' . $computer_repair_solutions_count, array(
        'label'   => __( 'Select A Post Page', 'computer-repair-solutions' ),
        'section' => 'computer_repair_solutions_featured_slider_info_section',
        'type'    => 'select', // Use 'select' for custom post list
        'choices' => $computer_repair_solutions_slider_list // Populate choices with posts
    ));
}

$wp_customize->add_setting('theme_options[featured_slider_section_heading]', 
	array(
	'default'           => $computer_repair_solutions_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', 'computer-repair-solutions'),
	'section'     => 'computer_repair_solutions_featured_slider_info_section',   
	'settings'    => 'theme_options[featured_slider_section_heading]',		
	'type'        => 'text'
	)
);


$wp_customize->add_setting('theme_options[featured_slider_section_lifirst]', 
	array(
	'default'           => $computer_repair_solutions_default['featured_slider_section_lifirst'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',	
	'sanitize_callback' => 'sanitize_text_field'
	)
);
$wp_customize->add_control('theme_options[featured_slider_section_lifirst]', 
	array(
	'label'       => __('Li Text 1', 'computer-repair-solutions'),
	'section'     => 'computer_repair_solutions_featured_slider_info_section',   
	'settings'    => 'theme_options[featured_slider_section_lifirst]',		
	'type'        => 'text'
	)
);
$wp_customize->add_setting('theme_options[featured_slider_section_lisec]', 
	array(
	'default'           => $computer_repair_solutions_default['featured_slider_section_lisec'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',	
	'sanitize_callback' => 'sanitize_text_field'
	)
);
$wp_customize->add_control('theme_options[featured_slider_section_lisec]', 
	array(
	'label'       => __('Li Text 2', 'computer-repair-solutions'),
	'section'     => 'computer_repair_solutions_featured_slider_info_section',   
	'settings'    => 'theme_options[featured_slider_section_lisec]',		
	'type'        => 'text'
	)
);
$wp_customize->add_setting('theme_options[featured_slider_section_lithird]', 
	array(
	'default'           => $computer_repair_solutions_default['featured_slider_section_lithird'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',	
	'sanitize_callback' => 'sanitize_text_field'
	)
);
$wp_customize->add_control('theme_options[featured_slider_section_lithird]', 
	array(
	'label'       => __('Li Text 3', 'computer-repair-solutions'),
	'section'     => 'computer_repair_solutions_featured_slider_info_section',   
	'settings'    => 'theme_options[featured_slider_section_lithird]',		
	'type'        => 'text'
	)
);
////////// Button

$wp_customize->add_setting('computer_repair_solutions_buttonfirst_text', 
    array(
    'default'           => __('Call Now: (555) 123-4567', 'computer-repair-solutions'),
    'type'              => 'theme_mod',
    'capability'        => 'edit_theme_options',    
    'sanitize_callback' => 'sanitize_text_field'
    )
);
$wp_customize->add_control('computer_repair_solutions_buttonfirst_text', 
    array(
    'label'       => __('1 Button Text', 'computer-repair-solutions'),
    'section'     => 'computer_repair_solutions_featured_slider_info_section',   
    'settings'    => 'computer_repair_solutions_buttonfirst_text',           
    'type'        => 'text'
    )
);
// Button URL
$wp_customize->add_setting( 'computer_repair_solutions_buttonfirst_url', array(
    'default'           => 'Enter the Button URL',
    'type' => 'theme_mod',
    'sanitize_callback' => 'esc_url_raw',
));

$wp_customize->add_control( 'computer_repair_solutions_buttonfirst_url', array(
    'label'       => __( '1 Button URL', 'computer-repair-solutions' ),
    'section'     => 'computer_repair_solutions_featured_slider_info_section',
    'settings'    => 'computer_repair_solutions_buttonfirst_url',
    'type'        => 'url',
));
$wp_customize->add_setting('computer_repair_solutions_buttonsec_text', 
    array(
    'default'           => __('Call Now: (555) 123-4567', 'computer-repair-solutions'),
    'type'              => 'theme_mod',
    'capability'        => 'edit_theme_options',    
    'sanitize_callback' => 'sanitize_text_field'
    )
);
$wp_customize->add_control('computer_repair_solutions_buttonsec_text', 
    array(
    'label'       => __('2 Button Text', 'computer-repair-solutions'),
    'section'     => 'computer_repair_solutions_featured_slider_info_section',   
    'settings'    => 'computer_repair_solutions_buttonsec_text',           
    'type'        => 'text'
    )
);
// Button URL
$wp_customize->add_setting( 'computer_repair_solutions_buttonsec_url', array(
    'default'           => 'Enter the Button URL',
    'type' => 'theme_mod',
    'sanitize_callback' => 'esc_url_raw',
));

$wp_customize->add_control( 'computer_repair_solutions_buttonsec_url', array(
    'label'       => __( '2 Button URL', 'computer-repair-solutions' ),
    'section'     => 'computer_repair_solutions_featured_slider_info_section',
    'settings'    => 'computer_repair_solutions_buttonsec_url',
    'type'        => 'url',
));
