Greeklish addresses for Greek titles
New posts, pages, products, categories and tags with Greek titles get addresses in Latin letters: “Καλοκαιρινά φορέματα” becomes kalokairina-foremata. Existing addresses don’t change.
<?php
$greeklish = static function ( string $text ): string {
$text = mb_strtolower( $text, 'UTF-8' );
$text = strtr( $text, array( 'ου' => 'ou', 'ού' => 'ou' ) );
return strtr(
$text,
array(
'α' => 'a', 'ά' => 'a', 'β' => 'v', 'γ' => 'g', 'δ' => 'd', 'ε' => 'e', 'έ' => 'e',
'ζ' => 'z', 'η' => 'i', 'ή' => 'i', 'θ' => 'th', 'ι' => 'i', 'ί' => 'i', 'ϊ' => 'i',
'ΐ' => 'i', 'κ' => 'k', 'λ' => 'l', 'μ' => 'm', 'ν' => 'n', 'ξ' => 'x', 'ο' => 'o',
'ό' => 'o', 'π' => 'p', 'ρ' => 'r', 'σ' => 's', 'ς' => 's', 'τ' => 't', 'υ' => 'y',
'ύ' => 'y', 'ϋ' => 'y', 'ΰ' => 'y', 'φ' => 'f', 'χ' => 'ch', 'ψ' => 'ps', 'ω' => 'o',
'ώ' => 'o',
)
);
};
add_filter(
'sanitize_title',
static function ( $title, $raw_title = '', $context = 'display' ) use ( $greeklish ) {
if ( 'save' === $context && preg_match( '/\p{Greek}/u', (string) $title ) ) {
return $greeklish( (string) $title );
}
return $title;
},
5,
3
);
In these packs
- Greek e-shop: For shops in Greece: receipt or invoice with a checked VAT number (ΑΦΜ), Greek phone and postcode checks, a cash on delivery fee, and greeklish addresses.