-
Notifications
You must be signed in to change notification settings - Fork 0
/
sinitize-russian.php
87 lines (84 loc) · 1.48 KB
/
sinitize-russian.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/*
Plugin Name: Sanitize Russian Urls and Filenames
Plugin URI: https://github.com/4selin/sanitize-russian
Description: Транслитерация руских букв для ссылок и файлов
Author: Alexey Selin <[email protected]>
Version: 0.1.1
*/
function sanitizze( $title ) {
$config = [
"А" => "A",
"Б" => "B",
"В" => "V",
"Г" => "G",
"Д" => "D",
"Е" => "E",
"Ё" => "JO",
"Ж" => "ZH",
"З" => "Z",
"И" => "I",
"Й" => "J",
"К" => "K",
"Л" => "L",
"М" => "M",
"Н" => "N",
"О" => "O",
"П" => "P",
"Р" => "R",
"С" => "S",
"Т" => "T",
"У" => "U",
"Ф" => "F",
"Х" => "H",
"Ц" => "C",
"Ч" => "CH",
"Ш" => "SH",
"Щ" => "SHCH",
"Ъ" => "",
"Ы" => "Y",
"Ь" => "",
"Э" => "E",
"Ю" => "YU",
"Я" => "YA",
"а" => "a",
"б" => "b",
"в" => "v",
"г" => "g",
"д" => "d",
"е" => "e",
"ё" => "yo",
"ж" => "zh",
"з" => "z",
"и" => "i",
"й" => "j",
"к" => "k",
"л" => "l",
"м" => "m",
"н" => "n",
"о" => "o",
"п" => "p",
"р" => "r",
"с" => "s",
"т" => "t",
"у" => "u",
"ф" => "f",
"х" => "h",
"ц" => "c",
"ч" => "ch",
"ш" => "sh",
"щ" => "shch",
"ъ" => "",
"ы" => "y",
"ь" => "",
"э" => "e",
"ю" => "yu",
"я" => "ya",
"«" => "",
"»" => "",
"—" => "-",
];
return strtr( $title, $config );
}
add_action( 'sanitize_title', 'sanitizze', 0 );
add_filter( 'sanitize_file_name', 'sanitizze', 0 );