<?php
/**
 * What We Offer Section options.
 *
 * @package prime-construction
 */

$default = prime_construction_get_default_theme_options();

/** What We Offer Info section */
$wp_customize->add_section(
    'featured_whatweoffer_info_section',
    array(
        'title'    => __( 'What We Offer Info', 'prime-construction' ),      
        'priority' => 1,
        'panel'      => 'prime_construction_section_panel',       	
    )
);

// Enable Section
$wp_customize->add_setting(
    'whatweoffer_enable_section',
    array(
        'default' 			=> true,
        'sanitize_callback' => 'prime_construction_sanitize_switch',
    )
);
$wp_customize->add_control(
    new prime_construction_Toggle_Checkbox_Custom_control(
        $wp_customize,
        'whatweoffer_enable_section',
        array(
            'settings'      => 'whatweoffer_enable_section',
            'section'       => 'featured_whatweoffer_info_section',
            'label'         => __( 'Enable Section', 'prime-construction' ),
            'on_off_label'  => array(
                'on' => __( 'Yes', 'prime-construction' ),
                'off' => __( 'No', 'prime-construction' )
            ),
        )
    )
);


     // ///////// Background Color
     $wp_customize->add_setting('whatweoffer_background_color', array(
        'default'   => '#ffffff',
        'transport' => 'refresh',
        'sanitize_callback' => 'sanitize_hex_color',
    ));
      
    $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'whatweoffer_background_color', array(
        'section' => 'featured_whatweoffer_info_section',
        'description' => __('Background Color', 'prime-construction'),
    )));

    // Section Title
    $wp_customize->add_setting('theme_options[featured_whatweoffer_title]', 
        array(
        'default'           => $default['featured_whatweoffer_title'],
        'type'              => 'theme_mod',
        'capability'        => 'edit_theme_options',    
        'sanitize_callback' => 'sanitize_text_field'
        )
    );

    // /// effects
    $wp_customize->add_setting('prime_construction_featured_whatweoffer_onload_effects',array(
        'default' => 'zoom-in',
        'sanitize_callback' => 'prime_construction_sanitize_choices',
    ));
    $wp_customize->add_control('prime_construction_featured_whatweoffer_onload_effects',array(
        'type' => 'select',
        'label' => __('Box Onload Transition Effects','prime-construction'),
        'choices' => array (
            'wow bounceInLeft' => __('Bounce In Left','prime-construction'),
            'wow bounceInRight' => __('Bounce In Right','prime-construction'),
            'wow bounceInUp' => __('Bounce In Up','prime-construction'),
            'wow bounceInDown' => __('Bounce In Down','prime-construction'),
            'wow zoomIn' => __('Zoom In','prime-construction'),
            'wow zoomOut' => __('Zoom Out','prime-construction'),
            'wow fadeInDown' => __('Fade In Down','prime-construction'),            
            'wow fadeInUp' => __('Fade In Up','prime-construction'),
            'wow fadeInLeft' => __('Fade In Left','prime-construction'),
            'wow fadeInRight' => __('Fade In Right','prime-construction'),
            'flip-up' => __('Flip Up','prime-construction')
        ),
        'section' => 'featured_whatweoffer_info_section',
    )); 

    $wp_customize->add_control('theme_options[featured_whatweoffer_title]', 
        array(
        'label'       => __('Section Title', 'prime-construction'),
        'section'     => 'featured_whatweoffer_info_section',   
        'settings'    => 'theme_options[featured_whatweoffer_title]',  
        'active_callback' => 'prime_construction_featured_whatweoffer_active',        
        'type'        => 'text'
        )
    );

    // Section Sub-Title
    $wp_customize->add_setting('theme_options[featured_whatweoffer_subtitle]', 
        array(
        'default'           => $default['featured_whatweoffer_subtitle'],
        'type'              => 'theme_mod',
        'capability'        => 'edit_theme_options',    
        'sanitize_callback' => 'sanitize_text_field'
        )
    );

    $wp_customize->add_control('theme_options[featured_whatweoffer_subtitle]', 
        array(
        'label'       => __('Section Sub-Title', 'prime-construction'),
        'section'     => 'featured_whatweoffer_info_section',   
        'settings'    => 'theme_options[featured_whatweoffer_subtitle]',  
        'active_callback' => 'prime_construction_featured_whatweoffer_active',        
        'type'        => 'text'
        )
    );
    // Section Sub-Title
    $wp_customize->add_setting('theme_options[featured_whatweoffer_subtitle1]', 
        array(
        'default'           => $default['featured_whatweoffer_subtitle1'],
        'type'              => 'theme_mod',
        'capability'        => 'edit_theme_options',    
        'sanitize_callback' => 'sanitize_text_field'
        )
    );

    $wp_customize->add_control('theme_options[featured_whatweoffer_subtitle1]', 
        array(
        'label'       => __('Section Color Sub-Title', 'prime-construction'),
        'section'     => 'featured_whatweoffer_info_section',   
        'settings'    => 'theme_options[featured_whatweoffer_subtitle1]',  
        'active_callback' => 'prime_construction_featured_whatweoffer_active',        
        'type'        => 'text'
        )
    );

// Number of offer Items
$wp_customize->add_setting('number_of_featured_offer_items', array(
    'default'           => 6, // Set default number of items
    'sanitize_callback' => 'absint', // Ensure it's a valid integer
));

$wp_customize->add_control('number_of_featured_offer_items', array(
    'label'    => __('Number of Offer Items', 'prime-construction'),
    'section'  => 'featured_whatweoffer_info_section', // The section where this control will appear
    'type'     => 'number',
    'input_attrs' => array(
        'min' => 1, // Minimum value
        'max' => 6, // Maximum value
        'step' => 1, // Increment step
    ),
));

    // Column
    $wp_customize->add_setting('theme_options[featured_whatweoffer_column]', 
        array(
        'default' 			=> $default['featured_whatweoffer_column'],
        'type'              => 'theme_mod',
        'capability'        => 'edit_theme_options',
        'sanitize_callback' => 'prime_construction_sanitize_select'
        )
    );

    $wp_customize->add_control(new prime_construction_Image_Radio_Control($wp_customize, 'theme_options[featured_whatweoffer_column]', 
        array(		
        'label' 	=> __('Column', 'prime-construction'),
        'section' 	=> 'featured_whatweoffer_info_section',
        'settings'  => 'theme_options[featured_whatweoffer_column]',
        'type' 		=> 'radio-image',
        'active_callback' => 'prime_construction_featured_whatweoffer_active',
        'choices' 	=> array(		
            '1' 	=> esc_url(get_template_directory_uri()) . '/assets/images/column-1.jpg',						
            '2' 	=> esc_url(get_template_directory_uri()) . '/assets/images/column-2.jpg',
            '3' 	=> esc_url(get_template_directory_uri()) . '/assets/images/column-3.jpg',
            '4' 	=> esc_url(get_template_directory_uri()) . '/assets/images/column-4.jpg',
            '5' 	=> esc_url(get_template_directory_uri()) . '/assets/images/column-5.jpg',
            '6' 	=> esc_url(get_template_directory_uri()) . '/assets/images/column-6.jpg',
            ),	
        ))
    );
/////list of post////////////////
$prime_construction_what_we_offer_list = array();
$args = array('post_type' => 'post'); // Fetch posts, not pages
$prime_construction_what_we_offer_posts = get_posts( $args ); 
foreach($prime_construction_what_we_offer_posts as $prime_construction_what_we_offer_post) {
    $prime_construction_what_we_offer_list[$prime_construction_what_we_offer_post->ID] = $prime_construction_what_we_offer_post->post_title; // Use post ID as key and title as value
}

for ( $count = 1; $count <= 6; $count++ ) {
    $wp_customize->add_setting( 'select_post_what_we_offer' . $count, array(
        'default'           => '',
        'sanitize_callback' => 'sanitize_post_dropdown'
    ));
    $wp_customize->add_control( 'select_post_what_we_offer' . $count, array(
        'label'   => __( 'Select Post Page', 'prime-construction' ),
        'section' => 'featured_whatweoffer_info_section',
        'type'    => 'select', // Use 'select' for custom post list
        'choices' => $prime_construction_what_we_offer_list // Populate choices with posts
    ));
}



    /** whatweoffer Colors Section */
    $wp_customize->add_section(
        'whatweoffer_text_colors_section',
        array(
            'title'    => __( 'Colors', 'prime-construction' ),        
            'priority' => 2,
            'panel'      => 'prime_construction_whatweofferec_panel3',  
        )
    );

     // ///////// Title Text Color
     $wp_customize->add_setting('whatweoffer_title_color', array(
        'default'   => '#3F3F3F',
        'transport' => 'refresh',
        'sanitize_callback' => 'sanitize_hex_color',
    ));
      
    $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'whatweoffer_title_color', array(
        'section' => 'whatweoffer_text_colors_section',
        'description' => __('Title Color', 'prime-construction'),
    )));

    // ///////// Sub-Title Text Color
    $wp_customize->add_setting('whatweoffer_subtitle_color', array(
        'default'   => '#3F3F3F',
        'transport' => 'refresh',
        'sanitize_callback' => 'sanitize_hex_color',
    ));
      
    $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'whatweoffer_subtitle_color', array(
        'section' => 'whatweoffer_text_colors_section',
        'description' => __('Sub-Title Color', 'prime-construction'),
    )));
    
    // ///////// Card Title Color
    $wp_customize->add_setting('whatweoffer_cardtitle_color', array(
        'default'   => '#3F3F3F',
        'transport' => 'refresh',
        'sanitize_callback' => 'sanitize_hex_color',
    ));
      
    $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'whatweoffer_cardtitle_color', array(
        'section' => 'whatweoffer_text_colors_section',
        'description' => __('Service Box Title Color', 'prime-construction'),
    )));

    
    /** whatweoffer Structure section */

        $wp_customize->add_section(
            'whatweoffer_structure_section',
            array(
                'title'    => __( 'Structure', 'prime-construction' ),        
                'priority' => 3,
                'panel'      => 'prime_construction_whatweofferec_panel3',  
            )
        );

        $wp_customize->add_setting('featured_whatweoffer_title_case',array(
            'default' => 'Uppercase',
            'sanitize_callback' => 'prime_construction_sanitize_choices',
        ));
        $wp_customize->add_control('featured_whatweoffer_title_case',array(
            'type' => 'select',
            'label' => __('Title Case','prime-construction'),
            'choices' => array (
                'Uppercase' => __('Uppercase','prime-construction'),
                'Lowercase' => __('Lowercase','prime-construction'),
                'Capitalize' => __('Capitalize','prime-construction'),
                'None' => __('None','prime-construction')
            ),
            'section' => 'whatweoffer_structure_section',
        ));

        $wp_customize->add_setting('featured_whatweoffer_subtitle_case',array(
            'default' => 'Capitalize',
            'sanitize_callback' => 'prime_construction_sanitize_choices',
        ));
        $wp_customize->add_control('featured_whatweoffer_subtitle_case',array(
            'type' => 'select',
            'label' => __('Sub Title Case','prime-construction'),
            'choices' => array (
                'Uppercase' => __('Uppercase','prime-construction'),
                'Lowercase' => __('Lowercase','prime-construction'),
                'Capitalize' => __('Capitalize','prime-construction'),
                'None' => __('None','prime-construction')
            ),
            'section' => 'whatweoffer_structure_section',
        ));

        $wp_customize->add_setting('featured_whatweoffer_cardtitle_case',array(
            'default' => 'Capitalize',
            'sanitize_callback' => 'prime_construction_sanitize_choices',
        ));
        $wp_customize->add_control('featured_whatweoffer_cardtitle_case',array(
            'type' => 'select',
            'label' => __('Card Title Case','prime-construction'),
            'choices' => array (
                'Uppercase' => __('Uppercase','prime-construction'),
                'Lowercase' => __('Lowercase','prime-construction'),
                'Capitalize' => __('Capitalize','prime-construction'),
                'None' => __('None','prime-construction')
            ),
            'section' => 'whatweoffer_structure_section',
        ));

