Skip to content

Instantly share code, notes, and snippets.

@meishern
Last active December 17, 2015 20:08
Show Gist options
  • Save meishern/5665108 to your computer and use it in GitHub Desktop.
Save meishern/5665108 to your computer and use it in GitHub Desktop.
German + Cyrillic + Greek - Enfold Theme Function - /framework/php/function-set-avia-backend.php lines 89-128
if(!function_exists('avia_backend_safe_string'))
{
/**
* Create a lower case version of a string without spaces so we can use that string for database settings
*
* @param string $string to convert
* @return string the converted string
*/
function avia_backend_safe_string( $string , $replace = "_")
{
$string = strtolower($string);
$trans = array(
'&\#\d+?;' => '', '&\S+?;' => '', '\s+' => $replace,
//-------German Start
'ä' => 'ae', 'ö' => 'oe', 'ü' => 'ue', 'Ä' => 'Ae',
'Ö' => 'Oe','Ü' => 'Ue','ß' => 'ss',
//-------Cyrillic Start
'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', 'Ѓ' => 'G`',
'Ґ' => 'G`', 'Д' => 'D', 'Е' => 'E', 'Ё' => 'YO', 'Є' => 'YE',
'Ж' => 'ZH', 'З' => 'Z', 'Ѕ' => 'Z', 'И' => 'I', 'Й' => 'J',
'Ј' => 'J', 'І' => 'I', 'Ї' => 'YI', 'К' => 'K', 'Ќ' => 'K`',
'Л' => 'L', 'Љ' => 'L', 'М' => 'M', 'Н' => 'N', 'Њ' => 'N`',
'О' => 'O', 'П' => 'P', 'Р' => 'R', 'С' => 'S', 'Т' => 'T',
'У' => 'U', 'Ў' => 'U`', 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'TS',
'Ч' => 'CH', 'Џ' => 'DH', 'Ш' => 'SH', 'Щ' => 'SHH', 'Ъ' => '``',
'Ы' => 'Y`', 'Ь' => '`', 'Э' => 'E`', 'Ю' => 'YU', 'Я' => 'YA',
'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'ѓ' => 'g',
'ґ' => 'g', 'д' => 'd', 'е' => 'e', 'ё' => 'yo', 'є' => 'ye',
'ж' => 'zh', 'з' => 'z', 'ѕ' => 'z', 'и' => 'i', 'й' => 'j',
'ј' => 'j', 'і' => 'i', 'ї' => 'yi', 'к' => 'k', 'ќ' => 'k`',
'л' => 'l', 'љ' => 'l', 'м' => 'm', 'н' => 'n', 'њ' => 'n`',
'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's', 'т' => 't',
'у' => 'u', 'ў' => 'u`', 'ф' => 'f', 'х' => 'h', 'ц' => 'ts',
'ч' => 'ch', 'џ' => 'dh', 'ш' => 'sh', 'щ' => 'shh', 'ъ' => '``',
'ы' => 'y`', 'ь' => '`', 'э' => 'e`', 'ю' => 'yu', 'я' => 'ya',
//-------Greek Start
'Α' => 'A', 'α' => 'a', 'Β' => 'B', 'β' => 'b', 'Γ' => 'G',
'γ' => 'g', 'Δ' => 'D', 'δ' => 'd', 'Ε' => 'E', 'ε' => 'e',
'Ζ' => 'Z', 'ζ' => 'z', 'Η' => 'H', 'η' => 'h', 'Θ' => 'Q',
'θ' => 'q', 'Ι' => 'I', 'ι' => 'i', 'Κ' => 'K', 'κ' => 'k',
'Λ' => 'L', 'λ' => 'l', 'Μ' => 'M', 'μ' => 'm', 'Ν' => 'N',
'ν' => 'n', 'Ξ' => 'X', 'ξ' => 'x', 'Ο' => 'O', 'ο' => 'o',
'Π' => 'P', 'π' => 'p', 'Ρ' => 'R', 'ρ' => 'r', 'Σ' => 'S',
'σ' => 's', 'Τ' => 'T', 'τ' => 't', 'Υ' => 'Y', 'υ' => 'y',
'Φ' => 'F', 'φ' => 'f', 'Χ' => 'C', 'χ' => 'c', 'Ψ' => 'U',
'ψ' => 'u', 'Ω' => 'W', 'ω' => 'w',
//-------End Languages
'[^a-z0-9\-\._]' => '', $replace.'+' => $replace,
$replace.'$' => $replace, '^'.$replace => $replace, '\.+$' => ''
);//end of $trans array
$string = strip_tags($string);
foreach ($trans as $key => $val)
{
$string = preg_replace("#".$key."#i", $val, $string);
}
return stripslashes($string);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment