<?php

function moving_truck_rental_sanitize_select( $moving_truck_rental_input, $moving_truck_rental_setting ) {
	$moving_truck_rental_input = sanitize_key( $moving_truck_rental_input );
	$moving_truck_rental_choices = $moving_truck_rental_setting->manager->get_control( $moving_truck_rental_setting->id )->choices;
	return ( array_key_exists( $moving_truck_rental_input, $moving_truck_rental_choices ) ? $moving_truck_rental_input : $moving_truck_rental_setting->default );
}

function moving_truck_rental_sanitize_switch( $moving_truck_rental_input ) {
	if ( true === $moving_truck_rental_input ) {
		return true;
	} else {
		return false;
	}
}

function moving_truck_rental_sanitize_google_fonts( $moving_truck_rental_input, $moving_truck_rental_setting ) {
	$moving_truck_rental_choices = $moving_truck_rental_setting->manager->get_control( $moving_truck_rental_setting->id )->choices;
	return ( array_key_exists( $moving_truck_rental_input, $moving_truck_rental_choices ) ? $moving_truck_rental_input : $moving_truck_rental_setting->default );
}
/**
 * Sanitize HTML input.
 *
 * @param string $moving_truck_rental_input HTML input to sanitize.
 * @return string Sanitized HTML.
 */
function moving_truck_rental_sanitize_html( $moving_truck_rental_input ) {
    return wp_kses_post( $moving_truck_rental_input );
}

/**
 * Sanitize URL input.
 *
 * @param string $moving_truck_rental_input URL input to sanitize.
 * @return string Sanitized URL.
 */
function moving_truck_rental_sanitize_url( $moving_truck_rental_input ) {
    return esc_url_raw( $moving_truck_rental_input );
}

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

function moving_truck_rental_sanitize_choices( $moving_truck_rental_input, $moving_truck_rental_setting ) {
	global $wp_customize; 
	$moving_truck_rental_control = $wp_customize->get_control( $moving_truck_rental_setting->id ); 
	if ( array_key_exists( $moving_truck_rental_input, $moving_truck_rental_control->choices ) ) {
		return $moving_truck_rental_input;
	} else {
		return $moving_truck_rental_setting->default;
	}
}

function moving_truck_rental_sanitize_range_value( $moving_truck_rental_number, $moving_truck_rental_setting ) {

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

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

	// Get minimum number in the range.
	$moving_truck_rental_min = ( isset( $moving_truck_rental_atts['min'] ) ? $moving_truck_rental_atts['min'] : $moving_truck_rental_number );

	// Get maximum number in the range.
	$moving_truck_rental_max = ( isset( $moving_truck_rental_atts['max'] ) ? $moving_truck_rental_atts['max'] : $moving_truck_rental_number );

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

	// If the number is within the valid range, return it; otherwise, return the default.
	return ( $moving_truck_rental_min <= $moving_truck_rental_number && $moving_truck_rental_number <= $moving_truck_rental_max && is_int( $moving_truck_rental_number / $moving_truck_rental_step ) ? $moving_truck_rental_number : $moving_truck_rental_setting->default );
}