Using this recipe: Custom page creation modal
And setting language in supported languages (single language) results in a bug, i can’t create a new page using these modals from recipe, because slug didn’t work for Cyrillic symbols.
Using this recipe: Custom page creation modal
And setting language in supported languages (single language) results in a bug, i can’t create a new page using these modals from recipe, because slug didn’t work for Cyrillic symbols.
Here’s workaround for people, who will experience the same issue:
File location: /user/plugins/admin/classes/utils.php
public static function slug($str)
{
//Cyrillic
$contains_cyrillic = (bool) preg_match('/[\p{Cyrillic}]/u', $str);
if ($contains_cyrillic) {
$cyr = [
'а','б','в','г','д','е','ё','ж','з','и','й','к','л','м','н','о','п',
'р','с','т','у','ф','х','ц','ч','ш','щ','ъ','ы','ь','э','ю','я',
'А','Б','В','Г','Д','Е','Ё','Ж','З','И','Й','К','Л','М','Н','О','П',
'Р','С','Т','У','Ф','Х','Ц','Ч','Ш','Щ','Ъ','Ы','Ь','Э','Ю','Я',
// Kazakh letters
'ә','ғ','қ','ң','ө','ұ','ү','һ','і'
];
$lat = [
'a','b','v','g','d','e','e','zh','z','i','y','k','l','m','n','o','p',
'r','s','t','u','f','h','c','ch','sh','sh','a','i','y','e','yu','ya',
'A','B','V','G','D','E','Io','Zh','Z','I','Y','K','L','M','N','O','P',
'R','S','T','U','F','H','Ts','Ch','Sh','Sht','A','I','Y','e','Yu','Ya',
// Kazakh letters
'a','gh','q','ng','o','u','u','h','i'
];
$str = str_replace($cyr, $lat, $str);
}
if (function_exists('transliterator_transliterate')) {
$str = transliterator_transliterate('Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove;', $str);
} else {
$str = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $str);
}
$str = strtolower($str);
$str = preg_replace('/[-\s]+/', '-', $str);
$str = preg_replace('/[^a-z0-9-]/i', '', $str);
$str = trim($str, '-');
return $str;
}