Cyr to Lat reloaded – transliteration of links and file names - Version 1.1.1

Version Description

  • Added: Greek symbols
  • Added: Special symbols
  • Added: Ability to rollback changes
  • Fixed: Bug with transliteration of Ukrainian symbols
Download this release

Release Info

Developer webcraftic
Plugin Icon 128x128 Cyr to Lat reloaded – transliteration of links and file names
Version 1.1.1
Comparing to
See all releases

Code changes from version 1.0.3 to 1.1.1

Files changed (3) hide show
  1. admin-notices.php +472 -0
  2. cyr-and-lat.php +395 -111
  3. readme.txt +86 -13
admin-notices.php ADDED
@@ -0,0 +1,472 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Admin Notices class
5
+ *
6
+ * @package WordPress
7
+ * @subpackage Admin Notices
8
+ */
9
+ class Admin_Notices {
10
+
11
+ // Configuration
12
+ // ---------------------------------------------------------------------------------------------------
13
+
14
+ /**
15
+ * Plugin suggestions
16
+ */
17
+ private $days_dismissing_suggestions = 180; // 6 months reappear
18
+ private $suggestions_message;
19
+ private $suggestions;
20
+
21
+ // Properties
22
+ // ---------------------------------------------------------------------------------------------------
23
+ /**
24
+ * Store missing plugins
25
+ */
26
+ private $missing;
27
+ /**
28
+ * Default prefix
29
+ * Can be changed by the external initialization.
30
+ */
31
+ private $prefix = 'lbladn';
32
+ /**
33
+ * Caller plugin file
34
+ */
35
+ private $plugin_file;
36
+
37
+ /**
38
+ * Single class instance
39
+ */
40
+ private static $instance;
41
+
42
+ // Initialization
43
+ // ---------------------------------------------------------------------------------------------------
44
+
45
+ /**
46
+ * Create or retrieve instance
47
+ */
48
+ public static function instance($plugin_file = null)
49
+ {
50
+
51
+ // Avoid direct calls
52
+ if( !function_exists('add_action') ) {
53
+ die;
54
+ }
55
+
56
+ // Check instance
57
+ if( !isset(self::$instance) ) {
58
+ self::$instance = new self($plugin_file);
59
+ }
60
+
61
+ // Done
62
+ return self::$instance;
63
+ }
64
+
65
+
66
+ /**
67
+ * Constructor
68
+ */
69
+ private function __construct($plugin_file = null)
70
+ {
71
+ // Main plugin file
72
+ $this->plugin_file = isset($plugin_file)
73
+ ? $plugin_file
74
+ : __FILE__;
75
+
76
+ // Uninstall hook endpoint
77
+ register_uninstall_hook($this->plugin_file, array(__CLASS__, 'uninstall'));
78
+
79
+ // Prefix from namespace constant
80
+ $this->prefix = 'wbcr_cyrandlat_an_';
81
+
82
+ if( in_array(get_locale(), array('ru_RU', 'bel', 'kk', 'uk', 'bg', 'bg_BG', 'ka_GE')) ) {
83
+ $this->suggestions_message = '<b>%plugin% Внимание:</b><br>Ваши старые ссылки записей, рубрик и меток автоматически преобразуются в латинские!
84
+ Если что-то пошло не так или вы не знали, что этот плагин работает автоматически, вы можете сделать откат преобразованных ссылок с помощью плагина <a href="https://ru.wordpress.org/plugins/cyrlitera/" target="_blank">Cyrlitera</a>. Cyr to lat reloaded совместим с плагином <a href="https://wordpress.org/plugins/cyrlitera/" target="_blank">Cyrlitera</a>, поэтому используя плагин Cyrlitera вы можете откатить изменения плагина Cyr to lat reloaded. В любом случае, если у вас что-то не получается, пожалуйста, сообщите нам о проблеме на <a href="https://wordpress.org/support/plugin/cyr-and-lat" target="_blank">форуме поддержки</a>, мы поможем вам!';
85
+ $this->suggestions = array(
86
+ 'cyrlitera' => array(
87
+ 'name' => 'Cyrlitera - это расширенный плагин транслитерации',
88
+ 'desc' => 'В отличии от Cyr to lat reloaded, плагин Cyrlitera имеет удобный интерфейс для полного контроля преобразования ссылок, возможность отката преобразованных ссылок, возможность перенаправления со старых ссылок на новые, для устранения битых ссылок.',
89
+ 'filename' => 'cyrlitera.php',
90
+ ),
91
+ 'clearfy' => array(
92
+ 'name' => '<span style="color:#f44336;">Clearfy - базовая оптимизация Wordpress одним плагином</span>',
93
+ 'desc' => 'Это бесплатный плагин для оптимизации Wordpress, в него включены функции транслитерации ссылок и файловых имен. Мы рекомендуем вам использовать его, потому что он выполняет комплексуню оптимизацию, улучшает SEO, улучшает защиту вашего сайта, ускоряет ваш сайт не заменяя популярные плагины оптимизации, а просто дополняя их. К примеру вы можете расширить возможности YOAST SEO на 30%, а плагинов оптимизации скорости на 15-20%! Clearfy позволит вам избавиться от большого количества мелких плагинов и уменьшит нагрузку на ваш сайт. Попробуйте, ведь это бесплатно!',
94
+ 'url' => 'https://ru.clearfy.pro/?utm_source=wordpress.org&utm_campaign=cyr-and-lat',
95
+ )
96
+ );
97
+ } else {
98
+ $this->suggestions_message = '<b>%plugin% Warning:</b><br>
99
+ Your old slugs, posts and terms are automatically converted to Latin!
100
+ If something went wrong or you did not know that this plugin works automatically, you can rollback the converted links using the <a href="https://wordpress.org/plugins/cyrlitera/" target="_blank">Cyrlitera</a> plugin.
101
+ Cyr to lat reloaded is compatible with the Cyrlitera plugin, so using the <a href="https://wordpress.org/plugins/cyrlitera/" target="_blank">Cyrlitera</a> plugin you can roll back the Cyr to lat reloaded plugin. In any case, if something does not work out for you, please let us know about the problem on the <a href="https://wordpress.org/support/plugin/cyr-and-lat" target="_blank">support forum</a>, we will help you!';
102
+ $this->suggestions = array(
103
+ 'cyrlitera' => array(
104
+ 'name' => 'Cyrlitera - plugin for transliteration with extended features',
105
+ 'desc' => 'Unlike Cyr to lat reloaded, the Cyrlitera plugin has a convenient interface for full control for tranliteration links, the ability to rollback converted links, the ability to redirect from old links to new ones, to eliminate broken links.',
106
+ 'filename' => 'cyrlitera.php',
107
+ ),
108
+ 'clearfy' => array(
109
+ 'name' => '<span style="color:#f44336;">Clearfy - base Wordpress optimization in one plugin</span>',
110
+ 'desc' => 'This is a free plugin to optimize Wordpress, it includes transliteration functions for links and file names. We recommend that you use it, because it performs complex optimization, improves SEO, improves securety of your site, speeds up your site without replacing the popular optimization plugins, but simply completing them. For example, you can extended YOAST SEO features at 30%, and speed optimization plug-ins by 15-20%! Clearfy will allow you to get rid of a large number of small plug-ins and reduce the load on your site. Try it, it\'s free!',
111
+ 'url' => 'https://clearfy.pro/?utm_source=wordpress.org&utm_campaign=cyr-and-lat',
112
+ )
113
+ );
114
+ }
115
+
116
+ // Check notices
117
+ if( is_admin() ) {
118
+ $this->check_timestamps();
119
+ $this->check_suggestions();
120
+ }
121
+ }
122
+
123
+ // Timestamp checks
124
+ // ---------------------------------------------------------------------------------------------------
125
+
126
+ /**
127
+ * Creates the activation timestamp only if it does not exist
128
+ */
129
+ private function check_timestamps()
130
+ {
131
+ $timestamp = $this->get_activation_timestamp();
132
+ if( empty($timestamp) ) {
133
+ $this->update_activation_timestamp();
134
+ }
135
+ }
136
+
137
+ /**
138
+ * Check the suggestions dismissed timestamp
139
+ */
140
+ private function check_suggestions()
141
+ {
142
+
143
+ // Compare timestamp
144
+ $timestamp = $this->get_dismissed_timestamp('suggestions');
145
+ if( empty($timestamp) || (time() - $timestamp) > ($this->days_dismissing_suggestions * 86400) ) {
146
+
147
+ // Check AJAX submit
148
+ if( defined('DOING_AJAX') && DOING_AJAX ) {
149
+ add_action('wp_ajax_' . $this->prefix . '_dismiss_suggestions', array(
150
+ &$this,
151
+ 'dismiss_suggestions'
152
+ ));
153
+ // Admin area (except install or activate plugins page)
154
+ } elseif( !in_array(basename($_SERVER['PHP_SELF']), array(
155
+ 'plugins.php',
156
+ 'plugin-install.php',
157
+ 'update.php'
158
+ ))
159
+ ) {
160
+ add_action('wp_loaded', array(&$this, 'load_notices_suggestions'), PHP_INT_MAX);
161
+ }
162
+ }
163
+ }
164
+
165
+ // Loaders
166
+ // ---------------------------------------------------------------------------------------------------
167
+
168
+ /**
169
+ * Check and load the sugestions notices
170
+ */
171
+ public function load_notices_suggestions()
172
+ {
173
+ // Check the disable nag constant
174
+ if( $this->disable_nag_notices() ) {
175
+ return;
176
+ }
177
+
178
+ // Collect missing plugins
179
+ $this->missing = $this->get_missing_plugins();
180
+ if( !empty($this->missing) && is_array($this->missing) ) {
181
+ add_action('admin_footer', array(&$this, 'admin_footer_suggestions'));
182
+ add_action('admin_notices', array(&$this, 'admin_notices_suggestions'));
183
+ }
184
+ }
185
+
186
+ // Admin Notices display
187
+ // ---------------------------------------------------------------------------------------------------
188
+
189
+ /**
190
+ * Suggestions display
191
+ */
192
+ public function admin_notices_suggestions()
193
+ {
194
+ $plugin_data = get_plugin_data($this->plugin_file);
195
+
196
+ ?>
197
+ <div class="<?php echo esc_attr($this->prefix); ?>-dismiss-suggestions notice notice-success is-dismissible" data-nonce="<?php echo esc_attr(wp_create_nonce($this->prefix . '-dismiss-suggestions')); ?>">
198
+ <p><?php echo str_replace('%plugin%', $plugin_data['Name'], $this->suggestions_message); ?></p>
199
+ <ul><?php foreach($this->missing as $plugin) : ?>
200
+
201
+ <li><strong><?php echo $this->suggestions[$plugin]['name']; ?></strong>
202
+ <a href="<?php echo esc_url($this->get_install_url($plugin)); ?>">
203
+ <?php if( in_array(get_locale(), array(
204
+ 'ru_RU',
205
+ 'bel',
206
+ 'kk',
207
+ 'uk',
208
+ 'bg',
209
+ 'bg_BG',
210
+ 'ka_GE'
211
+ )) ): ?>
212
+ (Установить бесплатно)
213
+ <?php else: ?>
214
+ (Install for free)
215
+ <?php endif ?>
216
+ </a><br/><?php echo $this->suggestions[$plugin]['desc']; ?></li>
217
+
218
+ <?php endforeach; ?></ul>
219
+ </div>
220
+ <?php
221
+ }
222
+
223
+ // AJAX Handlers
224
+ // ---------------------------------------------------------------------------------------------------
225
+
226
+ /**
227
+ * Dismiss suggestions
228
+ */
229
+ public function dismiss_suggestions()
230
+ {
231
+ if( !empty($_POST['nonce']) && wp_verify_nonce($_POST['nonce'], $this->prefix . '-dismiss-suggestions') ) {
232
+ $this->update_dismissed_timestamp('suggestions');
233
+ }
234
+ }
235
+
236
+
237
+ // Plugins information retrieval
238
+ // ---------------------------------------------------------------------------------------------------
239
+
240
+ /**
241
+ * Retrieve uninstalled plugins
242
+ */
243
+ private function get_missing_plugins()
244
+ {
245
+
246
+ // Initialize
247
+ $inactive = array();
248
+
249
+ // Check plugins directory
250
+ $directories = array_merge(self::get_mu_plugins_directories(), self::get_plugins_directories());
251
+ if( !empty($directories) ) {
252
+ $required = array_keys($this->suggestions);
253
+ foreach($required as $plugin) {
254
+ if( !in_array($plugin, $directories) ) {
255
+ $inactive[] = $plugin;
256
+ }
257
+ }
258
+ }
259
+
260
+ // Check inactives
261
+ if( empty($inactive) ) {
262
+ return false;
263
+ }
264
+
265
+ // Done
266
+ return $inactive;
267
+ }
268
+
269
+
270
+ /**
271
+ * Collects all active plugins
272
+ */
273
+ private function get_plugins_directories()
274
+ {
275
+
276
+ // Initialize
277
+ $directories = array();
278
+
279
+ // Plugins split directory
280
+ $split = '/' . basename(WP_CONTENT_DIR) . '/' . basename(WP_PLUGIN_DIR) . '/';
281
+
282
+ // Multisite plugins
283
+ if( is_multisite() ) {
284
+ $ms_plugins = wp_get_active_network_plugins();
285
+ if( !empty($ms_plugins) && is_array($ms_plugins) ) {
286
+ foreach($ms_plugins as $file) {
287
+ $directory = explode($split, $file);
288
+ $directory = explode('/', ltrim($directory[1], '/'));
289
+ $directory = $directory[0];
290
+ if( !in_array($directory, $directories) ) {
291
+ $directories[] = $directory;
292
+ }
293
+ }
294
+ }
295
+ }
296
+
297
+ // Active plugins
298
+ $plugins = wp_get_active_and_valid_plugins();
299
+ if( !empty($plugins) && is_array($plugins) ) {
300
+ foreach($plugins as $file) {
301
+ $directory = explode($split, $file);
302
+ $directory = explode('/', ltrim($directory[1], '/'));
303
+ $directory = $directory[0];
304
+ if( !in_array($directory, $directories) ) {
305
+ $directories[] = $directory;
306
+ }
307
+ }
308
+ }
309
+
310
+ // Done
311
+ return $directories;
312
+ }
313
+
314
+
315
+ /**
316
+ * Retrieve mu-plugins directories
317
+ */
318
+ private function get_mu_plugins_directories()
319
+ {
320
+
321
+ // Initialize
322
+ $directories = array();
323
+
324
+ // Dependencies
325
+ if( !function_exists('get_plugins') ) {
326
+ require_once(ABSPATH . 'wp-admin/includes/plugin.php');
327
+ }
328
+
329
+ // Retrieve mu-plugins
330
+ $plugins = get_plugins('/../mu-plugins');
331
+ if( !empty($plugins) && is_array($plugins) ) {
332
+ foreach($plugins as $path => $info) {
333
+ $directory = dirname($path);
334
+ if( !in_array($directory, array('.', '..')) ) {
335
+ $directories[] = $directory;
336
+ }
337
+ }
338
+ }
339
+
340
+ // Done
341
+ return $directories;
342
+ }
343
+
344
+
345
+ /**
346
+ * Plugin install/activate URL
347
+ */
348
+ private function get_install_url($plugin)
349
+ {
350
+ if( !isset($this->suggestions[$plugin]['filename']) && isset($this->suggestions[$plugin]['url']) ) {
351
+ return $this->suggestions[$plugin]['url'];
352
+ }
353
+
354
+ // Check existing plugin
355
+ $exists = @file_exists(WP_PLUGIN_DIR . '/' . $plugin);
356
+
357
+ // Activate
358
+ if( $exists ) {
359
+
360
+ // Existing plugin
361
+ $path = $plugin . '/' . $this->suggestions[$plugin]['filename'];
362
+
363
+ return admin_url('plugins.php?action=activate&plugin=' . $path . '&_wpnonce=' . wp_create_nonce('activate-plugin_' . $path));
364
+ // Install
365
+ } else {
366
+
367
+ // New plugin
368
+ return admin_url('update.php?action=install-plugin&plugin=' . $plugin . '&_wpnonce=' . wp_create_nonce('install-plugin_' . $plugin));
369
+ }
370
+ }
371
+
372
+ /**
373
+ * Determines the admin notices display
374
+ */
375
+ private function disable_nag_notices()
376
+ {
377
+ return (defined('DISABLE_NAG_NOTICES') && DISABLE_NAG_NOTICES);
378
+ }
379
+
380
+ // Plugin related
381
+ // ---------------------------------------------------------------------------------------------------
382
+
383
+ /**
384
+ * Plugin uninstall hook
385
+ */
386
+ public static function uninstall()
387
+ {
388
+ $admin_notices = self::instance();
389
+ $admin_notices->delete_activation_timestamp();
390
+ $admin_notices->delete_dismissed_timestamp('suggestions');
391
+ }
392
+
393
+
394
+
395
+ // Activation timestamp management
396
+ // ---------------------------------------------------------------------------------------------------
397
+
398
+ /**
399
+ * Retrieves the plugin activation timestamp
400
+ */
401
+ private function get_activation_timestamp()
402
+ {
403
+ return (int)get_option($this->prefix . '_activated_on');
404
+ }
405
+
406
+ /**
407
+ * Updates activation timestamp
408
+ */
409
+ private function update_activation_timestamp()
410
+ {
411
+ update_option($this->prefix . '_activated_on', time(), true);
412
+ }
413
+
414
+ /**
415
+ * Removes activation timestamp
416
+ */
417
+ private function delete_activation_timestamp()
418
+ {
419
+ delete_option($this->prefix . '_activated_on');
420
+ }
421
+
422
+ // Dismissed timestamp management
423
+ // ---------------------------------------------------------------------------------------------------
424
+
425
+ /**
426
+ * Current timestamp by key
427
+ */
428
+ private function get_dismissed_timestamp($key)
429
+ {
430
+ return (int)get_option($this->prefix . '_dismissed_' . $key . '_on');
431
+ }
432
+
433
+ /**
434
+ * Update with the current timestamp
435
+ */
436
+ private function update_dismissed_timestamp($key)
437
+ {
438
+ update_option($this->prefix . '_dismissed_' . $key . '_on', time(), true);
439
+ }
440
+
441
+ /**
442
+ * Removes dismissied option
443
+ */
444
+ private function delete_dismissed_timestamp($key)
445
+ {
446
+ delete_option($this->prefix . '_dismissed_' . $key . '_on');
447
+ }
448
+
449
+ // Javascript code
450
+ // ---------------------------------------------------------------------------------------------------
451
+
452
+ /**
453
+ * Footer script for Suggestions
454
+ */
455
+ public function admin_footer_suggestions()
456
+ {
457
+ ?>
458
+ <script type="text/javascript">
459
+ jQuery(function($) {
460
+
461
+ $(document).on('click', '.<?php echo $this->prefix; ?>-dismiss-suggestions .notice-dismiss', function() {
462
+ $.post(ajaxurl, {
463
+ 'action': '<?php echo $this->prefix; ?>_dismiss_suggestions',
464
+ 'nonce': $(this).parent().attr('data-nonce')
465
+ });
466
+ });
467
+
468
+ });
469
+ </script>
470
+ <?php
471
+ }
472
+ }
cyr-and-lat.php CHANGED
@@ -1,128 +1,412 @@
1
  <?php
2
- /*
3
- Plugin Name: Cyr-And-Lat
4
- Plugin URI:
5
- Description: Converts Cyrillic characters in post and term slugs to Latin characters. Useful for creating human-readable URLs. Allows to use both of cyrillic and latin slugs.
6
- Author:
7
- Author URI:
8
- Version: 1.0.3
9
- */
10
-
11
- function cal_sanitize_title($title,$savesymbols = false) {
12
- global $wpdb;
13
-
14
- $iso9_table = array(
15
- 'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', 'Ѓ' => 'G`',
16
- 'Ґ' => 'G`', 'Д' => 'D', 'Е' => 'E', 'Ё' => 'YO', 'Є' => 'YE',
17
- 'Ж' => 'ZH', 'З' => 'Z', 'Ѕ' => 'Z', 'И' => 'I', 'Й' => 'J',
18
- 'Ј' => 'J', 'І' => 'I', 'Ї' => 'YI', 'К' => 'K', 'Ќ' => 'K`',
19
- 'Л' => 'L', 'Љ' => 'L', 'М' => 'M', 'Н' => 'N', 'Њ' => 'N`',
20
- 'О' => 'O', 'П' => 'P', 'Р' => 'R', 'С' => 'S', 'Т' => 'T',
21
- 'У' => 'U', 'Ў' => 'U`', 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'TS',
22
- 'Ч' => 'CH', 'Џ' => 'DH', 'Ш' => 'SH', 'Щ' => 'SHH', 'Ъ' => '``',
23
- 'Ы' => 'Y`', 'Ь' => '`', 'Э' => 'E`', 'Ю' => 'YU', 'Я' => 'YA',
24
- 'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'ѓ' => 'g',
25
- 'ґ' => 'g', 'д' => 'd', 'е' => 'e', 'ё' => 'yo', 'є' => 'ye',
26
- 'ж' => 'zh', 'з' => 'z', 'ѕ' => 'z', 'и' => 'i', 'й' => 'j',
27
- 'ј' => 'j', 'і' => 'i', 'ї' => 'yi', 'к' => 'k', 'ќ' => 'k`',
28
- 'л' => 'l', 'љ' => 'l', 'м' => 'm', 'н' => 'n', 'њ' => 'n`',
29
- 'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's', 'т' => 't',
30
- 'у' => 'u', 'ў' => 'u`', 'ф' => 'f', 'х' => 'h', 'ц' => 'ts',
31
- 'ч' => 'ch', 'џ' => 'dh', 'ш' => 'sh', 'щ' => 'shh', 'ъ' => '``',
32
- 'ы' => 'y`', 'ь' => '`', 'э' => 'e`', 'ю' => 'yu', 'я' => 'ya'
33
- );
34
- $geo2lat = array(
35
- 'ა' => 'a', 'ბ' => 'b', 'გ' => 'g', 'დ' => 'd', 'ე' => 'e', 'ვ' => 'v',
36
- 'ზ' => 'z', 'თ' => 'th', 'ი' => 'i', 'კ' => 'k', 'ლ' => 'l', 'მ' => 'm',
37
- 'ნ' => 'n', 'ო' => 'o', 'პ' => 'p','ჟ' => 'zh','რ' => 'r','ს' => 's',
38
- 'ტ' => 't','უ' => 'u','ფ' => 'ph','ქ' => 'q','ღ' => 'gh','ყ' => 'qh',
39
- 'შ' => 'sh','ჩ' => 'ch','ც' => 'ts','ძ' => 'dz','წ' => 'ts','ჭ' => 'tch',
40
- 'ხ' => 'kh','ჯ' => 'j','ჰ' => 'h'
41
- );
42
- $iso9_table = array_merge($iso9_table, $geo2lat);
43
-
44
- $locale = get_locale();
45
- switch ( $locale ) {
46
- case 'bg_BG':
47
- $iso9_table['Щ'] = 'SHT';
48
- $iso9_table['щ'] = 'sht';
49
- $iso9_table['Ъ'] = 'A`';
50
- $iso9_table['ъ'] = 'a`';
51
- break;
52
- case 'uk':
53
- $iso9_table['И'] = 'Y`';
54
- $iso9_table['и'] = 'y`';
55
- break;
56
  }
57
 
58
- $is_term = false;
59
- $backtrace = debug_backtrace();
60
- foreach ( $backtrace as $backtrace_entry ) {
61
- if ( $backtrace_entry['function'] == 'wp_insert_term' ) {
62
- $is_term = true;
63
- break;
 
 
 
 
 
 
 
 
 
 
 
 
64
  }
65
- }
66
 
67
- $term = $is_term ? $wpdb->get_var("SELECT slug FROM {$wpdb->terms} WHERE name = '$title'") : '';
68
- if ( empty($term) ) {
69
- $title = strtr($title, apply_filters('cal_table', $iso9_table));
70
- if (function_exists('iconv')){
71
- $title = iconv('UTF-8', 'UTF-8//TRANSLIT//IGNORE', $title);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  }
73
- if (!$savesymbols) {
74
- $title = preg_replace("/[^A-Za-z0-9'_\-\.]/", '-', $title);
75
- $title = preg_replace('/\-+/', '-', $title);
76
- $title = preg_replace('/^-+/', '', $title);
77
- $title = preg_replace('/-+$/', '', $title);
78
- }
79
- } else {
80
- $title = $term;
81
- }
82
 
83
- return $title;
84
- }
85
- add_filter('sanitize_title', 'cal_sanitize_title', 9);
86
- add_filter('sanitize_file_name', 'cal_sanitize_title');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
 
88
- function cal_convert_existing_slugs() {
89
- global $wpdb;
90
 
91
- $posts = $wpdb->get_results("SELECT ID, post_name FROM {$wpdb->posts} WHERE post_name REGEXP('[^A-Za-z0-9\-]+') AND post_status IN ('publish', 'future', 'private')");
92
- foreach ( (array) $posts as $post ) {
93
- $sanitized_name = cal_sanitize_title(urldecode($post->post_name));
94
- if ( $post->post_name != $sanitized_name ) {
95
- add_post_meta($post->ID, '_wp_old_slug', $post->post_name);
96
- $wpdb->update($wpdb->posts, array( 'post_name' => $sanitized_name ), array( 'ID' => $post->ID ));
 
 
 
 
 
 
 
 
97
  }
98
- }
99
 
100
- $terms = $wpdb->get_results("SELECT term_id, slug FROM {$wpdb->terms} WHERE slug REGEXP('[^A-Za-z0-9\-]+') ");
101
- foreach ( (array) $terms as $term ) {
102
- $sanitized_slug = cal_sanitize_title(urldecode($term->slug));
103
- if ( $term->slug != $sanitized_slug ) {
104
- $wpdb->update($wpdb->terms, array( 'slug' => $sanitized_slug ), array( 'term_id' => $term->term_id ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  }
106
- }
107
- }
108
 
109
- function cal_schedule_conversion() {
110
- add_action('shutdown', 'cal_convert_existing_slugs');
111
- }
112
- register_activation_hook(__FILE__, 'cal_schedule_conversion');
 
 
 
 
 
 
 
 
113
 
114
- function cal_use_cyrillic_alias($request){
115
- if (isset($request['name'])){
116
- $request['name'] = cal_sanitize_title(urldecode($request['name']));
117
- }
118
- if (isset($request['category_name'])){
119
- $request['category_name'] = cal_sanitize_title(urldecode($request['category_name']),true);
120
- }
121
- if (isset($request['tag'])){
122
- $request['tag'] = cal_sanitize_title(urldecode($request['tag']));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  }
124
- return $request;
125
- }
126
- add_filter('request','cal_use_cyrillic_alias');
127
 
 
128
  ?>
1
  <?php
2
+ /*
3
+ Plugin Name: Webcraftic Cyr to Lat reloaded
4
+ Plugin URI: https://wordpress.org/plugins/cyr-and-lat/
5
+ Description: Converts Cyrillic characters in post and term slugs to Latin characters. Useful for creating human-readable URLs. Allows to use both of cyrillic and latin slugs.
6
+ Author: Webcraftic
7
+ Author URI: https://clearfy.pro
8
+ Version: 1.1.1
9
+ */
10
+
11
+ // Exit if accessed directly
12
+ if( !defined('ABSPATH') ) {
13
+ exit;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  }
15
 
16
+ class WCTL_Plugin {
17
+
18
+ public function __construct()
19
+ {
20
+ // Уведомления о расширенной версии плагина с пользовательским интерфейсовм.
21
+ // После скрытия больше не надоедают
22
+
23
+ require_once dirname(__FILE__) . '/admin-notices.php';
24
+ Admin_Notices::instance(__FILE__);
25
+
26
+ // Ссылка в матаданных плагина, на расширенную версию
27
+
28
+ add_filter('plugin_row_meta', array($this, 'setPluginMeta'), 10, 2);
29
+
30
+ register_activation_hook(__FILE__, array($this, 'scheduleConversion'));
31
+
32
+ add_filter('sanitize_title', array($this, 'sanitizeTitle'), 9);
33
+ add_filter('sanitize_file_name', array($this, 'sanitizeTitle'));
34
  }
 
35
 
36
+ /**
37
+ * Ссылка в метаданных плагина, на расширенную версию
38
+ *
39
+ * @param $links
40
+ * @param $file
41
+ * @return array
42
+ */
43
+ public function setPluginMeta($links, $file)
44
+ {
45
+ if( in_array(get_locale(), array('ru_RU', 'bel', 'kk', 'uk', 'bg', 'bg_BG', 'ka_GE')) ) {
46
+ $link_title = 'Получите расширенный плагин бесплатно';
47
+ $url = 'https://ru.clearfy.pro/?utm_source=wordpress.org&utm_campaign=cyr-and-lat';
48
+ } else {
49
+ $link_title = 'Get ultimate plugin for free';
50
+ $url = 'https://clearfy.pro/?utm_source=wordpress.org&utm_campaign=cyr-and-lat';
51
+ }
52
+
53
+ if( $file == plugin_basename(__FILE__) ) {
54
+ $links[] = '<a href="' . $url . '" style="color: #FF5722;font-weight: bold;" target="_blank">' . $link_title . '</a>';
55
+ }
56
+
57
+ return $links;
58
  }
 
 
 
 
 
 
 
 
 
59
 
60
+ /**
61
+ * @since 1.1.1
62
+ * @return void
63
+ */
64
+ public function scheduleConversion()
65
+ {
66
+ add_action('shutdown', array($this, 'convertExistingSlugs'));
67
+ }
68
+
69
+ /**
70
+ * Выполняет транслитерацию для старых записей, рубрик, меток в которых slug уже создан,
71
+ * также в этом методе предусмотрена возможность отката и совместимость с плагином Cyrlitera.
72
+ *
73
+ * @since 1.1.1
74
+ * @return void
75
+ */
76
+ public function convertExistingSlugs()
77
+ {
78
+ global $wpdb;
79
+
80
+ $posts = $wpdb->get_results("SELECT ID, post_name FROM {$wpdb->posts} WHERE post_name REGEXP('[^_A-Za-z0-9\-]+') AND post_status IN ('publish', 'future', 'private')");
81
+
82
+ foreach((array)$posts as $post) {
83
+ $sanitized_name = $this->sanitizeTitle(urldecode($post->post_name));
84
 
85
+ if( $post->post_name != $sanitized_name ) {
86
+ add_post_meta($post->ID, 'wbcr_wp_old_slug', $post->post_name);
87
 
88
+ $wpdb->update($wpdb->posts, array('post_name' => $sanitized_name), array('ID' => $post->ID), array('%s'), array('%d'));
89
+ }
90
+ }
91
+
92
+ $terms = $wpdb->get_results("SELECT term_id, slug FROM {$wpdb->terms} WHERE slug REGEXP('[^_A-Za-z0-9\-]+') ");
93
+
94
+ foreach((array)$terms as $term) {
95
+ $sanitized_slug = $this->sanitizeTitle(urldecode($term->slug));
96
+
97
+ if( $term->slug != $sanitized_slug ) {
98
+ update_option('wbcr_wp_term_' . $term->term_id . '_old_slug', $term->slug, false);
99
+ $wpdb->update($wpdb->terms, array('slug' => $sanitized_slug), array('term_id' => $term->term_id), array('%s'), array('%d'));
100
+ }
101
+ }
102
  }
 
103
 
104
+ /**
105
+ * Фильтрует все вызовы экшенов sinitize_title и sanitize_file_name,
106
+ * возвращает преобразованную строку на латинице.
107
+ *
108
+ * @param string $title обработанный заголовок
109
+ * @return string
110
+ */
111
+ public function sanitizeTitle($title)
112
+ {
113
+ global $wpdb;
114
+
115
+ $origin_title = $title;
116
+
117
+ $is_term = false;
118
+ $backtrace = debug_backtrace();
119
+ foreach($backtrace as $backtrace_entry) {
120
+ if( $backtrace_entry['function'] == 'wp_insert_term' ) {
121
+ $is_term = true;
122
+ break;
123
+ }
124
+ }
125
+
126
+ $term = $is_term
127
+ ? $wpdb->get_var($wpdb->prepare("SELECT slug FROM {$wpdb->terms} WHERE name = '%s'", $title))
128
+ : '';
129
+
130
+ if( empty($term) ) {
131
+ $title = $this->transliterate($title);
132
+ } else {
133
+ $title = $term;
134
+ }
135
+
136
+ return apply_filters('wbcr_ctl_sanitize_title', $title, $origin_title);
137
  }
 
 
138
 
139
+ /**
140
+ * Очищает от специальных символов и преобразует все символы строки в латинские.
141
+ *
142
+ * @since 1.1.1
143
+ * @param string $title
144
+ * @param bool $ignore_special_symbols
145
+ * @return string
146
+ */
147
+ public function transliterate($title, $ignore_special_symbols = false)
148
+ {
149
+ $origin_title = $title;
150
+ $iso9_table = $this->getSymbolsPack();
151
 
152
+ $title = strtr($title, $iso9_table);
153
+
154
+ if( function_exists('iconv') ) {
155
+ $title = iconv('UTF-8', 'UTF-8//TRANSLIT//IGNORE', $title);
156
+ }
157
+
158
+ if( !$ignore_special_symbols ) {
159
+ $title = preg_replace("/[^A-Za-z0-9'_\-\.]/", '-', $title);
160
+ $title = preg_replace('/\-+/', '-', $title);
161
+ $title = preg_replace('/^-+/', '', $title);
162
+ $title = preg_replace('/-+$/', '', $title);
163
+ }
164
+
165
+ return apply_filters('wbcr_ctl_transliterate', $title, $origin_title, $iso9_table);
166
+ }
167
+
168
+
169
+ /**
170
+ * Метод возвращает базу символов в зависимости от установленной локали
171
+ *
172
+ * @since 1.1.1
173
+ * @return array
174
+ */
175
+ public function getSymbolsPack()
176
+ {
177
+ $loc = get_locale();
178
+
179
+ $ret = array(
180
+ // russian
181
+ 'А' => 'A',
182
+ 'а' => 'a',
183
+ 'Б' => 'B',
184
+ 'б' => 'b',
185
+ 'В' => 'V',
186
+ 'в' => 'v',
187
+ 'Г' => 'G',
188
+ 'г' => 'g',
189
+ 'Д' => 'D',
190
+ 'д' => 'd',
191
+ 'Е' => 'E',
192
+ 'е' => 'e',
193
+ 'Ё' => 'Jo',
194
+ 'ё' => 'jo',
195
+ 'Ж' => 'Zh',
196
+ 'ж' => 'zh',
197
+ 'З' => 'Z',
198
+ 'з' => 'z',
199
+ 'И' => 'I',
200
+ 'и' => 'i',
201
+ 'Й' => 'J',
202
+ 'й' => 'j',
203
+ 'К' => 'K',
204
+ 'к' => 'k',
205
+ 'Л' => 'L',
206
+ 'л' => 'l',
207
+ 'М' => 'M',
208
+ 'м' => 'm',
209
+ 'Н' => 'N',
210
+ 'н' => 'n',
211
+ 'О' => 'O',
212
+ 'о' => 'o',
213
+ 'П' => 'P',
214
+ 'п' => 'p',
215
+ 'Р' => 'R',
216
+ 'р' => 'r',
217
+ 'С' => 'S',
218
+ 'с' => 's',
219
+ 'Т' => 'T',
220
+ 'т' => 't',
221
+ 'У' => 'U',
222
+ 'у' => 'u',
223
+ 'Ф' => 'F',
224
+ 'ф' => 'f',
225
+ 'Х' => 'H',
226
+ 'х' => 'h',
227
+ 'Ц' => 'C',
228
+ 'ц' => 'c',
229
+ 'Ч' => 'Ch',
230
+ 'ч' => 'ch',
231
+ 'Ш' => 'Sh',
232
+ 'ш' => 'sh',
233
+ 'Щ' => 'Shh',
234
+ 'щ' => 'shh',
235
+ 'Ъ' => '',
236
+ 'ъ' => '',
237
+ 'Ы' => 'Y',
238
+ 'ы' => 'y',
239
+ 'Ь' => '',
240
+ 'ь' => '',
241
+ 'Э' => 'Je',
242
+ 'э' => 'je',
243
+ 'Ю' => 'Ju',
244
+ 'ю' => 'ju',
245
+ 'Я' => 'Ja',
246
+ 'я' => 'ja',
247
+ // global
248
+ 'Ґ' => 'G',
249
+ 'ґ' => 'g',
250
+ 'Є' => 'Ie',
251
+ 'є' => 'ie',
252
+ 'І' => 'I',
253
+ 'і' => 'i',
254
+ 'Ї' => 'I',
255
+ 'ї' => 'i',
256
+ 'Ї' => 'i',
257
+ 'ї' => 'i',
258
+ 'Ё' => 'Jo',
259
+ 'ё' => 'jo',
260
+ 'й' => 'i',
261
+ 'Й' => 'I'
262
+ );
263
+
264
+ // ukrainian
265
+ if( $loc == 'uk' ) {
266
+ $ret = array_merge($ret, array(
267
+ 'Г' => 'H',
268
+ 'г' => 'h',
269
+ 'И' => 'Y',
270
+ 'и' => 'y',
271
+ 'Х' => 'Kh',
272
+ 'х' => 'kh',
273
+ 'Ц' => 'Ts',
274
+ 'ц' => 'ts',
275
+ 'Щ' => 'Shch',
276
+ 'щ' => 'shch',
277
+ 'Ю' => 'Iu',
278
+ 'ю' => 'iu',
279
+ 'Я' => 'Ia',
280
+ 'я' => 'ia',
281
+
282
+ ));
283
+ //bulgarian
284
+ } elseif( $loc == 'bg' || $loc == 'bg_BG' ) {
285
+ $ret = array_merge($ret, array(
286
+ 'Щ' => 'Sht',
287
+ 'щ' => 'sht',
288
+ 'Ъ' => 'a',
289
+ 'ъ' => 'a'
290
+ ));
291
+ }
292
+
293
+ // Georgian
294
+ if( $loc == 'ka_GE' ) {
295
+ $ret = array_merge($ret, array(
296
+ 'ა' => 'a',
297
+ 'ბ' => 'b',
298
+ 'გ' => 'g',
299
+ 'დ' => 'd',
300
+ 'ე' => 'e',
301
+ 'ვ' => 'v',
302
+ 'ზ' => 'z',
303
+ 'თ' => 'th',
304
+ 'ი' => 'i',
305
+ 'კ' => 'k',
306
+ 'ლ' => 'l',
307
+ 'მ' => 'm',
308
+ 'ნ' => 'n',
309
+ 'ო' => 'o',
310
+ 'პ' => 'p',
311
+ 'ჟ' => 'zh',
312
+ 'რ' => 'r',
313
+ 'ს' => 's',
314
+ 'ტ' => 't',
315
+ 'უ' => 'u',
316
+ 'ფ' => 'ph',
317
+ 'ქ' => 'q',
318
+ 'ღ' => 'gh',
319
+ 'ყ' => 'qh',
320
+ 'შ' => 'sh',
321
+ 'ჩ' => 'ch',
322
+ 'ც' => 'ts',
323
+ 'ძ' => 'dz',
324
+ 'წ' => 'ts',
325
+ 'ჭ' => 'tch',
326
+ 'ხ' => 'kh',
327
+ 'ჯ' => 'j',
328
+ 'ჰ' => 'h'
329
+ ));
330
+ }
331
+
332
+ // Greek
333
+ if( $loc == 'el' ) {
334
+ $ret = array_merge($ret, array(
335
+ 'α' => 'a',
336
+ 'β' => 'v',
337
+ 'γ' => 'g',
338
+ 'δ' => 'd',
339
+ 'ε' => 'e',
340
+ 'ζ' => 'z',
341
+ 'η' => 'h',
342
+ 'θ' => 'th',
343
+ 'ι' => 'i',
344
+ 'κ' => 'k',
345
+ 'λ' => 'l',
346
+ 'μ' => 'm',
347
+ 'ν' => 'n',
348
+ 'ξ' => 'x',
349
+ 'ο' => 'o',
350
+ 'π' => 'p',
351
+ 'ρ' => 'r',
352
+ 'σ' => 's',
353
+ 'ς' => 's',
354
+ 'τ' => 't',
355
+ 'υ' => 'u',
356
+ 'φ' => 'f',
357
+ 'χ' => 'ch',
358
+ 'ψ' => 'ps',
359
+ 'ω' => 'o',
360
+ 'Α' => 'A',
361
+ 'Β' => 'V',
362
+ 'Γ' => 'G',
363
+ 'Δ' => 'D',
364
+ 'Ε' => 'E',
365
+ 'Ζ' => 'Z',
366
+ 'Η' => 'H',
367
+ 'Θ' => 'TH',
368
+ 'Ι' => 'I',
369
+ 'Κ' => 'K',
370
+ 'Λ' => 'L',
371
+ 'Μ' => 'M',
372
+ 'Ν' => 'N',
373
+ 'Ξ' => 'X',
374
+ 'Ο' => 'O',
375
+ 'Π' => 'P',
376
+ 'Ρ' => 'R',
377
+ 'Σ' => 'S',
378
+ 'Τ' => 'T',
379
+ 'Υ' => 'U',
380
+ 'Φ' => 'F',
381
+ 'Χ' => 'CH',
382
+ 'Ψ' => 'PS',
383
+ 'Ω' => 'O',
384
+ 'ά' => 'a',
385
+ 'έ' => 'e',
386
+ 'ή' => 'h',
387
+ 'ί' => 'i',
388
+ 'ό' => 'o',
389
+ 'ύ' => 'u',
390
+ 'ώ' => 'o',
391
+ 'Ά' => 'A',
392
+ 'Έ' => 'E',
393
+ 'Ή' => 'H',
394
+ 'Ί' => 'I',
395
+ 'Ό' => 'O',
396
+ 'Ύ' => 'U',
397
+ 'Ώ' => 'O',
398
+ 'ϊ' => 'i',
399
+ 'ΐ' => 'i',
400
+ 'ΰ' => 'u',
401
+ 'ϋ' => 'u',
402
+ 'Ϊ' => 'I',
403
+ 'Ϋ' => 'U'
404
+ ));
405
+ }
406
+
407
+ return apply_filters('wbcr_ctl_default_symbols_pack', $ret);
408
+ }
409
  }
 
 
 
410
 
411
+ new WCTL_Plugin();
412
  ?>
readme.txt CHANGED
@@ -1,29 +1,80 @@
1
- === Cyr-And-Lat reloaded ===
2
  Contributors: webcraftic, preslilvs
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=VDX7JNTQPNPFW
4
- Tags: cyrillic, latin, l10n, russian, rustolat, slugs, translations, transliteration, media, georgian, european, diacritics, muiltilanguage
5
- Requires at least: 2.3
6
  Tested up to: 4.9
7
  Requires PHP: 5.2
8
  Stable tag: trunk
9
  License: GPLv2
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
12
- Allows to use both "old" cyrillic and "new" latin slugs at the same time. Now it works for terms (tags and categories slugs) too.
13
 
14
  == Description ==
15
 
16
- Converts Cyrillic characters in post, page and term slugs to Latin characters. Useful for creating human-readable URLs. After the activation changes every slug to Latin characters, but old slugs will work too.
17
 
18
- = Features =
19
- * Automatically converts existing post, page and term slugs on activation.
20
- * Saves access to posts by old cyrillic slugs (prevents broken links).
21
- * Saves existing post and page permalinks integrity.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  * Performs transliteration of attachment file names.
23
- * Includes Russian, Belarusian, Ukrainian, Bulgarian and Macedonian characters
24
- * Transliteration table can be customized without editing the plugin itself
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
- Based on the Cyr-To-Lat plugin by Sergey Biryukov, which based on the original Rus-To-Lat plugin by Anton Skorobogatov.
 
 
 
27
 
28
  == Installation ==
29
 
@@ -42,10 +93,32 @@ function my_cyr_and_lat_table($cal_table) {
42
  $cal_table['ъ'] = 'u';
43
  return $cal_table;
44
  }
45
- add_filter('cal_table', 'my_cyr_and_lat_table');
46
  `
 
 
 
 
 
 
 
 
 
 
 
47
 
48
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
49
 
50
  = 1.0.2 =
51
  * Backward сompatibility with "old" russian slugs works in terms (tags and categories) too.
1
+ === Cyr to Lat reloaded – transliteration of links and file names===
2
  Contributors: webcraftic, preslilvs
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=VDX7JNTQPNPFW
4
+ Tags: cyr-to-lat, cyr to lat, rus to lat, cyrillic, latin, l10n, russian, rustolat, slugs, translations, transliteration, media, georgian, european, diacritics, muiltilanguage
5
+ Requires at least: 4.2
6
  Tested up to: 4.9
7
  Requires PHP: 5.2
8
  Stable tag: trunk
9
  License: GPLv2
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
12
+ Plugin converts Cyrillic, Georgian and Greek links and file names to Latin characters. This is essential for the accurate WordPress plugin operations, and visibly improves the readability of links.
13
 
14
  == Description ==
15
 
16
+ Cyr to lat reloaded is the improved version of the popular Cyr to lat plugin, created by Sergei Biriukov, and Rus-To-Lat plugin designed by Anton Skorobogatov. Even though the plugin is still easy & simple, we have updated both the symbol base and the source code, and fixed known bugs.
17
 
18
+ What is transliteration? This term usually refers to the action aiming to convert symbols from one language to another. For example, when we change Cyrillic symbols to Latin. Since the majority of the Internet uses Latin symbols, all software is designed with full Latin support – not Cyrillic, Chinese or whatever. That is why whenever you assign Cyrillic names, you can end up with access problems in their absolute URLs. Besides, Cyrillic in links really deteriorates absolute URLs readability. And it this case you might need transliteration of links and file names.
19
+
20
+ We have created a simple transliteration plugin named Cyr to lat reloaded. It replaces Cyrillic, Georgian and Turkish symbols with Latins automatically and creates readable absolute URLs for posts, sections, marks, products and custom post types. In addition, this plugin fixes incorrect file names and removes extra symbols, which may cause access problems.
21
+
22
+ **Here’s an example of Cyrillic URL:**
23
+
24
+ http://webcraftic.com/%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82-%D0%BC%D0%B8%D1%80
25
+
26
+ **Now the same link, but transliterated to Latin:**
27
+
28
+ http://webcraftic.com/privet-mir
29
+
30
+ Do you see the difference? The first one is encoded and recognized by browser only, when the second one with Latin symbols is shorter and much clearer.
31
+
32
+ **Incorrect file name of the image:**
33
+
34
+ %D0%BC%D0%BE%D0%B5_image_ 290.jpg
35
+
36
+ A+nice+picture.png
37
+
38
+ **The example of image transliteration – readable name without special characters:**
39
+
40
+ moe_image_ 290.jpg
41
+
42
+ a-nice-picture.png
43
+
44
+ You can ignore all basic rules of creating file names, but one day you’ll definitely deal with bad links in images and 404 error in direct links to the files.
45
+
46
+ We recommend naming files in Latin symbols. Cyr-to-lat reloaded plugin can do this for you automatically on each file loading. In this case, there will be no bad links.
47
+
48
+ **FEATURES**
49
+
50
+ * Converts absolute URLs of existing posts, pages, sections and tags automatically (after plugin activation);
51
+ * Preserves absolute URLs integrity;
52
+ * Transliterates file names in attachments;
53
  * Performs transliteration of attachment file names.
54
+ * Supports Russian, Belarusian, Ukrainian, Bulgarian, Georgian, Greek
55
+
56
+ #### EXTENDED VERSION OF THE PLUGIN WITH CONTROL PANEL ####
57
+ * [Cyrlitera – transliteration of links and file names](https://wordpress.org/plugins/cyrlitera/)
58
+ * [Clearfy – WordPress optimization plugin and disable ultimate tweaker](https://wordpress.org/plugins/clearfy/)
59
+
60
+ #### RECOMMENDED SEPARATE MODULES ####
61
+ We invite you to check out a few other related free plugins that our team has also produced that you may find especially useful:
62
+ * [Disable Comments for Any Post Types (Remove Comments)](https://wordpress.org/plugins/comments-plus/)
63
+ * [Disable updates, Disable automatic updates, Updates manager](https://wordpress.org/plugins/webcraftic-updates-manager/)
64
+ * [Disable admin notices individually](https://wordpress.org/plugins/disable-admin-notices/ "Disable admin notices individually")
65
+ * [WordPress Assets manager, dequeue scripts, dequeue styles](https://wordpress.org/plugins/gonzales/ "WordPress Assets manager, dequeue scripts, dequeue styles")
66
+ * [Hide login page](https://wordpress.org/plugins/hide-login-page/ "Hide login page")
67
+
68
+ **THANKS TO THE PLUGIN DEVELOPERS**
69
+
70
+ We’ve used some features of the following plugins:
71
+
72
+ Cyrlitera, WP Translitera, Rus-To-Lat, Cyr-To-Lat, Clearfy — WordPress optimization plugin, translit-it, Cyr to Lat enhanced, Cyr-And-Lat, Rus filename translit, rus to lat advanced
73
 
74
+ == Screenshots ==
75
+
76
+ 1. Example for posts
77
+ 2. Example for files
78
 
79
  == Installation ==
80
 
93
  $cal_table['ъ'] = 'u';
94
  return $cal_table;
95
  }
96
+ add_filter('wbcr_ctl_default_symbols_pack', 'my_cyr_and_lat_table');
97
  `
98
+ = Does this plugin support multisites? =
99
+
100
+ Unfortunately, the answer is no. It’s temporary, as we are trying to add this support in some of the future versions.
101
+
102
+ = How to restore converted slugs? =
103
+
104
+ You can roll back the changes you have made, using the extended version of [Cyrlitera plugin](https://wordpress.org/plugins/cyrlitera/ "Cyrlitera plugin").
105
+
106
+ = How can I redirect users from old links to new ones? =
107
+
108
+ You can do this by installing the extended version of [Cyrlitera plugin](https://wordpress.org/plugins/cyrlitera/ "Cyrlitera plugin")
109
 
110
  == Changelog ==
111
+ = 1.1.1 =
112
+ * Added: Greek symbols
113
+ * Added: Special symbols
114
+ * Added: Ability to rollback changes
115
+ * Fixed: Bug with transliteration of Ukrainian symbols
116
+
117
+ = 1.1.0 =
118
+ * Rename plugin, now the plugin has a name Webcraftic Cyr-And-Lat reloaded
119
+ * Updated character base
120
+ * Fixed compatibility issues
121
+ * Tested with the latest version of Wordpress
122
 
123
  = 1.0.2 =
124
  * Backward сompatibility with "old" russian slugs works in terms (tags and categories) too.