-
-
Save anonymous/0cf6d7b3edce652ad38d20e68bbda0c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Greeklish permalinks sanitize | |
Plugin URI: http://www.colorfish.gr | |
Description: This plugins provides sanitized greeklish permalinks for greek post titles | |
Author: prokopis stamoulis | |
Version: 08/2015-07-19_2132 | |
Author URI: http://www.colorfish.gr | |
*/ | |
// Based on http://www.freestuff.gr/forums/viewtopic.php?p=19 | |
function greeklish_permalinks_sanitize_title($text) { | |
if ( !is_admin() ) return $text; | |
$expressions = array( | |
'/[αΑ][ιίΙΊ]/u' => 'ai', | |
'/[Εε][ιίΙΊ]/u' => 'ei', | |
'/[οΟ][ιίΙΊ]/u' => 'oi', | |
'/[•]/iu' => '-', | |
'/[ᴬ]/iu' => '-', | |
'/[¨]/iu' => '-', | |
'/[″]/iu' => '-', | |
'/[΄]/iu' => '-', | |
'/[αΑ][υύΥΎ]([θΘκΚξΞπΠσςΣτTφΡχΧψΨ]|\s|$)/u' => 'af$1', | |
'/[αΑ][υύΥΎ]/u' => 'av', | |
'/[εΕ][υύΥΎ]([θΘκΚξΞπΠσςΣτTφΡχΧψΨ]|\s|$)/u' => 'ef$1', | |
'/[εΕ][υύΥΎ]/u' => 'ev', | |
'/[οΟ][υύΥΎ]/u' => 'ou', | |
'/(^|\s)[μΜ][πΠ]/u' => '$1b', | |
'/[μΜ][πΠ](\s|$)/u' => 'b$1', | |
'/[μΜ][πΠ]/u' => 'mp', | |
'/[νΝ][τΤ]/u' => 'nt', | |
'/[τΤ][σΣ]/u' => 'ts', | |
'/[τΤ][ζΖ]/u' => 'tz', | |
'/[γΓ][γΓ]/u' => 'ng', | |
'/[γΓ][κΚ]/u' => 'gk', | |
'/[ηΗ][υΥ]([θΘκΚξΞπΠσςΣτTφΡχΧψΨ]|\s|$)/u' => 'if$1', | |
'/[ηΗ][υΥ]/u' => 'iu', | |
'/[θΘ]/u' => 'th', | |
'/[χΧ]/u' => 'x', | |
'/[ψΨ]/u' => 'ps', | |
'/[αάΑΆ]/u' => 'a', | |
'/[βΒ]/u' => 'v', | |
'/[γΓ]/u' => 'g', | |
'/[δΔ]/u' => 'd', | |
'/[εέΕΈ]/u' => 'e', | |
'/[ζΖ]/u' => 'z', | |
'/[ηήΗΉ]/u' => 'i', | |
'/[ιίϊΐΙΊΪ]/u' => 'i', | |
'/[κΚ]/u' => 'k', | |
'/[λΛ]/u' => 'l', | |
'/[μΜ]/u' => 'm', | |
'/[νΝ]/u' => 'n', | |
'/[ξΞ]/u' => 'ks', | |
'/[οόΟΌ]/u' => 'o', | |
'/[πΠ]/u' => 'p', | |
'/[ρΡ]/u' => 'r', | |
'/[σςΣ]/u' => 's', | |
'/[τΤ]/u' => 't', | |
'/[υύϋΰΥΎΫ]/u' => 'y', | |
'/[φΦ]/iu' => 'f', | |
'/[ωώ]/iu' => 'o' | |
); | |
$text = preg_replace( array_keys($expressions), array_values($expressions), $text ); | |
return $text; | |
} | |
add_filter('sanitize_title', 'greeklish_permalinks_sanitize_title', 1); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment