<?php

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

function eco_solar_energy_sanitise_custom_text($input)
{
	return filter_var($input, FILTER_SANITIZE_STRING);
}

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

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

	return $sanitized_array;
}


function eco_solar_energy_sanitise_custom_texttitle($inputtitle)
{
	return filter_var($inputtitle, FILTER_SANITIZE_STRING);
}

function eco_solar_energy_sanitise_custom_url($input)
{
	return filter_var($input, FILTER_SANITIZE_URL);
}

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

function 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.
	}
}

function eco_solar_energy_site_title_font_choices()
{
	return apply_filters('eco_solar_energy_site_title_font_choices', array(
		'aboreto'   => 'Aboreto',
		'lobster two' => 'Lobster Two',
		'norican'   => 'Norican',
		'arial'     => 'Arial',
		'verdana'   => 'Verdana, Geneva',
		'trebuchet' => 'Trebuchet',
		'georgia'   => 'Georgia',
		'times new roman'     => 'Times New Roman',
		'tahoma'    => 'Tahoma, Geneva',
		'palatino'  => 'Palatino',
		'helvetica' => 'Helvetica*',
		'abel'     => 'Abel',
		'abril fatface' => 'Abril Fatface',
		'aclonica'   => 'Aclonica',
		'adamina'     => 'Adamina',
		'advent pro'    => 'Advent Pro',
		'akronim'  => 'Akronim',
		'aladin' => 'Aladin',
		'aleo'     => 'Aleo',
		'alex brush'   => 'Alex Brush',
		'alice' => 'Alice',
		'alike'   => 'Alike',
		'almendra'     => 'Almendra',
		'arial black'     => 'Arial Black',
		'arial narrow'   => 'Arial narrow',
		'arial nova' => 'Arial Nova',
		'arnoldboecklin'   => 'Arnoldboecklin',
		'avanta'     => 'Avanta Garde',
		'bahnschrift'    => 'Bahnschrift',
		'bahnschrift light'  => 'Bahnschrift Light',
		'baskerville' => 'Baskerville',
		'b612'    => 'B612',
		'babylonica'  => 'Babylonica',
		'bad script' => 'Bad Script',
		'bangers'     => 'Bangers',
		'barrio'   => 'Barrio',
		'battambang' => 'Battambang',
		'bayon'   => 'Bayon',
		'bellota'     => 'Bellota',
		'babylonica'  => 'Babylonica',
		'batang'     => 'Batang',
		'batangChe'   => 'BatangChe',
		'big caslon' => 'Big Caslon',
		'bIZ udgothic'   => 'BIZ UDGothic',
		'blippo'     => 'Blippo',
		'bodoni mt'    => 'Bodoni MT',
		'book antiqua'  => 'Book Antiqua',
		'bookman' => 'Bookman',
		'bradley hand'     => 'Bradley Hand',
		'browallia new'   => 'Browallia New',
		'browalliaUPC' => 'BrowalliaUPC',
		'brush script mt'   => 'Brush Script MT',
		'brushscript script std'     => 'Brush Script Std',
		'brushstroke'    => 'Brushstroke',
		'calibri'  => 'Calibri',
		'calibri light' => 'Calibri Light',
		'calisto mt'     => 'Calisto MT',
		'cambodian'   => 'Cambodian',
		'cambria' => 'Cambria',
		'cambria math'   => 'Cambria Math',
		'candara'     => 'Candara',
		'century gothic'    => 'Century Gothic',
		'chalkduster'  => 'Chalkduster',
		'cherokee' => 'Cherokee',
		'comic sans'     => 'Comic Sans',
		'comicms sans ms'   => 'Comic Sans MS',
		'consolas' => 'Consolas',
		'constantia'   => 'Constantia',
		'copperplate'     => 'Copperplate',
		'corbel'    => 'Corbel',
		'cordia new'  => 'Cordia New',
		'cordiaUPC' => 'CordiaUPC',
		'cabin'     => 'Cabin',
		'cairo'   => 'Cairo',
		'calligraffitti' => 'Calligraffitti',
		'candal'   => 'Candal',
		'cherry swash'     => 'Cherry Swash',
		'chonburi'    => 'Chonburi',
		'cinzel decorative'  => 'Cinzel Decorative',
		'comfortaa' => 'Comfortaa',
		'coronetscript'     => 'Coronetscript',
		'courier'   => 'Courier',
		'Courier new' => 'Courier New',
		'daunPenh'   => 'DaunPenh',
		'david'     => 'David',
		'dengXian'    => 'DengXian',
		'didot'  => 'Didot',
		'dilleniaUPC' => 'DilleniaUPC',
		'dokChampa'     => 'DokChampa',
		'dotum'   => 'Dotum',
		'dotumChe' => 'DotumChe',
		'ebrima'   => 'Ebrima',
		'estrangelo edessa'     => 'Estrangelo Edessa',
		'eucrosiaUPC'    => 'EucrosiaUPC',
		'euphemia'  => 'Euphemia',
		'eangSong' => 'FangSong',
		'elorence'     => 'Florence',
		'franklin gothic medium'   => 'Franklin Gothic Medium',
		'frankRuehl' => 'FrankRuehl',
		'freesiaUPC'   => 'FreesiaUPC',
		'futara'     => 'Futara',
		'fondamento' => 'Fondamento',
		'gabriola'    => 'Gabriola',
		'gadugi'  => 'Gadugi',
		'garamond' => 'Garamond',
		'gautami'     => 'Gautami',
		'geneva'   => 'Geneva',
		'georgia' => 'Georgia',
		'georgia pro'   => 'Georgia Pro',
		'gill sans'     => 'Gill Sans',
		'gill sans nova'    => 'Gill Sans Nova',
		'gisha'  => 'Gisha',
		'goudy old style' => 'Goudy Old Style',
		'gulim'     => 'Gulim',
		'gungsuh'   => 'Gungsuh',
		'hebrew' => 'Hebrew',
		'hoefler text'   => 'Hoefler Text',
		'impact'     => 'Impact',
		'ink free'    => 'Ink Free',
		'irisUPC'  => 'IrisUPC',
		'iskoola pota' => 'Iskoola Pota',
		'japanese'     => 'Japanese',
		'jasmineUPC'   => 'JasmineUPC',
		'javanese text' => 'Javanese Text',
		'jazz let'   => 'Jazz LET',
		'kaiTi'     => 'KaiTi',
		'kalinga'    => 'Kalinga',
		'kartika'  => 'Kartika',
		'kokila' => 'Kokila',
		'lao'     => 'Lao',
		'Lato'    => 'Lato',
		'latha'   => 'Latha',
		'leelawadee' => 'Leelawadee',
		'levenim mt'   => 'Levenim MT',
		'lucida bright'     => 'Lucida Bright',
		'lucida console'    => 'Lucida Console',
		'lucida handwriting'  => 'Lucida Handwriting',
		'lucida sans' => 'Lucida Sans',
		'malgun gothic'     => 'Malgun Gothic',
		'mangal'   => 'Mangal',
		'marker felt' => 'Marker Felt',
		'meiryo'   => 'Meiryo',
		'microsoft sans serif'     => 'Microsoft Sans Serif',
		'microsoft tai le'    => 'Microsoft Tai Le',
		'miriam'  => 'Miriam',
		'monaco' => 'Monaco',
		'Montserrat' => 'Montserrat',
		'mystery quest'     => 'Mystery Quest',
		'nerko one'   => 'Nerko One',
		'nokora' => 'Nokora',
		'notable'   => 'Notable',
		'noto emoji'     => 'Noto Emoji',
		'oldenburg'    => 'Oldenburg',
		'oleo script'  => 'Oleo Script',
		'open sans' => 'Open Sans',
		'oregano'     => 'Oregano',
		'overpass'   => 'Overpass',
		'Oswald'     => 'Oswald',
		'pt mono' => 'PT Mono',
		'palanquin'   => 'Palanquin',
		'play'     => 'Play',
		'podkova'    => 'Podkova',
		'poppins'  => 'Poppins',
		'prata' => 'Prata',
		'playfair display' => 'Playfair Display',
		'radley'     => 'Radley',
		'raleway'   => 'Raleway',
		'ramaraja' => 'Ramaraja',
		'rhodium libre'   => 'Rhodium Libre',
		'roboto'     => 'Roboto',
		'Roboto Condensed' => 'Roboto Condensed',
		'ruda'    => 'Ruda',
		'sahitya'  => 'Sahitya',
		'salsa' => 'Salsa',
		'sanchez'     => 'Sanchez',
		'send flowers'   => 'Send Flowers',
		'shanti' => 'Shanti',
		'shippori mincho'   => 'Shippori Mincho',
		'solway'     => 'Solway',
		'sofia'    => 'Sofia',
		'tapestry'  => 'Tapestry',
		'texturina' => 'Texturina',
		'tillana'     => 'Tillana',
		'xanh mono'   => 'Xanh Mono',
		'yeon sung' => 'Yeon Sung',
		'yuji boku'   => 'Yuji Boku',
		'yusei magic'     => 'Yusei Magic',
		'zen antique'    => 'Zen Antique',
		'zen dots'  => 'Zen Dots',
		'zen old mincho' => 'Zen Old Mincho',
	));
}

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

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