<?php

/**
 * Sanitize select field
 *
 * @param  string $input   Selected input
 * @param  string $setting Input setting
 */
function go_mechanic_sanitise_custom_option($input)
{
	return ($input === "No") ? "No" : "Yes";
}

function go_mechanic_sanitise_custom_text($input)
{
	return sanitize_text_field($input);
}

function go_mechanic_sanitize_additional_content_array($input_array)
{
	$sanitized_array = array();

	foreach ($input_array as $input) {
		$sanitized_array[] = sanitize_text_field($input);
	}

	return $sanitized_array;
}


function go_mechanic_sanitise_custom_texttitle($inputtitle)
{
	return sanitize_text_field($inputtitle);
}

function go_mechanic_sanitise_custom_url($input)
{
	return esc_url_raw($input);
}

function go_mechanic_sanitize_switch($input)
{
	if (true === $input) {
		return true;
	} else {
		return false;
	}
}

function go_mechanic_sanitize_post_dropdown( $input ) {
	// Ensure the input is an integer (post ID).
	$input = absint( $input );

	// Check if the post exists in the database.
	if ( get_post( $input ) ) {
		return $input; // Return the valid post ID.
	} else {
		return ''; // Return empty if it's invalid.
	}
}

/*
 * Ensure the users font choice is a valid option contained in our fonts array.
 */
function go_mechanic_sanitize_site_title_font_choice($value)
{
	// Grab our fonts array.
	$choices = go_mechanic_site_title_font_choices();

	// Return a valid font name.
	return $value;
}
