<?php
function technology_software_firm_sanitize_select( $technology_software_firm_input, $technology_software_firm_setting ) {
	$technology_software_firm_input = sanitize_key( $technology_software_firm_input );
	$technology_software_firm_choices = $technology_software_firm_setting->manager->get_control( $technology_software_firm_setting->id )->choices;
	return ( array_key_exists( $technology_software_firm_input, $technology_software_firm_choices ) ? $technology_software_firm_input : $technology_software_firm_setting->default );
}

function technology_software_firm_sanitize_switch( $technology_software_firm_input ) {
	if ( true === $technology_software_firm_input ) {
		return true;
	} else {
		return false;
	}
}

function technology_software_firm_sanitize_google_fonts( $technology_software_firm_input, $technology_software_firm_setting ) {
	$technology_software_firm_choices = $technology_software_firm_setting->manager->get_control( $technology_software_firm_setting->id )->choices;
	return ( array_key_exists( $technology_software_firm_input, $technology_software_firm_choices ) ? $technology_software_firm_input : $technology_software_firm_setting->default );
}
/**
 * Sanitize HTML input.
 *
 * @param string $technology_software_firm_input HTML input to sanitize.
 * @return string Sanitized HTML.
 */
function technology_software_firm_sanitize_html( $technology_software_firm_input ) {
    return wp_kses_post( $technology_software_firm_input );
}

// Sanitize Scroll Top Position
function technology_software_firm_sanitize_scroll_top_position( $technology_software_firm_input ) {
    $valid_positions = array( 'bottom-right', 'bottom-left', 'bottom-center' );
    if ( in_array( $technology_software_firm_input, $valid_positions ) ) {
        return $technology_software_firm_input;
    } else {
        return 'bottom-right'; // Default to bottom-right if invalid value
    }
}

function technology_software_firm_sanitize_choices( $technology_software_firm_input, $technology_software_firm_setting ) {
	global $wp_customize; 
	$control = $wp_customize->get_control( $technology_software_firm_setting->id ); 
	if ( array_key_exists( $technology_software_firm_input, $control->choices ) ) {
		return $technology_software_firm_input;
	} else {
		return $technology_software_firm_setting->default;
	}
}

function technology_software_firm_sanitize_range_value( $technology_software_firm_number, $technology_software_firm_setting ) {

	// Ensure input is an absolute integer.
	$technology_software_firm_number = absint( $technology_software_firm_number );

	// Get the input attributes associated with the setting.
	$technology_software_firm_atts = $technology_software_firm_setting->manager->get_control( $technology_software_firm_setting->id )->input_attrs;

	// Get minimum number in the range.
	$technology_software_firm_min = ( isset( $technology_software_firm_atts['min'] ) ? $technology_software_firm_atts['min'] : $technology_software_firm_number );

	// Get maximum number in the range.
	$technology_software_firm_max = ( isset( $technology_software_firm_atts['max'] ) ? $technology_software_firm_atts['max'] : $technology_software_firm_number );

	// Get step.
	$technology_software_firm_step = ( isset( $technology_software_firm_atts['step'] ) ? $technology_software_firm_atts['step'] : 1 );

	// If the number is within the valid range, return it; otherwise, return the default.
	return ( $technology_software_firm_min <= $technology_software_firm_number && $technology_software_firm_number <= $technology_software_firm_max && is_int( $technology_software_firm_number / $technology_software_firm_step ) ? $technology_software_firm_number : $technology_software_firm_setting->default );
}